Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Regard whitespace Rev 6 → Rev 5

/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBox.java
55,7 → 55,7
protected Vector items = new Vector();
protected boolean popupAdded = false;
protected boolean visible = false;
protected String currentValue = null;
protected int current = -1;
/**
176,9 → 176,9
else {
// Validation de l'entree :
if (autoCompleteAsyncTextBoxListeners!= null) {
autoCompleteAsyncTextBoxListeners.fireTextBoxEnter(this,this.getText(),currentValue);
autoCompleteAsyncTextBoxListeners.fireTextBoxEnter(this,current, this.getText());
}
currentValue=null;
current=-1;
this.setText("");
}
228,13 → 228,13
for(int i = 0; i < items.size(); i++)
{
choices.addItem(((String [])items.get(i))[0],((String [])items.get(i))[1]);
choices.addItem((String) items.get(i));
}
// if there is only one match and it is what is in the
// text field anyways there is no need to show autocompletion
if(items.size() == 1 && (((String []) items.get(0))[0]).compareTo(this.getText()) == 0)
if(items.size() == 1 && ((String) items.get(0)).compareTo(this.getText()) == 0)
{
choicesPopup.hide();
} else {
277,7 → 277,7
if(choices.getItemCount() > 0)
{
this.setText(choices.getItemText(choices.getSelectedIndex()));
currentValue=choices.getValue(choices.getSelectedIndex());
current=choices.getSelectedIndex();
}
 
visible=false;
287,8 → 287,8
}
public void addItem(String item, String value) {
items.add(new String [] {item, value});
public void addItem(String item) {
items.add(item);
}
private void addToCache (String query, Vector result)
/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBoxListenerCollection.java
12,10 → 12,10
* @param sender the widget sending the event
* @param text the text sent
*/
public void fireTextBoxEnter(SourcesAutoCompleteAsyncTextBoxEvents sender, String text, String value) {
public void fireTextBoxEnter(SourcesAutoCompleteAsyncTextBoxEvents sender, int pos, String text) {
for (Iterator it = iterator(); it.hasNext();) {
AutoCompleteAsyncTextBoxListener listener = (AutoCompleteAsyncTextBoxListener) it.next();
listener.onValidate(sender, text, value);
listener.onValidate(sender, pos, text);
}
}
}
/trunk/src/org/tela_botanica/client/CenterPanel.java
9,6 → 9,7
 
import org.tela_botanica.client.TaxonList;
import org.tela_botanica.client.NameAssistant;
import java.util.Vector;
 
/**
* Composite permet de wrapper des Widgett pour creer un nouveau Widget cf methode initWidget()
16,8 → 17,9
 
public class CenterPanel extends Composite {
 
private TaxonList taxonList = new TaxonList();
private NameAssistant nameAssistant = new NameAssistant(taxonList);
private Vector complements=new Vector(); // Complements de saisie associé à nameassistant ... (design a revoir ...).
private TaxonList taxonList = new TaxonList(complements);
private NameAssistant nameAssistant = new NameAssistant(taxonList,complements);
 
 
public CenterPanel() {
/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBoxListener.java
12,5 → 12,5
* @param sender the widget sending the event
* @param text : text selected
*/
void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, String text, String value);
void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,int pos, String text);
}
/trunk/src/org/tela_botanica/client/TaxonList.java
15,6 → 15,7
*/
package org.tela_botanica.client;
 
 
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONNumber;
37,31 → 38,29
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
 
/*
* Le retour de getUser appelle getCount qui appelle update pour veiller à une
* initialisation correcte
*
import java.util.Vector;
 
/* Le retour de getUser appelle getCount qui appelle update pour veiller à une initialisation correcte
 
*/
 
public class TaxonList extends Composite implements
AutoCompleteAsyncTextBoxListener {
public class TaxonList extends Composite implements AutoCompleteAsyncTextBoxListener {
 
 
// Barre de navigation
 
private class NavBar extends Composite implements ClickListener {
 
public final DockPanel bar = new DockPanel();
 
public final Button gotoFirst = new Button("&lt;&lt;", this);
 
public final Button gotoNext = new Button("&gt;", this);
 
public final Button gotoPrev = new Button("&lt;", this);
 
public final Button gotoEnd = new Button("&gt;&gt;", this);
 
public final HTML status = new HTML();
 
 
public NavBar() {
initWidget(bar);
bar.setStyleName("navbar");
76,14 → 75,13
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
bar.add(status, DockPanel.CENTER);
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
bar.setCellHorizontalAlignment(status,
HasHorizontalAlignment.ALIGN_RIGHT);
bar.setCellVerticalAlignment(status,
HasVerticalAlignment.ALIGN_MIDDLE);
bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
bar.setCellWidth(status, "100%");
 
}
 
public void onClick(Widget sender) {
if (sender == gotoNext) {
// Move forward a page.
90,16 → 88,19
startIndex += VISIBLE_TAXON_COUNT;
if (startIndex >= count)
startIndex -= VISIBLE_TAXON_COUNT;
} else {
}
else {
if (sender == gotoPrev) {
// Move back a page.
startIndex -= VISIBLE_TAXON_COUNT;
if (startIndex < 0)
startIndex = 0;
} else {
}
else {
if (sender == gotoEnd) {
gotoEnd();
} else {
}
else {
if (sender == gotoFirst) {
startIndex = 0;
}
115,31 → 116,34
navBar.status.setText(text);
}
 
 
private static final int VISIBLE_TAXON_COUNT = 15;
 
private Grid header = new Grid(1, 6);
 
private FlexTable table = new FlexTable();
 
private VerticalPanel panel = new VerticalPanel();
 
private int startIndex = 0;
 
private String serviceBaseUrl = getServiceBaseUrl();
 
private int count = 65000;
 
private Vector complements=null;
private String element=null;
private String complement=null;
private String user;
 
private NavBar navBar = new NavBar();
 
public TaxonList() {
public TaxonList(Vector comps) {
 
initAsync();
 
// Information complementaire : un tableau associe au retour de
// l'assistant de saisie
// Information complementaire : un tableau associe au retour de l'assistant de saisie
 
complements=comps;
// Mise en forme du header
 
header.setCellSpacing(0);
173,6 → 177,7
 
navBar.setWidth("100%");
 
table.setStyleName("taxon-List");
 
panel.add(navBar);
181,45 → 186,46
 
initWidget(panel);
 
}
 
/**
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
* la recherche d'informations complémentaires (famille, numero
* nomenclaturaux etc) et met a jour l'inventaire (addelement())
*
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance la recherche d'informations
* complémentaires (famille, numero nomenclaturaux etc) et met a jour l'inventaire (addelement())
* @return void
*/
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
final String str,final String value) {
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,int pos, String str) {
 
setStatusDisabled();
 
// Il y a surement une meilleure facon de faire que de passer par une variable de classe
// pour atteindre une inner classe
element=str;
// Saisie assistée
 
if (value !=null) {
if (pos>=0) {
 
// Le vecteur complements contient les informations complémentaires associées à un nom.
 
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + value,
complement=(String) complements.get(pos);
HTTPRequest.asyncGet(serviceBaseUrl+"/NameValid/"+complement,
new ResponseTextHandler() {
 
public void onCompletion(String strcomplete) {
public void onCompletion(String str) {
 
JSONValue jsonValue = JSONParser.parse(strcomplete);
JSONValue jsonValue= JSONParser.parse(str);
JSONArray jsonArray;
 
complements.clear();
if ((jsonArray = jsonValue.isArray()) != null) {
// Nom retenu, Num Nomen nom retenu, Num Taxon,
// Famille
addElement(str, value,
((JSONString) jsonArray.get(0))
.stringValue(),
((JSONString) jsonArray.get(1))
.stringValue(),
((JSONString) jsonArray.get(2))
.stringValue(),
((JSONString) jsonArray.get(3))
.stringValue());
// Nom retenu, Num Nomen nom retenu, Num Taxon, Famille
addElement(element,complement,((JSONString) jsonArray.get(0)).stringValue(),
((JSONString) jsonArray.get(1)).stringValue(),((JSONString) jsonArray.get(2)).stringValue(),
((JSONString) jsonArray.get(3)).stringValue());
}
}
 
227,42 → 233,34
}
// Saisie libre
else {
addElement(str, " ", " ", " ", " ", " ");
complements.clear();
 
addElement(element," "," "," "," "," ");
}
}
 
/**
* Ajoute un element à l'inventaire
*
* @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
* @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
*/
 
public void addElement(String nom_sel, String num_nom_sel, String nom_ret,
String num_nom_ret, String num_taxon, String famille) {
public void addElement(String nom_sel, String num_nom_sel, String nom_ret, String num_nom_ret, String num_taxon, String famille) {
 
// Calcul du nouveau numéro d'ordre
 
/*
* int order=1; if (table.getRowCount()>0) { order=new
* Integer(table.getText(table.getRowCount()-1,6)).intValue()+1; }
*/
/* int order=1;
if (table.getRowCount()>0) {
order=new Integer(table.getText(table.getRowCount()-1,6)).intValue()+1;
}*/
 
count++;
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,
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,
 
new ResponseTextHandler() {
 
278,8 → 276,10
*
*/
 
public void deleteElement() {
 
setStatusDisabled();
boolean checked = false;
 
289,8 → 289,7
checked = true;
String str = table.getText(i, 6);
count--;
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
+ "/" + str, "action=DELETE",
HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/"+user+"/"+str, "action=DELETE",
new ResponseTextHandler() {
 
public void onCompletion(String str) {
308,11 → 307,11
 
/**
*
* Lancement des initialisations dependantes de réponses asynchrones : le
* retour d'une demande d'initialisation declanche la demande
* d'initialisation suivantes user : resultat recherche nom d'utilisateur
* count : resultat nombre d'enregistrements d'inventaires affichage
* enregistrements trouvés
* Lancement des initialisations dependantes de réponses asynchrones : le retour d'une demande d'initialisation declanche
* la demande d'initialisation suivantes
* user : resultat recherche nom d'utilisateur
* count : resultat nombre d'enregistrements d'inventaires
* affichage enregistrements trouvés
*
*/
private void initAsync() {
329,6 → 328,7
*/
private void getUser() {
 
setStatusDisabled();
 
HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
344,6 → 344,8
}
});
 
 
}
 
/**
370,21 → 372,19
}
 
/**
* Mise a jour de l'affichage, à partir des données d'inventaire deja
* saisies. La valeur de this.startIndex permet de determiner quelles
* données seront affichées
* Mise a jour de l'affichage, à partir des données d'inventaire deja saisies.
* La valeur de this.startIndex permet de determiner quelles données seront affichées
*
*/
 
private void update() {
 
 
setStatusDisabled();
 
// TODO : optimisation : ne supprimer que les lignes qui ne seront pas
// alimentes .
// TODO : optimisation : ne supprimer que les lignes qui ne seront pas alimentes .
 
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/"
+ startIndex + "/" + VISIBLE_TAXON_COUNT,
HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/"+startIndex+"/"+VISIBLE_TAXON_COUNT,
 
new ResponseTextHandler() {
 
399,6 → 399,7
table.removeRow(i);
}
 
 
int j = 0;
if ((jsonArray = jsonValue.isArray()) != null) {
for (int i = 0; i < jsonArray.size(); ++i) {
407,35 → 408,26
// Case a cocher
table.setWidget(row, 0, new CheckBox());
// Nom saisi
table.setText(row, 1, ((JSONString) jsonArrayNested
.get(0)).stringValue());
table.setText(row,1,((JSONString) jsonArrayNested.get(0)).stringValue());
// Nom retenu
table.setText(row, 2, ((JSONString) jsonArrayNested
.get(2)).stringValue());
table.setText(row,2,((JSONString) jsonArrayNested.get(2)).stringValue());
// Num nomenclatural
table.setText(row, 3, ((JSONString) jsonArrayNested
.get(1)).stringValue());
table.setText(row,3,((JSONString) jsonArrayNested.get(1)).stringValue());
// Num Taxonomique
table.setText(row, 4, ((JSONString) jsonArrayNested
.get(4)).stringValue());
table.setText(row,4,((JSONString) jsonArrayNested.get(4)).stringValue());
// Famille
table.setText(row, 5, ((JSONString) jsonArrayNested
.get(5)).stringValue());
table.setText(row,5,((JSONString) jsonArrayNested.get(5)).stringValue());
// Numero d'ordre
table.setText(row, 6, ((JSONString) jsonArrayNested
.get(6)).stringValue());
table.setText(row,6,((JSONString) jsonArrayNested.get(6)).stringValue());
 
table.getCellFormatter().setVisible(row, 6, false);
 
table.getFlexCellFormatter().setWidth(row, 0, "2%");
table.getFlexCellFormatter()
.setWidth(row, 1, "31%");
table.getFlexCellFormatter()
.setWidth(row, 2, "31%");
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, "18%");
table.getFlexCellFormatter().setWidth(row,5,"18%");
j++;
}
 
457,11 → 449,12
Dictionary theme = Dictionary.getDictionary("Parameters");
return theme.get("serviceBaseUrl");
 
}
 
/**
* Affichage message d'attente et désactivation navigation
*
* @param
* @return void
*/
476,6 → 469,7
setStatusText("Patientez ...");
}
 
 
/**
* Affichage numero de page et gestion de la navigation
*
487,41 → 481,39
 
if (count > 0) {
 
if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
// premiere page
if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la premiere page
navBar.gotoPrev.setEnabled(true);
navBar.gotoFirst.setEnabled(true);
if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
// derniere
// page
if (startIndex<(count-VISIBLE_TAXON_COUNT)) { // Pas la derniere page
navBar.gotoNext.setEnabled(true);
navBar.gotoEnd.setEnabled(true);
setStatusText((startIndex + 1) + " - "
+ (startIndex + VISIBLE_TAXON_COUNT));
} else { // Derniere page
setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
}
else { // Derniere page
setStatusText((startIndex + 1) + " - " + count);
}
} else { // Premiere page
}
else { // Premiere page
if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
navBar.gotoNext.setEnabled(true);
navBar.gotoEnd.setEnabled(true);
setStatusText((startIndex + 1) + " - "
+ (startIndex + VISIBLE_TAXON_COUNT));
} else {
setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
}
else {
setStatusText((startIndex + 1) + " - " + count);
}
}
}
 
else { // Pas d'inventaire, pas de navigation
setStatusText(0 + " - " + 0);
}
}
 
/**
* Positionnement index de parcours (this.startIndex) pour affichage de la
* dernière page
*
* Positionnement index de parcours (this.startIndex) pour affichage de la dernière page
* @param
* @return void
*/
530,7 → 522,8
 
if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
startIndex = count - (count % VISIBLE_TAXON_COUNT);
} else {
}
else {
startIndex = count - VISIBLE_TAXON_COUNT;
}
 
/trunk/src/org/tela_botanica/client/NameAssistant.java
14,7 → 14,9
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
 
import java.util.Vector;
 
 
import org.tela_botanica.client.AutoCompleteAsyncTextBox;
 
/**
25,9 → 27,11
 
private AutoCompleteAsyncTextBox autoCompletebox = new AutoCompleteAsyncTextBox(this);
private HorizontalPanel panel = new HorizontalPanel();
private Vector complements=null;
public NameAssistant(AutoCompleteAsyncTextBoxListener listener) {
public NameAssistant(AutoCompleteAsyncTextBoxListener listener,Vector comps) {
complements=comps;
autoCompletebox.setSearchUrl(getServiceBaseUrl()+"/NameSearch/");
panel.add(autoCompletebox);
45,16 → 49,20
JSONArray jsonArrayNested;
JSONString jsonString;
 
complements.clear();
if ((jsonArray = jsonValue.isArray()) != null) {
for (int i = 0; i < jsonArray.size(); ++i) {
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
if ((jsonString = (jsonArrayNested.get(0)).isString()) != null) {
autoCompletebox.addItem(((JSONString) jsonArrayNested.get(0)).stringValue(),((JSONString) jsonArrayNested.get(1)).stringValue());
autoCompletebox.addItem(jsonString.stringValue());
}
if ((jsonString = (jsonArrayNested.get(1)).isString()) != null) {
complements.add(i,jsonString.stringValue());
}
}
}
}
 
autoCompletebox.displayList();