tableClan = new CellTable<ItemsDataClan> (ItemsDataClan.KEY_PROVIDER);
//construct column in celltable tableClan , set data set sort handler etc ..
buildACellTableForCommunityClan(listClan);
ScrollPanel sPanel = new ScrollPanel();
//
sPanel.setStyleName("myCellTableStyle");
sPanel.setAlwaysShowScrollBars(true);
sPanel.setHeight("500px");
//sPanel.add(pagerClan);
sPanel.add(tableClan);
tp.add(sPanel, "Clans");
dockPanel.add(tp, DockPanel.SOUTH);
tp.selectTab(0);
tableClan.setVisible(true);
tableClan.setFocus(true);
searchUsersClanButton.setEnabled(true);
//on autorise le bouton more clans s'il y a en core 100 �lments dans TAB
// if(listClan.getItems().size()== 100)
// searchClansButtonMore.setEnabled(true);
// else {
// searchClansButtonMore.setEnabled(false);
// }
if(listClan.getItems().size()== 1) {
tableClan.getSelectionModel().setSelected(listClan.getItems().get(0), true);
//On pourrait chosir tout de suite les users du clan
}
}else {
dialogBox
.setText(status_code);
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(status_code + " An error arrived , please Retry again ! " );
dialogBox.center();
closeButton.setFocus(true);
}
}
});
//searchClanButton.setEnabled(true);
//searchClanButton.setFocus(true);
}
//
}
/////////////////////////
//creare a handler for persist data in datastore
// Create a handler for the Button search all clans
class HandlerPersistStats implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
//persist stats
persisStats(passSaving, nbUsersToTreat);
passSaving = 1 ;
nbUsersToTreat = 30;
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
persisStats(passSaving, nbUsersToTreat);
passSaving = 1 ;
nbUsersToTreat = 30;
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void persisStats(int indexBeginSaveStatsUser, int indexEndSaveStatsUser) {
hPanelLoading.setVisible(true);
// recup des users selected in dropBoxClanUsers
List<String> listIdUser = new ArrayList<String>();
int itemCount = dropBoxClanUsers.getItemCount();
for(int i = 0 ; i< itemCount ; i++) {
if (dropBoxClanUsers.isItemSelected(i)) {
listIdUser.add(dropBoxClanUsers.getValue(i));
}
}
// First, we validate the input.
errorLabel.setText("");
String textToServer = idClan;
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
return;
}
// Then, we send the input to the server.
//searchClanButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
wotService.persistStats(textToServer , indexBeginSaveStatsUser, indexEndSaveStatsUser, listIdUser,//offsetClan,
new AsyncCallback<List<String>>() {
public void onFailure(Throwable caught) {
hPanelLoading.setVisible(false);
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(List<String> listClan) {
hPanelLoading.setVisible(false);
// if (listClan.size()== 0) {
//
// dialogBox
// .setText(idClan);
// serverResponseLabel
// .addStyleName("serverResponseLabelError");
// serverResponseLabel.setHTML(idClan + " An error arrived , please Retry again ! " );
// dialogBox.center();
// closeButton.setFocus(true);
// }
}
});
//searchClanButton.setEnabled(true);
//searchClanButton.setFocus(true);
}
}
////
///////////
// Create a handler for search achivement's member
// class HandlerGetAchievementsMember implements ClickHandler, KeyUpHandler {
// /**
// * Fired when the user clicks on the sendButton.
// */
// public void onClick(ClickEvent event) {
// int indexSelected = dropBoxCategoryAchievement.getSelectedIndex();
// if (indexSelected >= 0 )
// {
// String valueSelected = dropBoxCategoryAchievement.getValue(indexSelected);
// getAchievementMember2(valueSelected);
// }
//// offsetClan = 0;
//// limitClan = 100;
// }
//
// /**
// * Fired when the user types in the nameField.
// */
// public void onKeyUp(KeyUpEvent event) {
// if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
// int indexSelected = dropBoxCategoryAchievement.getSelectedIndex();
// if (indexSelected >= 0 )
// {
// String valueSelected = dropBoxCategoryAchievement.getValue(indexSelected);
// getAchievementMember2(valueSelected);
// }
//// offsetClan = 0;
//// limitClan = 100;
// }
// }
// private void getAchievementMember2(String valueSelected) {
// hPanelLoading.setVisible(true);
// // First, we validate the input.
// errorLabel.setText("");
// String textToServer = idClan;
// if (!FieldVerifier.isValidName(textToServer)) {
// errorLabel.setText("Please enter at least four characters");
//
// /////
// dialogBox
// .setText("Select a Clan before!!");
// serverResponseLabel
// .addStyleName("serverResponseLabelError");
// serverResponseLabel.setHTML("Click on a clan before find members !" );
// dialogBox.center();
// closeButton.setFocus(true);
// hPanelLoading.setVisible(false);
// return;
// }
// dockPanel.remove(tableAchivementCommAcc);
// dockPanel.remove(tableStatsCommAcc);
// dockPanel. remove(tableClan);
//
//// if (pagerAchievementsCommunityAccount != null)
//// dockPanel.remove(pagerAchievementsCommunityAccount);
//// if (pagerStatsCommunityAccount != null)
//// dockPanel.remove(pagerStatsCommunityAccount);
//// if (pagerClan != null)
//// dockPanel.remove(pagerClan);
//
////
//// if (dataAchievementsProvider.getDataDisplays()!= null && !dataAchievementsProvider.getDataDisplays().isEmpty())
//// dataAchievementsProvider.removeDataDisplay(tableAchivementCommAcc);
////
// //on re-construit 1 nouveau tableau
// //tableAchivementCommAcc = new CellTable<CommunityAccount> (CommunityAccount.KEY_PROVIDER);
//
// //construct column in celltable tableCommAcc , set data set sort handler etc ..
// //buildACellTableForAchivementsCommunityAccount(dataStatsProvider.getList(), xmlWiki, valueSelected);
//
// //Create a Pager to control the table.
// //SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
// //pagerAchievementsCommunityAccount = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
// //pagerAchievementsCommunityAccount.setDisplay(tableAchivementCommAcc);
//
//
// //add to dock panel ======
// //add tab achievement a the end
// //dockPanel.add(pagerAchievementsCommunityAccount, DockPanel.SOUTH);
// //pagerAchievementsCommunityAccount.setPage(10);
// //pagerAchievementsCommunityAccount.setVisible(true);
//
// //dockPanel.add(tableAchivementCommAcc, DockPanel.SOUTH);
// //tableAchivementCommAcc.setVisible(true);
// //tableAchivementCommAcc.setFocus(true);
// //add tab stats
//// dockPanel.add(pagerStatsCommunityAccount, DockPanel.SOUTH);
//// pagerStatsCommunityAccount.setPage(10);
//// pagerStatsCommunityAccount.setVisible(true);
//
// dockPanel.add(tableStatsCommAcc, DockPanel.SOUTH);
// tableStatsCommAcc.setVisible(false);
//
// //add tab clan at the begin
// //dockPanel.add(pagerClan, DockPanel.SOUTH);
// //dockPanel.add(tableClan, DockPanel.SOUTH);
// tableClan.setVisible(true);
// //pagerClan.setVisible(true);
// hPanelLoading.setVisible(false);
// }
// }
//
///////////
// Create a handler for search clan's members
class HandlerGetAllMembersClanAndStats implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
getMembersClan();
offsetClan = 0;
limitClan = 100;
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
getMembersClan();
offsetClan = 0;
limitClan = 100;
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void getMembersClan() {
// First, we validate the input.
hPanelLoading.setVisible(true);
// recup des users selected in dropBoxClanUsers
List<String> listIdUser = new ArrayList<String>();
int itemCount = dropBoxClanUsers.getItemCount();
for(int i = 0 ; i< itemCount ; i++) {
if (dropBoxClanUsers.isItemSelected(i)) {
listIdUser.add(dropBoxClanUsers.getValue(i));
}
}
errorLabel.setText("");
String textToServer = idClan;
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
/////
dialogBox
.setText("Select a Clan before!!");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML("Click on a clan before find members !" );
dialogBox.center();
closeButton.setFocus(true);
return;
}
// Then, we send the input to the server.
//searchClanButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
wotService.getAllMembersClanAndStats(listIdUser,
new AsyncCallback<AllCommunityAccount>() {
public void onFailure(Throwable caught) {
hPanelLoading.setVisible(false);
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(AllCommunityAccount listAccount) {
hPanelLoading.setVisible(false);
dockPanel.remove(tableStatsCommAcc);
dockPanel. remove(tableClan);
if (dataStatsProvider.getDataDisplays()!= null && !dataStatsProvider.getDataDisplays().isEmpty())
dataStatsProvider.removeDataDisplay(tableStatsCommAcc);
//on re-construit 1 nouveau tableau
tableStatsCommAcc = new CellTable<CommunityAccount> (CommunityAccount.KEY_PROVIDER);
//construct column in celltable tableCommAcc , set data set sort handler etc ..
buildACellTableForStatsCommunityAccount(listAccount.getListCommunityAccount());
//Create a Pager to control the table.
// SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
// pagerStatsCommunityAccount = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
// pagerStatsCommunityAccount.setDisplay(tableStatsCommAcc);
/////////
ScrollPanel sPanel = new ScrollPanel();
//
sPanel.setStyleName("myCellTableStyle");
sPanel.setAlwaysShowScrollBars(true);
sPanel.setHeight("500px");
//sPanel.add(pagerClan);
sPanel.add(tableStatsCommAcc);
tp.add(sPanel, "Stats");
int count = tp.getWidgetCount();
dockPanel.add(tp, DockPanel.SOUTH);
tp.selectTab(count-1);
tableClan.setVisible(true);
//pagerClan.setVisible(true);
tableStatsCommAcc.setFocus(true);
//dialogBox.center();
//closeButton.setFocus(true);
// statsMembersButton.setEnabled(true);
// findHistorizedStatsButton.setEnabled(true);
}
});
//searchClanButton.setEnabled(true);
//searchClanButton.setFocus(true);
}
}
///////////
///////////
// // Create a handler for search clan's members
// class HandlerGetAllStatsFromDossierCache implements ClickHandler, KeyUpHandler {
// /**
// * Fired when the user clicks on the sendButton.
// */
// public void onClick(ClickEvent event) {
// getStats();
//
// }
//
// /**
// * Fired when the user types in the nameField.
// */
// public void onKeyUp(KeyUpEvent event) {
// if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
// getStats();
//
// }
// }
//
// /**
// * Send the name from the nameField to the server and wait for a response.
// */
// private void getStats() {
//
// String filename = fileUpload.getFilename();
// String textToServer = filename;
//
// if (filename.length() == 0) {
// errorLabel.setText("Please enter at least four characters");
//
// /////
// dialogBox
// .setText("Select a file before!!");
// serverResponseLabel
// .addStyleName("serverResponseLabelError");
// serverResponseLabel.setHTML("Click on a file before !" );
// dialogBox.center();
// closeButton.setFocus(true);
// return;
//
// } else {
// Window.alert("file size OK");
//
//// FileReader fileReader = null;
//// try {
//// File fileToUpload = new File(filename);
//// fileReader = new FileReader(fileToUpload);
////
////
//// CharBuffer buffer = CharBuffer.allocate(1000*1000);
//// int bytesRead = -1;
//// while ((bytesRead = fileReader.read(buffer)) != -1) {
//// System.out.println("bytesRead " + bytesRead );
//// }
////
////
//// } catch (FileNotFoundException e) {
//// // TODO Auto-generated catch block
//// e.printStackTrace();
//// } catch (IOException e) {
//// // TODO Auto-generated catch block
//// e.printStackTrace();
//// }
//// finally {
//// try {
//// if (fileReader != null ) fileReader.close();
//// } catch (IOException e) {
//// // TODO Auto-generated catch block
//// e.printStackTrace();
//// }
//// }
//
// //TODO : Display stats of dossier cache
// }
//
// // First, we validate the input.
// hPanelLoading.setVisible(true);
//
// // Sending filename <file *.dat> to server
// // Then, we send the input to the server.
// //searchClanButton.setEnabled(false);
// textToServerLabel.setText(textToServer);
// serverResponseLabel.setText("");
// wotService.getAllStatsFromDossierCache(filename,
// new AsyncCallback<AllCommunityAccount>() {
// public void onFailure(Throwable caught) {
// hPanelLoading.setVisible(false);
// // Show the RPC error message to the user
// dialogBox
// .setText("Remote Procedure Call - Failure");
// serverResponseLabel
// .addStyleName("serverResponseLabelError");
// serverResponseLabel.setHTML(SERVER_ERROR);
// dialogBox.center();
// closeButton.setFocus(true);
//
// }
//
// public void onSuccess(AllCommunityAccount listAccount) {
// hPanelLoading.setVisible(false);
// dockPanel.remove(tableStatsCommAcc);
// dockPanel. remove(tableClan);
//
//
//
// if (dataStatsProvider.getDataDisplays()!= null && !dataStatsProvider.getDataDisplays().isEmpty())
// dataStatsProvider.removeDataDisplay(tableStatsCommAcc);
//
// //on re-construit 1 nouveau tableau
// tableStatsCommAcc = new CellTable<CommunityAccount> (CommunityAccount.KEY_PROVIDER);
//
// //construct column in celltable tableCommAcc , set data set sort handler etc ..
// buildACellTableForStatsCommunityAccount(listAccount.getListCommunityAccount());
//
// //Create a Pager to control the table.
//// SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
//// pagerStatsCommunityAccount = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
//// pagerStatsCommunityAccount.setDisplay(tableStatsCommAcc);
//
//
// /////////
// ScrollPanel sPanel = new ScrollPanel();
// //
// sPanel.setStyleName("myCellTableStyle");
// sPanel.setAlwaysShowScrollBars(true);
// sPanel.setHeight("500px");
// //sPanel.add(pagerClan);
// sPanel.add(tableStatsCommAcc);
// tp.add(sPanel, "Stats");
// int count = tp.getWidgetCount();
// dockPanel.add(tp, DockPanel.SOUTH);
// tp.selectTab(count-1);
//
// tableClan.setVisible(true);
// //pagerClan.setVisible(true);
//
// tableStatsCommAcc.setFocus(true);
// }
// });
// }
// }
// ///////////
// Create a handler for search clan's members
class HandlerGetHistorizedStats implements ClickHandler, KeyUpHandler {
public String stat ;
public HandlerGetHistorizedStats(String stat) {
this.stat = stat;
}
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
getHistorizedStats();
offsetClan = 0;
limitClan = 100;
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
getHistorizedStats();
offsetClan = 0;
limitClan = 100;
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void getHistorizedStats() {
// First, we validate the input.
hPanelLoading.setVisible(true);
// recup des users selected in dropBoxClanUsers
List<String> listIdUser = new ArrayList<String>();
int itemCount = dropBoxClanUsers.getItemCount();
for(int i = 0 ; i< itemCount ; i++) {
if (dropBoxClanUsers.isItemSelected(i)) {
listIdUser.add(dropBoxClanUsers.getValue(i));
}
}
errorLabel.setText("");
String textToServer = idClan;
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
/////
dialogBox
.setText("Select a Clan before!!");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML("Click on a clan before find members !" );
dialogBox.center();
closeButton.setFocus(true);
return;
}
// Then, we send the input to the server.
//searchClanButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
//
wotService.getHistorizedStats( stat, listIdUser,
new AsyncCallback<List<CommunityAccount>>() {
public void onFailure(Throwable caught) {
hPanelLoading.setVisible(false);
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(List<CommunityAccount> listAccount) {
hPanelLoading.setVisible(false);
dockPanel.remove(tableHistorizedStatsCommAcc);
dockPanel.remove(tableClan);
// if (pagerHistorizedStatsCommunityAccount != null)
// dockPanel.remove(pagerHistorizedStatsCommunityAccount);
// if (pagerClan != null)
// dockPanel.remove(pagerClan);
if (dataHistorizedStatsProvider.getDataDisplays()!= null && !dataHistorizedStatsProvider.getDataDisplays().isEmpty())
dataHistorizedStatsProvider.removeDataDisplay(tableHistorizedStatsCommAcc);
//on re-construit 1 nouveau tableau
tableHistorizedStatsCommAcc = new CellTable<CommunityAccount> (CommunityAccount.KEY_PROVIDER);
//construct column in celltable tableCommAcc , set data set sort handler etc ..
buildACellTableForHistorizedStatsCommunityAccount(listAccount);
///////////
ScrollPanel sPanel = new ScrollPanel();
//
sPanel.setStyleName("myCellTableStyle");
sPanel.setAlwaysShowScrollBars(true);
sPanel.setHeight("500px");
sPanel.setWidth("1000px");
//sPanel.add(pagerClan);
LineChartExample lineChartExample = new LineChartExample(stat, listAccount);
lineChartExample.setVisible(true);
sPanel.add(lineChartExample);
tp.add(sPanel, "History " + stat);
int count = tp.getWidgetCount();
dockPanel.add(tp, DockPanel.SOUTH);
tp.selectTab(count-1);
/////////
//add to dock panel ======
//dockPanel.add(pagerHistorizedStatsCommunityAccount, DockPanel.SOUTH);
//pagerHistorizedStatsCommunityAccount.setPage(10);
//pagerHistorizedStatsCommunityAccount.setVisible(true);
//dockPanel.add(tableHistorizedStatsCommAcc, DockPanel.SOUTH);
//dockPanel.add(pagerClan, DockPanel.SOUTH);
//dockPanel.add(tableClan, DockPanel.SOUTH);
//tableHistorizedStatsCommAcc.setVisible(true);
//tableClan.setVisible(true);
//pagerClan.setVisible(true);
//tableHistorizedStatsCommAcc.setFocus(true);
//dialogBox.center();
//closeButton.setFocus(true);
}
public void onSuccessSave(List<CommunityAccount> listAccount) {
hPanelLoading.setVisible(false);
dockPanel.remove(tableHistorizedStatsCommAcc);
dockPanel.remove(tableClan);
// if (pagerHistorizedStatsCommunityAccount != null)
// dockPanel.remove(pagerHistorizedStatsCommunityAccount);
// if (pagerClan != null)
// dockPanel.remove(pagerClan);
if (dataHistorizedStatsProvider.getDataDisplays()!= null && !dataHistorizedStatsProvider.getDataDisplays().isEmpty())
dataHistorizedStatsProvider.removeDataDisplay(tableHistorizedStatsCommAcc);
//on re-construit 1 nouveau tableau
tableHistorizedStatsCommAcc = new CellTable<CommunityAccount> (CommunityAccount.KEY_PROVIDER);
//construct column in celltable tableCommAcc , set data set sort handler etc ..
buildACellTableForHistorizedStatsCommunityAccount(listAccount);
//Create a Pager to control the table.
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
// pagerHistorizedStatsCommunityAccount = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
// pagerHistorizedStatsCommunityAccount.setDisplay(tableHistorizedStatsCommAcc);
//
///////////
ScrollPanel sPanel = new ScrollPanel();
//
sPanel.setStyleName("myCellTableStyle");
sPanel.setAlwaysShowScrollBars(true);
sPanel.setHeight("500px");
//sPanel.add(pagerClan);
sPanel.add(tableHistorizedStatsCommAcc);
tp.add(sPanel, "History batttles");
int count = tp.getWidgetCount();
dockPanel.add(tp, DockPanel.SOUTH);
tp.selectTab(count-1);