Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 11 → Rev 12

/trunk/src/org/tela_botanica/client/InventoryItemList.java
62,11 → 62,14
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");
97,8 → 100,27
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(
119,14 → 141,64
 
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.
177,22 → 249,9
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) {
 
215,15 → 274,15
header.setCellPadding(2);
header.setWidth("100%");
 
header.setStyleName("taxon-ListHeader");
header.setStyleName("inventoryItem-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.setHTML(0, 1, "Plante observ&eacute;e");
header.setHTML(0, 2, "R&eacute;f&eacute;rence retenue");
header.setHTML(0, 3, "R&eacute;f&eacute;rence<br>Nomenclaturale");
header.setHTML(0, 4, "R&eacute;f&eacute;rence<br>Taxonomique");
header.setText(0, 5, "Famille");
header.setText(0, 6, "Localisation");
header.setText(0, 6, "Commune");
 
header.getCellFormatter().setWidth(0, 0, "2%");
header.getCellFormatter().setWidth(0, 1, "31%");
244,51 → 303,14
 
navBar.setWidth("100%");
 
table.setStyleName("taxon-List");
table.setStyleName("inventoryItem-List");
 
panel.add(navBar);
panel.add(header);
panel.add(table);
 
HorizontalPanel selections = new HorizontalPanel();
selections.setSpacing(3);
 
selections.add(new HTML("S&eacute;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();
//updateCount();
// update()
 
296,7 → 318,12
 
 
}
 
 
/**
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
* la recherche d'informations complémentaires (famille, numero
307,25 → 334,20
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
String str, String value) {
// Le nom de plante est requis
 
mediator.onAddInventoryItem();
if (mediator.getNameAssistant().getText().compareTo("")==0) {
return;
}
 
nameText=(mediator.getNameAssistant()).getText();
nameValue=(mediator.getNameAssistant()).getValue();
}
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();
public void addelement() {
if (mediator.inventoryItemIsValid()) {
final InventoryItem inventoryItem=mediator.getInventoryItem();
setStatusDisabled();
// On met a jour rapidement l'affichage puis on lance la requete ....
341,9 → 363,9
// Recherche complement d'information
if (nameValue !=null) {
if (inventoryItem.getNomenclaturalNumber() !=null) {
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + nameValue,
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
new ResponseTextHandler() {
public void onCompletion(String strcomplete) {
354,7 → 376,7
if ((jsonArray = jsonValue.isArray()) != null) {
// Nom retenu, Num Nomen nom retenu, Num Taxon,
// Famille
addElement(nameText, nameValue,
addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
((JSONString) jsonArray.get(0))
.stringValue(),
((JSONString) jsonArray.get(1))
363,7 → 385,7
.stringValue(),
((JSONString) jsonArray.get(3))
.stringValue(),
locationText,locationValue);
inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
}
}
371,11 → 393,14
}
// Saisie libre
else {
addElement(nameText, " ", " ", " ", " ", " ",locationText,locationValue);
addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
}
}
else {
return;
}
}
 
/**
* Ajoute un element à l'inventaire
394,8 → 419,8
* famille
*/
 
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) {
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) {
 
// Calcul du nouveau numéro d'ordre
 
403,12 → 428,16
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,
+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
+ "&station="+ complementLocation + "&commentaire="+ comment,
 
new ResponseTextHandler() {
 
public void onCompletion(String str) {
location=loc;
if (location.compareTo("")==0) {
location="000null";
}
updateCount();
}
});
425,32 → 454,32
boolean checked = false;
Vector parseChecked = new Vector();
 
// TODO : optimiser
// Lifo ...
for (int i = table.getRowCount() - 1; i >= 0; i--) {
if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
checked = true;
// Numero ordre
parseChecked.add(table.getText(i, 7));
count--;
}
if (table.getWidget(i, 0)!=null) {
if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
checked = true;
// Numero ordre
parseChecked.add(table.getText(i, 7));
count--;
}
}
}
sizeChecked=parseChecked.size();
itemDeleted=0;
StringBuffer ids=new StringBuffer();
for (Iterator it = parseChecked.iterator(); it.hasNext();) {
itemDeleted++;
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
+ "/" + (String) it.next(), "action=DELETE",
ids.append((String)it.next());
if (it.hasNext()) ids.append(",");
}
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
+ "/" + ids.toString(), "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();
}
463,7 → 492,9
 
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);
}
}
470,7 → 501,9
 
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);
}
}
484,8 → 517,13
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,
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate ,
new ResponseTextHandler() {
 
public void onCompletion(String str) {
522,7 → 560,12
 
setStatusDisabled();
 
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/"
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 + "/"+
+ startIndex + "/" + VISIBLE_TAXON_COUNT,
 
new ResponseTextHandler() {
533,6 → 576,7
JSONArray jsonArray;
JSONArray jsonArrayNested;
 
int row=0;
int i=0;
if ((jsonArray = jsonValue.isArray()) != null) {
545,23 → 589,55
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
table.setText(row, 2, ((JSONString) jsonArrayNested
.get(2)).stringValue());
String aname=((JSONString) jsonArrayNested .get(2)).stringValue();
if (aname.compareTo("null")==0) {
table.setText(row, 2, "");
}
else {
table.setText(row, 2, aname);
}
// Num nomenclatural
table.setText(row, 3, ((JSONString) jsonArrayNested
.get(1)).stringValue());
String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
if (ann.compareTo("0")==0) {
table.setText(row, 3, "");
}
else {
table.setText(row, 3, ann);
}
 
// Num Taxonomique
table.setText(row, 4, ((JSONString) jsonArrayNested
.get(4)).stringValue());
String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
if (ant.compareTo("0")==0) {
table.setText(row, 4, "");
}
else {
table.setText(row, 4, ann);
}
 
// Famille
table.setText(row, 5, ((JSONString) jsonArrayNested
.get(5)).stringValue());
String afamily=((JSONString) jsonArrayNested .get(5)).stringValue();
if (afamily.compareTo("null")==0) {
table.setText(row, 5, "");
}
else {
table.setText(row, 5, afamily);
}
 
table.getFlexCellFormatter().setWidth(row, 0, "2%");
569,31 → 645,48
.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")==00) {
if (aloc.compareTo("000null")==0) {
table.setText(row, 6, "Inconnu");
}
else {
table.setText(row, 6, ((JSONString) jsonArrayNested .get(6)).stringValue());
table.setText(row, 6, aloc );
}
 
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
606,6 → 699,8
 
}
}
 
// Suppression fin ancien affichage
if (i<table.getRowCount()-1) {
for (int j = table.getRowCount() - 1; j > i-1; j--) {
706,6 → 801,12
public void setLocation(String location) {
this.location = location;
}
 
 
 
public void setDate(String date) {
this.date = date;
}