62,14 → 62,11 |
public final Button gotoPrev = new Button("<", this); |
|
public final Button gotoEnd = new Button(">>", this); |
|
|
|
public final HTML status = new HTML(); |
|
|
public NavBar() { |
|
|
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
100,27 → 97,8 |
|
VerticalPanel actions = new VerticalPanel(); |
|
|
HorizontalPanel actionButton = new HorizontalPanel(); |
|
HTML addButton = new HTML("Nouvelle observation"); |
addButton.setStyleName("html_button"); |
addButton.addClickListener( |
|
new ClickListener() { |
|
public void onClick(Widget w) { |
openEntryPanel(); |
} |
|
} |
|
|
); |
|
|
actionButton.add(addButton); |
|
HTML delButton=new HTML("Suppression"); |
delButton.setStyleName("html_button"); |
delButton.addClickListener( |
141,64 → 119,14 |
|
actions.add(actionButton); |
|
|
HorizontalPanel selections = new HorizontalPanel(); |
|
selections.setSpacing(3); |
|
|
selections.add(new HTML("Sélection : ")); |
|
Label allLabel = new Label("Tous"); |
Label separatorLabel = new Label(","); |
Label noneLabel = new Label("Aucun"); |
|
allLabel.setStyleName("selection_label"); |
noneLabel.setStyleName("selection_label"); |
|
selections.add(allLabel); |
allLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
selectAll(); |
} |
} |
); |
|
selections.add(separatorLabel); |
|
selections.add(noneLabel); |
noneLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
deselectAll(); |
} |
} |
); |
|
|
actionButton.add(selections); |
|
|
|
|
bar.add(actions, DockPanel.WEST); |
|
|
|
|
|
} |
|
|
private void openEntryPanel() { |
|
mediator.onEntryClick(); |
|
} |
|
|
|
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
249,9 → 177,22 |
private NavBar navBar=null; |
|
private Mediator mediator = null; |
|
// Optimization |
int sizeChecked=0; |
int itemDeleted=0; |
|
|
// Données alimentant la saisie : texte et valeur localité, texte et valeur communes |
|
private String nameText=null; |
private String nameValue=null; |
private String locationText=null; |
private String locationValue=null; |
|
// |
|
private String location = "all"; |
private String date = "all"; |
|
public InventoryItemList(Mediator med) { |
|
274,15 → 215,15 |
header.setCellPadding(2); |
header.setWidth("100%"); |
|
header.setStyleName("inventoryItem-ListHeader"); |
header.setStyleName("taxon-ListHeader"); |
|
header.setText(0, 0, ""); |
header.setHTML(0, 1, "Plante observée"); |
header.setHTML(0, 2, "Référence retenue"); |
header.setHTML(0, 3, "Référence<br>Nomenclaturale"); |
header.setHTML(0, 4, "Référence<br>Taxonomique"); |
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.setText(0, 6, "Commune"); |
header.setText(0, 6, "Localisation"); |
|
header.getCellFormatter().setWidth(0, 0, "2%"); |
header.getCellFormatter().setWidth(0, 1, "31%"); |
303,14 → 244,51 |
|
navBar.setWidth("100%"); |
|
table.setStyleName("inventoryItem-List"); |
table.setStyleName("taxon-List"); |
|
panel.add(navBar); |
panel.add(header); |
panel.add(table); |
|
|
//updateCount(); |
HorizontalPanel selections = new HorizontalPanel(); |
|
selections.setSpacing(3); |
|
|
selections.add(new HTML("Sélection : ")); |
|
Label allLabel = new Label("Tous"); |
Label separatorLabel = new Label(","); |
Label noneLabel = new Label("Aucun"); |
|
allLabel.setStyleName("selection_label"); |
noneLabel.setStyleName("selection_label"); |
|
selections.add(allLabel); |
allLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
selectAll(); |
} |
} |
); |
|
selections.add(separatorLabel); |
|
selections.add(noneLabel); |
noneLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
deselectAll(); |
} |
} |
); |
|
|
panel.add(selections); |
|
|
updateCount(); |
// update() |
|
|
318,12 → 296,7 |
|
|
} |
|
|
|
|
|
|
/** |
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance |
* la recherche d'informations complémentaires (famille, numero |
334,20 → 307,25 |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, |
String str, String value) { |
|
// Le nom de plante est requis |
|
if (mediator.getNameAssistant().getText().compareTo("")==0) { |
return; |
} |
|
mediator.onAddInventoryItem(); |
|
} |
nameText=(mediator.getNameAssistant()).getText(); |
nameValue=(mediator.getNameAssistant()).getValue(); |
|
|
public void addelement() { |
|
|
if (mediator.inventoryItemIsValid()) { |
|
final InventoryItem inventoryItem=mediator.getInventoryItem(); |
|
setStatusDisabled(); |
locationText=(mediator.getLocationAssistant()).getText(); |
locationValue=(mediator.getLocationAssistant()).getValue(); |
|
// Suppresion indication departementale (on pourrait faire mieux !!) |
int pos=locationText.indexOf(" (" ); |
if (pos>=0) { |
locationText=locationText.substring(0,pos); |
} |
|
setStatusDisabled(); |
|
// On met a jour rapidement l'affichage puis on lance la requete .... |
|
363,9 → 341,9 |
|
// Recherche complement d'information |
|
if (inventoryItem.getNomenclaturalNumber() !=null) { |
if (nameValue !=null) { |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(), |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + nameValue, |
new ResponseTextHandler() { |
|
public void onCompletion(String strcomplete) { |
376,7 → 354,7 |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, |
// Famille |
addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(), |
addElement(nameText, nameValue, |
((JSONString) jsonArray.get(0)) |
.stringValue(), |
((JSONString) jsonArray.get(1)) |
385,7 → 363,7 |
.stringValue(), |
((JSONString) jsonArray.get(3)) |
.stringValue(), |
inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment()); |
locationText,locationValue); |
} |
} |
|
393,14 → 371,11 |
} |
// Saisie libre |
else { |
addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment()); |
addElement(nameText, " ", " ", " ", " ", " ",locationText,locationValue); |
} |
|
} |
else { |
return; |
|
} |
} |
|
/** |
* Ajoute un element à l'inventaire |
419,8 → 394,8 |
* famille |
*/ |
|
private void addElement(String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) { |
public void addElement(String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location) { |
|
// Calcul du nouveau numéro d'ordre |
|
428,16 → 403,12 |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant=" |
+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ complementLocation + "&commentaire="+ comment, |
+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location, |
|
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
location=loc; |
if (location.compareTo("")==0) { |
location="000null"; |
} |
updateCount(); |
} |
}); |
454,32 → 425,32 |
boolean checked = false; |
Vector parseChecked = new Vector(); |
|
// TODO : optimiser |
// Lifo ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
checked = true; |
// Numero ordre |
parseChecked.add(table.getText(i, 7)); |
count--; |
} |
} |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
checked = true; |
// Numero ordre |
parseChecked.add(table.getText(i, 7)); |
count--; |
} |
} |
StringBuffer ids=new StringBuffer(); |
sizeChecked=parseChecked.size(); |
itemDeleted=0; |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + ids.toString(), "action=DELETE", |
itemDeleted++; |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + (String) it.next(), "action=DELETE", |
|
new ResponseTextHandler() { |
public void onCompletion(String str) { |
// Optimisation : on ne lance la suppression qu'a la fin |
if (itemDeleted==sizeChecked) { |
updateCount(); |
} |
} |
}); |
|
} |
if (!checked) { |
setStatusEnabled(); |
} |
492,9 → 463,7 |
|
public void selectAll() { |
|
// TODO : optimiser ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) |
((CheckBox) table.getWidget(i, 0)).setChecked(true); |
} |
} |
501,9 → 470,7 |
|
public void deselectAll() { |
|
// TODO : optimiser ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) |
((CheckBox) table.getWidget(i, 0)).setChecked(false); |
} |
} |
517,13 → 484,8 |
public void updateCount() { |
|
setStatusDisabled(); |
|
String adate="all"; |
if (date.compareTo("all")!=0) { |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00"; |
} |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate , |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location, |
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
560,12 → 522,7 |
|
setStatusDisabled(); |
|
String adate="all"; |
if (date.compareTo("all")!=0) { |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00"; |
} |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/"+ |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
|
new ResponseTextHandler() { |
576,7 → 533,6 |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
|
|
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
589,55 → 545,23 |
else { |
row = i; |
} |
|
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Nom saisi |
|
table.setText(row, 1, ((JSONString) jsonArrayNested |
.get(0)).stringValue()); |
|
// Nom retenu |
String aname=((JSONString) jsonArrayNested .get(2)).stringValue(); |
|
if (aname.compareTo("null")==0) { |
table.setText(row, 2, ""); |
} |
else { |
table.setText(row, 2, aname); |
} |
|
table.setText(row, 2, ((JSONString) jsonArrayNested |
.get(2)).stringValue()); |
// Num nomenclatural |
String ann=((JSONString) jsonArrayNested .get(3)).stringValue(); |
|
if (ann.compareTo("0")==0) { |
table.setText(row, 3, ""); |
} |
else { |
table.setText(row, 3, ann); |
} |
|
|
table.setText(row, 3, ((JSONString) jsonArrayNested |
.get(1)).stringValue()); |
// Num Taxonomique |
|
String ant=((JSONString) jsonArrayNested .get(4)).stringValue(); |
|
if (ant.compareTo("0")==0) { |
table.setText(row, 4, ""); |
} |
else { |
table.setText(row, 4, ann); |
} |
|
table.setText(row, 4, ((JSONString) jsonArrayNested |
.get(4)).stringValue()); |
// Famille |
String afamily=((JSONString) jsonArrayNested .get(5)).stringValue(); |
|
if (afamily.compareTo("null")==0) { |
table.setText(row, 5, ""); |
} |
else { |
table.setText(row, 5, afamily); |
} |
table.setText(row, 5, ((JSONString) jsonArrayNested |
.get(5)).stringValue()); |
|
|
table.getFlexCellFormatter().setWidth(row, 0, "2%"); |
645,48 → 569,31 |
.setWidth(row, 1, "31%"); |
table.getFlexCellFormatter() |
.setWidth(row, 2, "31%"); |
|
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter().setWidth(row, 5, "9%"); |
|
// TODO : Bool ici non ? |
|
// Affichage contenu commune si tout demandé. |
|
String aloc=((JSONString) jsonArrayNested .get(6)).stringValue(); |
|
if (location.compareTo("all")==0) { |
|
// Localisation - Lieu |
String aloc=((JSONString) jsonArrayNested .get(6)).stringValue(); |
|
if (aloc.compareTo("000null")==0) { |
if (aloc.compareTo("000null")==00) { |
table.setText(row, 6, "Inconnu"); |
} |
else { |
table.setText(row, 6, aloc ); |
table.setText(row, 6, ((JSONString) jsonArrayNested .get(6)).stringValue()); |
} |
|
|
header.getCellFormatter().setVisible(0, 6,true); |
|
table.getFlexCellFormatter().setWidth(row, 1, "31%"); |
table.getFlexCellFormatter().setWidth(row, 2, "31%"); |
|
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter().setWidth(row, 5, "9%"); |
table.getFlexCellFormatter().setWidth(row, 6, "9%"); |
|
} |
else { |
header.getCellFormatter().setVisible(0, 6,false); |
table.getCellFormatter().setVisible(row, 6,false); |
|
table.getFlexCellFormatter().setWidth(row, 1, "36%"); |
table.getFlexCellFormatter().setWidth(row, 2, "36%"); |
|
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter().setWidth(row, 5, "8%"); |
|
} |
table.getFlexCellFormatter().setWidth(row, 6, "9%"); |
|
// Numero d'ordre (caché) |
table.setText(row, 7, ((JSONString) jsonArrayNested |
699,8 → 606,6 |
|
} |
} |
|
|
// Suppression fin ancien affichage |
if (i<table.getRowCount()-1) { |
for (int j = table.getRowCount() - 1; j > i-1; j--) { |
801,12 → 706,6 |
public void setLocation(String location) { |
this.location = location; |
} |
|
|
|
public void setDate(String date) { |
this.date = date; |
} |
|
|
|