Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 12 → Rev 13

/trunk/src/org/tela_botanica/client/InventoryItemList.java
30,6 → 30,8
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.Button;
38,7 → 40,6
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
 
/*
* Le retour de getUser appelle updateCount qui appelle update pour veiller à une
97,108 → 98,10
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
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(
new ClickListener() {
public void onClick(Widget sender) {
mediator.getInventoryItemList().deleteElement();
}
}
);
actionButton.add(delButton);
HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>");
actionButton.add(exportButton);
exportButton.setStyleName("html_button");
 
actionButton.setSpacing(5);
 
actions.add(actionButton);
 
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();
}
}
);
 
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.
232,7 → 135,7
 
private static final int VISIBLE_TAXON_COUNT = 15;
 
private Grid header = new Grid(1, 7);
private Grid header = new Grid(1, 3);
 
private FlexTable table = new FlexTable();
 
250,8 → 153,13
private Mediator mediator = null;
 
private int selectedRow = -1;
private String location = "all";
private String date = "all";
private String search = "all";
 
private boolean add=false;
public InventoryItemList(Mediator med) {
 
276,22 → 184,8
 
header.setStyleName("inventoryItem-ListHeader");
 
header.setText(0, 0, "");
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, "Commune");
header.setWidget(0, 2, navBar);
 
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, "9%");
header.getCellFormatter().setWidth(0, 6, "9%");
 
// Mise en forme de la table.
 
table.setCellSpacing(0);
298,6 → 192,7
table.setBorderWidth(0);
table.setCellPadding(2);
table.setWidth("100%");
 
// Mise en forme barre navigation
 
305,11 → 200,26
 
table.setStyleName("inventoryItem-List");
 
panel.add(navBar);
//panel.add(navBar);
panel.add(header);
panel.add(table);
 
// Hook up events.
table.addTableListener(new TableListener () {
public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
if (table.getWidget(row, 0)!=null) {
selectRow(row);
// Numero d'ordre
mediator.onInventoryItemSelected(table.getText(row, 4));
}
}
 
});
//updateCount();
// update()
 
320,8 → 230,29
}
private void selectRow(int row) {
styleRow(selectedRow, false);
styleRow(row, true);
 
selectedRow = row;
}
private void styleRow(int row, boolean selected) {
if (row != -1) {
if (selected)
table.getRowFormatter().addStyleName(row, "inventoryItem-SelectedRow");
else
if (row < table.getRowCount()) {
table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
}
}
}
 
 
 
/**
339,7 → 270,63
}
 
// Action sur modification d'un element
public void updateElement() {
if (mediator.inventoryItemIsValid()) {
final InventoryItem inventoryItem=mediator.getInventoryItem();
setStatusDisabled();
if (inventoryItem.getNomenclaturalNumber() !=null) {
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
new ResponseTextHandler() {
public void onCompletion(String strcomplete) {
JSONValue jsonValue = JSONParser.parse(strcomplete);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
// Nom retenu, Num Nomen nom retenu, Num Taxon,
// Famille
updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
((JSONString) jsonArray.get(0))
.stringValue(),
((JSONString) jsonArray.get(1))
.stringValue(),
((JSONString) jsonArray.get(2))
.stringValue(),
((JSONString) jsonArray.get(3))
.stringValue(),
inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
}
}
});
}
// Saisie libre
else {
updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
}
}
else {
return;
}
}
 
// Action sur ajout d'un element
public void addelement() {
422,7 → 409,6
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
 
count++;
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
438,12 → 424,53
if (location.compareTo("")==0) {
location="000null";
}
add=true;
updateCount();
}
});
}
 
 
/**
* Modifie un element de l'inventaire
*
* @param ordre : numero d'ordre
* @param nom_sel :
* nom selectionne
* @param num_nom_sel :
* numero nomenclatural nom selectionne
* @param nom_ret :
* nom retenu
* @param num_nom_ret :
* numero nomenclaturel nom retenu
* @param num_taxon :
* numero taxonomique
* @param famille :
* famille
*/
 
private void updateElement(String ordre, 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) {
 
 
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" +ordre + "/", "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,
 
new ResponseTextHandler() {
 
public void onCompletion(String str) {
add=false;
update();
}
});
}
 
/**
* Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
*
*/
461,7 → 488,7
if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
checked = true;
// Numero ordre
parseChecked.add(table.getText(i, 7));
parseChecked.add(table.getText(i, 4));
count--;
}
}
514,7 → 541,7
* Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
*
*/
public void updateCount() {
public void updateCount () {
setStatusDisabled();
523,7 → 550,7
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 + "/" + adate + "/" + search,
new ResponseTextHandler() {
 
public void onCompletion(String str) {
547,6 → 574,11
});
 
}
private String subLeft(String text, int length) {
return (text.length() < length) ? text : text.substring(0, length)+ " ...";
}
 
/**
* Mise a jour de l'affichage, à partir des données d'inventaire deja
558,6 → 590,8
 
public void update() {
 
// table.setBorderWidth(1);
setStatusDisabled();
 
String adate="all";
564,8 → 598,39
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 + "/"+
String com;
if (location.compareTo("all")==0) {
com="Toutes communes";
}
else {
if (location.compareTo("000null")==0) {
com="Communes non pr&eacute;cis&eacute;es";
}
else {
com="Commune de "+location;
}
}
 
String dat;
if (date.compareTo("all")==0) {
dat=", toute p&eacute;riode";
}
else {
if (date.compareTo("00/00/0000")==0) {
dat=", p&eacute;riode non pr&eacute;cis&eacute;";
}
else {
dat=", le "+ date;
}
}
header.setHTML(0, 0, com + dat );
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" +
+ startIndex + "/" + VISIBLE_TAXON_COUNT,
 
new ResponseTextHandler() {
575,6 → 640,10
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
JSONArray jsonArrayNested;
StringBuffer left=new StringBuffer();
StringBuffer center=new StringBuffer();
StringBuffer right=new StringBuffer();
 
int row=0;
590,31 → 659,33
row = i;
}
 
left=new StringBuffer();
center=new StringBuffer();
right=new StringBuffer();
// Case a cocher
table.setWidget(row, 0, new CheckBox());
// Nom saisi
 
left.append("<b>"+((JSONString) jsonArrayNested .get(0)).stringValue()+"</b>");
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);
center.append(aname+", ");
}
// Num nomenclatural
String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
if (ann.compareTo("0")==0) {
table.setText(row, 3, "");
if (ann.compareTo("0")!=0) {
center.append(""+ann+"-");
}
else {
table.setText(row, 3, ann);
center.append("0-");
}
 
622,11 → 693,11
String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
if (ant.compareTo("0")==0) {
table.setText(row, 4, "");
if (ant.compareTo("0")!=0) {
center.append(ant+", ");
}
else {
table.setText(row, 4, ann);
center.append("0, ");
}
 
// Famille
633,67 → 704,103
String afamily=((JSONString) jsonArrayNested .get(5)).stringValue();
if (afamily.compareTo("null")==0) {
table.setText(row, 5, "");
//
}
else {
table.setText(row, 5, afamily);
center.append(afamily+", ");
}
 
table.getFlexCellFormatter().setWidth(row, 0, "2%");
table.getFlexCellFormatter()
.setWidth(row, 1, "31%");
table.getFlexCellFormatter()
.setWidth(row, 2, "31%");
String aloc=((JSONString) jsonArrayNested .get(6)).stringValue();
// Localisation - Lieu
if (aloc.compareTo("000null")==0) {
if (center.length()==0) {
center.append("Commune absente");
}
else {
center.append("commune absente");
}
}
else {
if (center.length()==0) {
center.append("Commune de "+aloc);
}
else {
center.append("commune de "+aloc);
}
}
// TODO : Bool ici non ?
String alieudit=((JSONString) jsonArrayNested .get(9)).stringValue();
// Affichage contenu commune si tout demandé.
// Localisation - Lieu dit
if (alieudit.compareTo("null")!=0) {
center.append(", "+alieudit);
}
String aloc=((JSONString) jsonArrayNested .get(6)).stringValue();
String acomment=((JSONString) jsonArrayNested .get(10)).stringValue();
// Commentaire
if (acomment.compareTo("null")!=0) {
center.append(", "+acomment);
}
if (location.compareTo("all")==0) {
 
// Localisation - Lieu
if (aloc.compareTo("000null")==0) {
table.setText(row, 6, "Inconnu");
String adate=((JSONString) jsonArrayNested .get(8)).stringValue();
// Date
if (adate.compareTo("0000-00-00 00:00:00")!=0) {
right.append("<b>"+adate+"</b>");
}
else {
table.setText(row, 6, aloc );
// right.append("<b>00/00/0000</b>");
}
 
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.setHTML(row, 1, subLeft("&nbsp;"+left,40));
table.setHTML(row, 2, subLeft("&nbsp;"+center,120));
table.setHTML(row, 3, subLeft("&nbsp;"+right,25));
table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
table.getCellFormatter().setWordWrap(row,1,false);
table.getCellFormatter().setWidth(row,1,"10%");
table.getCellFormatter().setWordWrap(row,2,false);
table.getCellFormatter().setWordWrap(row,3,false);
table.getCellFormatter().setWidth(row,3,"7%");
String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
// Numero d'ordre (caché)
table.setText(row, 7, ((JSONString) jsonArrayNested
.get(7)).stringValue());
table.setText(row, 4, aordre);
 
table.getCellFormatter().setVisible(row, 7, false);
if (add){
if (i ==(arraySize -1)) {
selectRow(row);
mediator.getEntryPanel().setOrdre(aordre);
}
}
else {
if ((mediator.getEntryPanel().getOrdre()!=null) && (mediator.getEntryPanel().getOrdre().compareTo(aordre)==0)) {
selectRow(row);
}
}
 
table.getCellFormatter().setVisible(row, 4, false);
 
}
 
702,16 → 809,24
 
// Suppression fin ancien affichage
if (i<table.getRowCount()-1) {
for (int j = table.getRowCount() - 1; j > i-1; j--) {
table.removeRow(j);
}
for (int j=i;j<VISIBLE_TAXON_COUNT;j++) {
table.setHTML(j,0,"&nbsp;");
table.setHTML(j,1,"&nbsp;");
table.setHTML(j,2,"&nbsp;");
table.setHTML(j,3,"&nbsp;");
table.setHTML(j,4,"&nbsp;");
table.getCellFormatter().setVisible(j, 4, false);
table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow");
}
add=false;
 
setStatusEnabled();
}
});
 
}
 
794,6 → 909,17
}
 
/*
* Recherche en cours
*
*/
public void setSearch(String search) {
this.search = search;
}
 
 
/*
* Localite en cours
*
*/