15,9 → 15,6 |
*/ |
package org.tela_botanica.client; |
|
import java.util.Iterator; |
import java.util.Vector; |
|
import com.google.gwt.i18n.client.Dictionary; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
40,6 → 37,7 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.Window; |
|
/* |
* Le retour de getUser appelle getCount qui appelle update pour veiller à une |
91,6 → 89,9 |
|
|
|
|
|
|
VerticalPanel actions = new VerticalPanel(); |
|
HorizontalPanel actionButton = new HorizontalPanel(); |
105,25 → 106,24 |
)); |
|
*/ |
|
|
HTML delButton=new HTML("Suppression"); |
delButton.setStyleName("html_button"); |
delButton.addClickListener( |
actionButton.add(new Button("Suppression", |
new ClickListener() { |
public void onClick(Widget sender) { |
deleteElement(); |
} |
} |
); |
actionButton.add(delButton); |
)); |
|
HTML exportButton=new HTML("<a href=\""+serviceBaseUrl+"/InventoryExport/" +user+"\">"+"Tout exporter</a>"); |
actionButton.add(exportButton); |
exportButton.setStyleName("html_button"); |
|
actionButton.setSpacing(5); |
actionButton.add(new Button("Tout exporter", |
new ClickListener() { |
public void onClick(Widget sender) { |
exportAll(); |
} |
} |
)); |
|
|
actions.add(actionButton); |
|
HorizontalPanel selections = new HorizontalPanel(); |
134,15 → 134,11 |
|
selections.add(new HTML("Sélection : ")); |
|
Label allLabel = new Label("Tous"); |
Label separatorLabel = new Label(","); |
Label noneLabel = new Label("Aucun"); |
Label all = new Label("Tous,"); |
Label none = new Label("Aucun"); |
|
allLabel.setStyleName("selection_label"); |
noneLabel.setStyleName("selection_label"); |
|
selections.add(allLabel); |
allLabel.addClickListener( |
selections.add(all); |
all.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
selectAll(); |
150,10 → 146,8 |
} |
); |
|
selections.add(separatorLabel); |
|
selections.add(noneLabel); |
noneLabel.addClickListener( |
selections.add(none); |
none.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
deselectAll(); |
160,8 → 154,7 |
} |
} |
); |
|
|
|
bar.add(actions, DockPanel.WEST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT); |
|
193,7 → 186,7 |
} |
} |
} |
update(true); |
update(); |
} |
|
} |
218,18 → 211,56 |
|
private String user; |
|
private NavBar navBar=null; |
private NavBar navBar = new NavBar(); |
|
int sizeChecked=0; |
int itemDeleted=0; |
|
public TaxonList() { |
|
getUser(); // Appelle le reste des initialisations |
|
initAsync(); |
|
// Information complementaire : un tableau associe au retour de |
// l'assistant de saisie |
|
// Mise en forme du header |
|
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
|
header.setStyleName("taxon-ListHeader"); |
|
header.setText(0, 0, ""); |
header.setText(0, 1, "Nom saisi"); |
header.setText(0, 2, "Nom retenu"); |
header.setHTML(0, 3, "Code<br>Nomenclatural"); |
header.setHTML(0, 4, "Code<br>Taxonomique"); |
header.setText(0, 5, "Famille"); |
|
header.getCellFormatter().setWidth(0, 0, "2%"); |
header.getCellFormatter().setWidth(0, 1, "31%"); |
header.getCellFormatter().setWidth(0, 2, "31%"); |
header.getCellFormatter().setWidth(0, 3, "9%"); |
header.getCellFormatter().setWidth(0, 4, "9%"); |
header.getCellFormatter().setWidth(0, 5, "18%"); |
|
// Mise en forme de la table. |
|
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
|
// Mise en forme barre navigation |
|
navBar.setWidth("100%"); |
|
table.setStyleName("taxon-List"); |
|
panel.add(navBar); |
panel.add(header); |
panel.add(table); |
|
initWidget(panel); |
|
|
} |
|
/** |
244,19 → 275,7 |
|
setStatusDisabled(); |
|
// On met a jour rapidement l'affichage puis on lance la requete .... |
|
int row = table.insertRow(table.getRowCount()); |
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Nom saisi |
table.setText(row, 1, str); |
|
table.getFlexCellFormatter().setWidth(row, 0, "2%"); |
table.getFlexCellFormatter() |
.setWidth(row, 1, "31%"); |
|
// Recherche complement d'information |
// Saisie assistée |
|
if (value !=null) { |
|
290,9 → 309,6 |
else { |
addElement(str, " ", " ", " ", " ", " "); |
} |
|
|
|
} |
|
/** |
331,14 → 347,8 |
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
// (Optimisation) Si on reste sur la meme page : ajout à la fin |
if (((count-2)/VISIBLE_TAXON_COUNT)==(count-1/VISIBLE_TAXON_COUNT)) { |
update(false); |
} |
else { |
gotoEnd(); |
update(true); |
} |
gotoEnd(); |
update(); |
} |
}); |
} |
352,34 → 362,24 |
|
setStatusDisabled(); |
boolean checked = false; |
Vector parseChecked = new Vector(); |
|
// Lifo ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
checked = true; |
parseChecked.add(table.getText(i, 6)); |
String str = table.getText(i, 6); |
count--; |
|
} |
} |
sizeChecked=parseChecked.size(); |
itemDeleted=0; |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
itemDeleted++; |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + (String) it.next(), "action=DELETE", |
|
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + str, "action=DELETE", |
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
// On ne lance la suppression qu'a la fin |
if (itemDeleted==sizeChecked) { |
gotoEnd(); |
update(true); |
} |
gotoEnd(); |
update(); |
} |
}); |
|
} |
} |
if (!checked) { |
setStatusEnabled(); |
417,52 → 417,8 |
*/ |
private void initAsync() { |
|
navBar = new NavBar(); |
|
|
// Information complementaire : un tableau associe au retour de |
// l'assistant de saisie |
|
// Mise en forme du header |
|
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
|
header.setStyleName("taxon-ListHeader"); |
|
header.setText(0, 0, ""); |
header.setText(0, 1, "Nom saisi"); |
header.setText(0, 2, "Nom retenu"); |
header.setHTML(0, 3, "Code<br>Nomenclatural"); |
header.setHTML(0, 4, "Code<br>Taxonomique"); |
header.setText(0, 5, "Famille"); |
|
header.getCellFormatter().setWidth(0, 0, "2%"); |
header.getCellFormatter().setWidth(0, 1, "31%"); |
header.getCellFormatter().setWidth(0, 2, "31%"); |
header.getCellFormatter().setWidth(0, 3, "9%"); |
header.getCellFormatter().setWidth(0, 4, "9%"); |
header.getCellFormatter().setWidth(0, 5, "18%"); |
|
// Mise en forme de la table. |
|
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
|
// Mise en forme barre navigation |
|
navBar.setWidth("100%"); |
|
table.setStyleName("taxon-List"); |
|
panel.add(navBar); |
panel.add(header); |
panel.add(table); |
|
getCount(); |
getUser(); |
// getCount() |
// update() |
|
} |
473,6 → 429,7 |
*/ |
private void getUser() { |
|
setStatusDisabled(); |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/User/", |
new ResponseTextHandler() { |
483,7 → 440,7 |
if ((jsonString = jsonValue.isString()) != null) { |
user = jsonString.stringValue(); |
} |
initAsync(); |
getCount(); |
} |
}); |
|
494,8 → 451,6 |
* |
*/ |
private void getCount() { |
|
setStatusDisabled(); |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/", |
new ResponseTextHandler() { |
507,7 → 462,7 |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
gotoEnd(); // Derniere page |
update(true); |
update(); |
} |
} |
}); |
521,19 → 476,13 |
* |
*/ |
|
private void update(final boolean deep) { |
private void update() { |
|
setStatusDisabled(); |
|
// TODO : optimisation : ne supprimer que les lignes qui ne seront pas |
// alimentes . |
|
// TODO : ne pas recreer la table a chaque fois ... : parcouris le retour, le comparer au present |
// et inserer ou supprimer s'il le faut. |
|
// TODO : ou alors prevoir un update pour les ajouts (forcemment à la fin) et un update pour les suppressions ... |
// Sauf qu'il y a les chgts de pages ... : oui, la un fait un update normal ... |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/" |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
|
546,21 → 495,13 |
JSONArray jsonArrayNested; |
|
// Lifo ... |
if (deep) { |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
table.removeRow(i); |
} |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
table.removeRow(i); |
} |
else { |
table.removeRow(table.getRowCount()); |
} |
|
|
int j = 0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
int arraySize = jsonArray.size(); |
for (int i = 0; i < arraySize; ++i) { |
if (!deep && i != arraySize -1) { |
continue; |
} |
for (int i = 0; i < jsonArray.size(); ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
int row = table.insertRow(table.getRowCount()); |
// Case a cocher |
595,6 → 536,7 |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter() |
.setWidth(row, 5, "18%"); |
j++; |
} |
|
} |
694,5 → 636,17 |
|
} |
|
/* |
* Export du releve affiche dans un format tableur |
* |
* @param |
* @return void |
*/ |
|
private void exportAll() { |
|
Window.open(serviceBaseUrl+"/InventoryExport/" +user + "/","_self",""); |
|
} |
|
} |