dockPanel = new DockPanel();
rootPanel.add(dockPanel, 29, 265);
dockPanel.setSize("1193px", "550px");
// Add a file upload widget
final FileUpload fileUpload = new FileUpload();
fileUpload.ensureDebugId("cwFileUpload");
int posTop = 10;
rootPanel.add(fileUpload, 10 , posTop);
//
Button fileUploadButton = new Button("Download dossier cache");
fileUploadButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String filename = fileUpload.getFilename();
if (filename.length() == 0) {
Window.alert("file size null");
} else {
Window.alert("file size OK");
//TODO : Display stats of dossier cache
}
}
});
posTop = posTop + 35;
rootPanel.add(fileUploadButton, 10, posTop );
fileUploadButton.setSize("80px", "28px");
//button search Clans
//int posLeft = 10;
posTop = posTop + 35;
Button searchClansButton = new Button("Clans");
rootPanel.add(searchClansButton, 10, posTop);
searchClansButton.setSize("80px", "28px");
//bouton plus de clans
// final Button searchClansButtonMore = new Button("100 Clans +");
// rootPanel.add(searchClansButtonMore, 95, posTop);
// searchClansButtonMore.setSize("120px", "28px");
// searchClansButtonMore.setEnabled(false);
//label clan
//lblNewLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
//nom du clan a rechercher
final TextBox nameClan = new TextBox();
rootPanel.add(nameClan, 300, posTop);
nameClan.setText("NOVA SNAIL");
nameClan.setSize("125px", "18px");
nameClan.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
// TODO Auto-generated method stub
offsetClan = 0;
limitClan = 100;
}
});
// Focus the name clan
nameClan.setFocus(true);
//bouton login for admin functions
final Button loginAdminButton = new Button("Admin login");
rootPanel.add(loginAdminButton, 700, posTop);
loginAdminButton.setSize("125px", "28px");
loginAdminButton.setEnabled(true);
//nom du login
final TextBox nameLogin = new TextBox();
rootPanel.add(nameLogin, 850, posTop);
nameLogin.setText("t..");
nameLogin.setSize("125px", "18px");
nameLogin.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
// TODO Auto-generated method stub
passSaving = 0;
nbUsersToTreat = 30;
}
});
final Button persistStatsButton = new Button("Save stats");
rootPanel.add(persistStatsButton, 1000, posTop);
persistStatsButton.setSize("125px", "28px");
persistStatsButton.setEnabled(false);
// Add a handler to set admin login true
loginAdminButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (nameLogin.getText().equalsIgnoreCase("thleconn")){
persistStatsButton.setEnabled(true);
adminLogin = true;
}else {
persistStatsButton.setEnabled(false);
adminLogin = false;
}
}
});
//
//next row button search Clan's users
posTop = posTop + 35;
final Button searchUsersClanButton = new Button("Clan's Users");
rootPanel.add(searchUsersClanButton, 10, posTop);
searchUsersClanButton.setSize("210px", "28px");
searchUsersClanButton.setEnabled(false);
// Add a drop box with the clan's users
//final ListBox dropBoxClanUsers = new ListBox(true);
dropBoxClanUsers.setSize("300px", "150px");
dropBoxClanUsers.ensureDebugId("cwListBox-dropBox");
dropBoxClanUsers.setVisibleItemCount(20);
//dropBoxClanUsers.setMultipleSelect(true);
rootPanel.add(dropBoxClanUsers, 300, posTop);
//next row -- button search stats member's clan
posTop = posTop + 35 ;
//final Button statsMembersButton = new Button("Send");
statsMembersButton.setText("Stats");
rootPanel.add(statsMembersButton, 10, posTop);
statsMembersButton.setSize("210px", "28px");
statsMembersButton.setEnabled(false);
//findHistorizedStatsButton
posTop = posTop + 35 ;
//final Button findHistorizedStatsWN8Button = new Button("Send");
findHistorizedStatsWN8Button.setText("Histo WN8");
rootPanel.add(findHistorizedStatsWN8Button, 10, posTop);
findHistorizedStatsWN8Button.setSize("210px", "28px");
findHistorizedStatsWN8Button.setEnabled(false);
//findHistorizedStatsTanksButton
posTop = posTop + 35 ;
//final Button findHistorizedStatsWRButton = new Button("Send");
findHistorizedStatsWRButton.setText("Histo WR");
rootPanel.add(findHistorizedStatsWRButton, 10, posTop);
findHistorizedStatsWRButton.setSize("210px", "28px");
findHistorizedStatsWRButton.setEnabled(false);
posTop = posTop + 35 ;
//final Button findHistorizedStatsWRButton = new Button("Send");
findHistorizedStatsBattleButton.setText("Histo Battle");
rootPanel.add(findHistorizedStatsBattleButton, 10, posTop);
findHistorizedStatsBattleButton.setSize("210px", "28px");
findHistorizedStatsBattleButton.setEnabled(false);
//next row - button achievement's member
posTop = posTop + 70 ;
// final Button findAchievementsMemberButton = new Button("Send");
// findAchievementsMemberButton.setText("Achievements");
// rootPanel.add(findAchievementsMemberButton, 10, posTop);
// findAchievementsMemberButton.setSize("210px", "28px");
// findAchievementsMemberButton.setEnabled(false);
// Add a drop box with the category of achievement
// final ListBox dropBoxCategoryAchievement = new ListBox(false);
// dropBoxCategoryAchievement.setSize("300px", "28px");
// dropBoxCategoryAchievement.ensureDebugId("cwListBox-dropBox");
// rootPanel.add(dropBoxCategoryAchievement, 300, posTop);
//
// final ListBox dropBoxAchievement = new ListBox(false);
// dropBoxAchievement.setSize("300px", "28px");
// dropBoxAchievement.ensureDebugId("cwListBox-dropBox");
// rootPanel.add(dropBoxAchievement, 650, posTop);
//
//loading .gif
posTop = posTop + 35 ;
Image image = new Image("loading.gif");
hPanelLoading.add(image);
hPanelLoading.setVisible(false);
rootPanel.add(hPanelLoading, 350, posTop);
// Create the popup dialog box in case of error
dialogBox.setText("Remote Procedure Call");
dialogBox.setAnimationEnabled(true);
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.addStyleName("dialogVPanel");
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
dialogVPanel.add(textToServerLabel);
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
dialogVPanel.add(serverResponseLabel);
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
// searchClanButton.setEnabled(true);
// searchClanButton.setFocus(true);
}
});
// Create a handler for the Button search all clans
class HandlerGetClans implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
//si c'est bouton find more on incr�mente offset por trouver les 100 clans suivnats
// if ( ((Button)event.getSource()).getText().equalsIgnoreCase(searchClansButtonMore.getText())) {
// offsetClan = offsetClan + 100;
// limitClan = 100;
// } else {
//bouton find clan offset 0
offsetClan = 0;
limitClan = 100;
//}
//recherche des clans
getClans();
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
// if ( event.getSource() instanceof Button && ((Button)event.getSource()).getText().equalsIgnoreCase(searchClansButtonMore.getText())) {
// offsetClan = offsetClan + 100;
// limitClan = 100;
// } else {
offsetClan = 0;
limitClan = 100;
// }
getClans();
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void getClans() {
hPanelLoading.setVisible(true);
tableStatsCommAcc.setVisible(false);
// First, we validate the input.
errorLabel.setText("");
String textToServer = nameClan.getText();
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.getClans(textToServer , offsetClan,
new AsyncCallback<Clan>() {
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(Clan listClan) {
hPanelLoading.setVisible(false);
try {
//String translatedText =Translate.execute("Bonjour le monde", Languages.FRENCH, Languages.ENGLISH);
//System.out.println("Bonjour le monde : " + translatedText);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String status_code= listClan.getStatus_code();
String status= listClan.getStatus();
// "status": "ok",
// "status_code": "NO_ERROR",
if (status.equalsIgnoreCase("ok")) {
// dockPanel.remove(tableStatsCommAcc);
// dockPanel.remove(tableClan);
// if (pagerStatsCommunityAccount != null)
// dockPanel.remove(pagerStatsCommunityAccount);
// if (pagerClan != null)
// dockPanel.remove(pagerClan);
if (dataClanProvider.getDataDisplays()!= null && !dataClanProvider.getDataDisplays().isEmpty())
dataClanProvider.removeDataDisplay(tableClan);
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");