Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 26 → Rev 27

/trunk/src/org/tela_botanica/client/Mediator.java
12,34 → 12,50
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.TextBox;
 
public class Mediator implements AutoCompleteAsyncTextBoxListener {
private String serviceBaseUrl = getServiceBaseUrlFromDictionnary();
private String user = null;
private InventoryItemList inventoryItemList = null;
private LocationList locationList = null;
private DateList dateList = null;
private StationList stationList = null;
private NameAssistant nameAssistant=null;
private LocationAssistant locationAssistant=null;
private InventoryItem inventoryItem=null;
private EntryPanel entryPanel=null;
private ActionPanel actionPanel=null;
private TopPanel topPanel=null;
private LeftPanel leftPanel=null;
private InfoPopup infoPopup=null;
private String serviceBaseUrl = getServiceBaseUrlFromDictionnary(); // Recherche url de base des services distants
private TextBox date = null;
private TextBox complementLocation = null;
private TextBox comment = null;
// Utilisateur
private TopPanel topPanel=null; // Information de connexion
private String user = null; // Utilisateur connecte ou bien identifiant de session
private boolean connected=false;
 
boolean connected=false;
// Filtres
private LeftPanel leftPanel=null; // Containeur filtre date, lieu, lieu-dit ...
private LocationList locationList = null; // Filtre sur lieu de releve
private DateList dateList = null; // Filtre sur date d'observation
private StationList stationList = null; // Filtre sur station d'observation
// Saisie d'une observation
private EntryPanel entryPanel=null; // Formulaire de saisie observation
private NameAssistant nameAssistant=null; // Assistant de saisie nom scientifique
private LocationAssistant locationAssistant=null; // Assistant de saisie nom de commune
private TextBox date = null; // date observation
private TextBox milieu = null; // milieu observation
private TextBox lieudit = null; // lieu dit observation
private TextBox comment = null; // commentaire observation
private InventoryItem inventoryItem=null; // Une observation saisie
 
 
// Liste des observations
private InventoryItemList inventoryItemList = null; // Liste de releves saisis
private ActionPanel actionPanel=null; // Action sur les observations
// Informations
private InfoPopup infoPopup=null; // Information complementaire sur un taxon (photo, repartition)
 
// Point d'entree (pour fin d'initialisation)
 
private Cel cel = null;
 
46,8 → 62,63
Mediator() {
}
// Methodes Private
/**
* Recuperation du prefixe d'appel des services
* @return prefix appel des service
*/
 
private String getServiceBaseUrlFromDictionnary() {
 
Dictionary theme = Dictionary.getDictionary("Parameters");
return theme.get("serviceBaseUrl");
 
}
 
 
// Appel aux services :
 
/**
* Recherche distante et asynchrone de l'utilisateur connecte, en retour lancement methode initialisation
* de l'appellant Cel. (initAsync)
*
*/
private void getUserFromService() {
 
 
HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
new ResponseTextHandler() {
 
public void onCompletion(String str) {
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
user = ((JSONString) jsonArray.get(0)).stringValue(); // Identifiant utilisateur ou identifiant de session si non connecte
connected = ((JSONBoolean) jsonArray.get(1)).booleanValue(); // Drapeau leve si utilisateur identifie
}
cel.initAsync();
}
});
 
}
 
 
// Methodes Public
// Information sur Etat du systeme
/**
* Recuperation information utilisateur
*
*/
57,11 → 128,12
}
// Actions declanchee par le systeme
/**
* Action initialisation
* Action initialisation premier affichage
*/
public void onInit() {
 
73,10 → 145,12
}
// Actions sur formulaire de saisie
 
/**
* Action lancee par la completion d'un nom dans l'assistant de saisie
* Recherche d'information compl�mentaires ....
* Action lancee par la completion d'un nom dans un assistant de saisie
* Recherche d'information complementaires ....
*
* @return void
*/
90,42 → 164,107
}
/**
* Action suivant la completion d'un nom
*
*/
 
public void onNameCompleted(String value) {
if (infoPopup==null) {
infoPopup = new InfoPopup(this);
}
infoPopup.setImageUrl(value);
}
 
/**
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
* la recherche d'informations compl�mentaires (famille, numero
* Action prealable a l'ajout d'une observation : controle presence champs requis et lancement mise a jour
*
*/
public void onAddInventoryItem() {
// Lazy instantiation
if (inventoryItem==null) {
registerInventoryItem(new InventoryItem());
}
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),"null");
inventoryItemList.addelement();
}
 
/**
* Action prealable a la modification d'une observation : controle presence champs requis et lancement mise a jour
*
*/
 
public void onModifyInventoryItem(String ordre) {
 
// Lazy instantiation
if (inventoryItem==null) {
registerInventoryItem(new InventoryItem());
}
 
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),ordre);
inventoryItemList.updateElement();
 
}
 
public boolean inventoryItemIsValid() {
// TODO : controle date
if (inventoryItem.getName().compareTo("")==0) {
return false;
}
else {
return true;
}
}
 
 
 
/**
* Action lancee par la selection d'un nom dans un assistant de saisie. Lance
* la recherche d'informations complementaires (famille, numero
* nomenclaturaux etc) et met a jour l'inventaire (addelement())
*
* @return void
*/
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
String str, String value) {
if (getEntryPanel().getOrdre()==null) {
if (getEntryPanel().getOrdre()==null) { // Nouvelle observation
onAddInventoryItem();
}
else {
onModifyInventoryItem(getEntryPanel().getOrdre());
onModifyInventoryItem(getEntryPanel().getOrdre()); // Modification d'une observation
getEntryPanel().setOrdre(null);
}
 
}
 
// Action portant sur la liste des observations
/**
* Action suite ajout, modification, suppression element inventaire
* Action suite ajout, modification, suppression d'un element inventaire
*/
public void onInventoryUpdated(String location) {
 
locationList.setLocation(location);
locationList.updateCount();
locationList.setLocation(location); // Mise a jour filtre localite
locationList.updateCount();
 
this.onLocationSelected(location);
this.onLocationSelected(location); // Selection localite
}
136,66 → 275,32
public void onInventoryItemSelected(String ordre) {
entryPanel.setOrdre(ordre);
entryPanel.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne
entryPanel.update();
}
 
/**
* Action sur deselection d'une observation : affichage du detail
* Action sur deselection d'une observation : remise a zero
*/
public void onInventoryItemUnselected(String ordre) {
entryPanel.setOrdre(null);
entryPanel.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne
}
 
 
 
/**
* Action sur recherche : affichage de la liste des taxons correspondants
*/
public void onSearch(String search) {
if (search.trim().compareTo("")==0) {
search="all";
}
inventoryItemList.setSearch(search);
inventoryItemList.updateCount();
}
// Action sur Filtrage
 
 
// Filtre identification
/**
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants
* TODO : gerer asynchronicite ?
*/
public void onLocationSelected(String loc) {
inventoryItemList.setLocation(loc);
inventoryItemList.updateCount();
inventoryItemList.displayFilter();
 
dateList.setLocation(loc);
dateList.updateCount();
stationList.setLocation(loc);
stationList.updateCount();
}
/**
* Action sur login
* Action sur login : initialisation filtres pour cette utilisateur
* @param user
*/
231,99 → 336,90
entryPanel.setUser(user);
locationList.setUser(user);
this.onInit();
}
// Filtre recherche contenu
/**
* Action sur recherche : affichage de la liste des taxons correspondants
*/
public void onSearch(String search) {
if (search.trim().compareTo("")==0) {
search="all";
}
inventoryItemList.setSearch(search);
inventoryItemList.updateCount();
}
 
// Filtre selection lieu
/**
* Action sur selection d'une station : affichage de la liste des taxons correspondants
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants
* TODO : gerer asynchronicite ?
*/
public void onStationSelected(String station) {
 
inventoryItemList.setStation(station);
public void onLocationSelected(String loc) {
inventoryItemList.setLocation(loc);
inventoryItemList.updateCount();
inventoryItemList.displayFilter();
 
// nameAssistant.setValue(null);
 
 
dateList.setLocation(loc);
dateList.updateCount();
stationList.setLocation(loc);
stationList.updateCount();
}
 
 
 
// Filtre station
/**
* Action sur selection d'une date : affichage de la liste des taxons correspondants
* Action sur selection d'une station : affichage de la liste des taxons correspondants
*/
public void onDateSelected(String date) {
public void onStationSelected(String station) {
 
inventoryItemList.setDate(date);
inventoryItemList.setStation(station);
inventoryItemList.updateCount();
inventoryItemList.displayFilter();
 
// nameAssistant.setValue(null);
 
 
}
 
/**
* Action suivant la completion d'un nom
*
*/
// Filtre date d'observation
 
public void onNameCompleted(String value) {
if (infoPopup==null) {
infoPopup = new InfoPopup(this);
}
infoPopup.setImageUrl(value);
}
/**
* Action prealable a l'ajout d'une observation : controle presence champs requis et lancement mise a jour
*
* Action sur selection d'une date : affichage de la liste des taxons correspondants
*/
public void onAddInventoryItem() {
// TODO : singleton ?
registerInventoryItem(new InventoryItem(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),complementLocation.getText(),comment.getText(),"null"));
inventoryItemList.addelement();
public void onDateSelected(String date) {
 
inventoryItemList.setDate(date);
inventoryItemList.updateCount();
}
inventoryItemList.displayFilter();
 
/**
* Action prealable a la modification d'une observation : controle presence champs requis et lancement mise a jour
*
*/
 
public void onModifyInventoryItem(String ordre) {
 
// TODO : singleton ?
registerInventoryItem(new InventoryItem(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),complementLocation.getText(),comment.getText(),ordre));
inventoryItemList.updateElement();
 
}
 
public boolean inventoryItemIsValid() {
// TODO : controle date
if (inventoryItem.getName().compareTo("")==0) {
return false;
}
else {
return true;
}
}
// Declaration, enregistrement
 
/**
* Declaration InventoryItem
* Declaration InventoryItem : une observation
* @param cel
*/
 
334,9 → 430,8
 
 
/**
* Declaration InventoryItemList
* Declaration InventoryItemList : liste d'observation
* @param inventoryItemList
*/
347,7 → 442,7
}
/**
* Declaration LocationList
* Declaration LocationList : filtre lieu observation
* @param locationList
*/
359,7 → 454,7
/**
* Declaration DateList
* Declaration DateList : filtre date observation
* @param locationList
*/
370,7 → 465,7
 
/**
* Declaration InfoPopup
* Declaration InfoPopup : information complementaire taxon en cours
* @param infoPopup
*/
382,7 → 477,7
 
/**
* Declaration StationList
* Declaration StationList : filtre par station
* @param locationList
*/
394,7 → 489,7
/**
* Declaration Cel
* Declaration Cel : point d'entree
* @param cel
*/
 
405,7 → 500,7
 
/**
* Declaration NameAssistant
* Declaration NameAssistant : completion nom scientifique
* @param nameassistant
*/
415,7 → 510,7
}
/**
* Declaration LocationAssistant
* Declaration LocationAssistant : completion commune
* @param locationassistant
*/
424,10 → 519,10
}
 
/**
* Declaration date
* Declaration date : date observation
* @param date
*/
436,28 → 531,55
}
/**
* Declaration lieu dit : lieu dit d'observation
*
* @param milieu
*/
public void registerLieudit(TextBox lieudit) {
this.lieudit=lieudit;
}
 
 
/**
* Declaration complementLocation
* @param complementLocation
* Declaration milieu : milieu d'observation
*
* @param milieu
*/
public void registerComplementLocation(TextBox complementLocation) {
this.complementLocation=complementLocation;
public void registerMilieu(TextBox milieu) {
this.milieu=milieu;
}
 
/**
* Declaration Entry Panel : formulaire de saisie observation
*/
 
public void registerEntryPanel(EntryPanel entryPanel) {
this.entryPanel=entryPanel;
}
 
 
/**
* Declaration Action Panel : actions sur liste des observations
*/
 
public void registerActionPanel(ActionPanel actionPanel) {
this.actionPanel=actionPanel;
}
 
 
/**
* Declaration TopPanel : panneau de connexion
*/
 
public void registerTopPanel(TopPanel topPanel) {
477,7 → 599,8
}
 
/* Panneau gauche
/*
* Declaration LeftPanel Panneau gauche filtre sur liste d'observation
*
*/
487,33 → 610,9
}
// Accesseurs et setteurs
 
/**
* Recherche distante et asynchrone de l'utilisateur connecte, en retour lancement methode initialisation
* de l'appellant Cel. (initAsync)
*
*/
private void getUserFromService() {
 
 
HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
new ResponseTextHandler() {
 
public void onCompletion(String str) {
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
user = ((JSONString) jsonArray.get(0)).stringValue(); // Identifiant utilisateur ou identifiant de session si non connecte
connected = ((JSONBoolean) jsonArray.get(1)).booleanValue(); // Drapeau leve si utilisateur identifie
}
cel.initAsync();
}
});
 
}
/**
* Accesseur Url de base
* @return Url de base
525,21 → 624,8
 
}
 
/**
* Recuperation du prefixe d'appel des services
* @return prefix appel des service
*/
 
private String getServiceBaseUrlFromDictionnary() {
 
Dictionary theme = Dictionary.getDictionary("Parameters");
return theme.get("serviceBaseUrl");
 
}
 
 
/**
* Accesseur Utilisateur
* @return utilisateur connecte ou identifiant de session
*/
548,13 → 634,10
return user;
}
 
 
public void setUser(String user) {
this.user=user;
}
 
 
public InventoryItemList getInventoryItemList() {
return inventoryItemList;