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; |
|
|
47,7 → 63,62 |
|
} |
|
|
// 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,112 → 164,143 |
} |
|
|
|
/** |
* 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 suivant la completion d'un nom |
* |
* @return void |
*/ |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, |
String str, String value) { |
|
if (getEntryPanel().getOrdre()==null) { |
onAddInventoryItem(); |
public void onNameCompleted(String value) { |
if (infoPopup==null) { |
infoPopup = new InfoPopup(this); |
} |
else { |
onModifyInventoryItem(getEntryPanel().getOrdre()); |
getEntryPanel().setOrdre(null); |
infoPopup.setImageUrl(value); |
} |
|
|
|
/** |
* 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 suite ajout, modification, suppression element inventaire |
* Action prealable a la modification d'une observation : controle presence champs requis et lancement mise a jour |
* |
*/ |
|
public void onModifyInventoryItem(String ordre) { |
|
public void onInventoryUpdated(String location) { |
// 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(); |
|
locationList.setLocation(location); |
locationList.updateCount(); |
} |
|
this.onLocationSelected(location); |
|
public boolean inventoryItemIsValid() { |
// TODO : controle date |
|
if (inventoryItem.getName().compareTo("")==0) { |
return false; |
} |
else { |
return true; |
} |
|
} |
|
|
|
/** |
* Action sur selection d'une observation : affichage du detail |
* 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 onInventoryItemSelected(String ordre) { |
|
entryPanel.setOrdre(ordre); |
entryPanel.update(); |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, |
String str, String value) { |
|
if (getEntryPanel().getOrdre()==null) { // Nouvelle observation |
onAddInventoryItem(); |
} |
else { |
onModifyInventoryItem(getEntryPanel().getOrdre()); // Modification d'une observation |
getEntryPanel().setOrdre(null); |
} |
|
} |
|
|
// Action portant sur la liste des observations |
|
/** |
* Action sur deselection d'une observation : affichage du detail |
* Action suite ajout, modification, suppression d'un element inventaire |
*/ |
|
public void onInventoryItemUnselected(String ordre) { |
|
entryPanel.setOrdre(null); |
public void onInventoryUpdated(String location) { |
|
} |
locationList.setLocation(location); // Mise a jour filtre localite |
locationList.updateCount(); |
|
this.onLocationSelected(location); // Selection localite |
|
} |
|
|
/** |
* Action sur recherche : affichage de la liste des taxons correspondants |
* Action sur selection d'une observation : affichage du detail |
*/ |
|
public void onSearch(String search) { |
public void onInventoryItemSelected(String ordre) { |
|
if (search.trim().compareTo("")==0) { |
search="all"; |
} |
inventoryItemList.setSearch(search); |
inventoryItemList.updateCount(); |
entryPanel.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne |
entryPanel.update(); |
|
} |
|
|
|
/** |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
* TODO : gerer asynchronicite ? |
* Action sur deselection d'une observation : remise a zero |
*/ |
|
public void onLocationSelected(String loc) { |
public void onInventoryItemUnselected(String ordre) { |
|
inventoryItemList.setLocation(loc); |
inventoryItemList.updateCount(); |
entryPanel.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne |
|
inventoryItemList.displayFilter(); |
} |
|
dateList.setLocation(loc); |
dateList.updateCount(); |
|
stationList.setLocation(loc); |
stationList.updateCount(); |
|
} |
// Action sur Filtrage |
|
|
// Filtre identification |
|
|
/** |
* 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 selection d'une station : affichage de la liste des taxons correspondants |
* Action sur recherche : affichage de la liste des taxons correspondants |
*/ |
|
public void onStationSelected(String station) { |
public void onSearch(String search) { |
|
inventoryItemList.setStation(station); |
if (search.trim().compareTo("")==0) { |
search="all"; |
} |
inventoryItemList.setSearch(search); |
inventoryItemList.updateCount(); |
|
inventoryItemList.displayFilter(); |
|
// nameAssistant.setValue(null); |
|
|
} |
|
|
|
// Filtre selection lieu |
|
/** |
* Action sur selection d'une date : 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 onDateSelected(String date) { |
public void onLocationSelected(String loc) { |
|
inventoryItemList.setDate(date); |
inventoryItemList.setLocation(loc); |
inventoryItemList.updateCount(); |
|
inventoryItemList.displayFilter(); |
|
// nameAssistant.setValue(null); |
dateList.setLocation(loc); |
dateList.updateCount(); |
|
stationList.setLocation(loc); |
stationList.updateCount(); |
|
} |
|
|
// Filtre station |
|
/** |
* Action suivant la completion d'un nom |
* |
* Action sur selection d'une station : affichage de la liste des taxons correspondants |
*/ |
|
public void onNameCompleted(String value) { |
if (infoPopup==null) { |
infoPopup = new InfoPopup(this); |
} |
infoPopup.setImageUrl(value); |
} |
public void onStationSelected(String station) { |
|
inventoryItemList.setStation(station); |
inventoryItemList.updateCount(); |
|
/** |
* Action prealable a l'ajout d'une observation : controle presence champs requis et lancement mise a jour |
* |
*/ |
inventoryItemList.displayFilter(); |
|
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(); |
|
} |
|
// Filtre date d'observation |
|
|
/** |
* Action prealable a la modification 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 onModifyInventoryItem(String ordre) { |
public void onDateSelected(String date) { |
|
// TODO : singleton ? |
registerInventoryItem(new InventoryItem(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),complementLocation.getText(),comment.getText(),ordre)); |
inventoryItemList.updateElement(); |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
|
} |
inventoryItemList.displayFilter(); |
|
|
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 |
*/ |
|
427,7 → 522,7 |
|
|
/** |
* Declaration date |
* Declaration date : date observation |
* @param date |
*/ |
|
439,27 → 534,54 |
|
|
/** |
* Declaration complementLocation |
* @param complementLocation |
* Declaration lieu dit : lieu dit d'observation |
* |
* @param milieu |
*/ |
|
public void registerComplementLocation(TextBox complementLocation) { |
this.complementLocation=complementLocation; |
public void registerLieudit(TextBox lieudit) { |
this.lieudit=lieudit; |
|
} |
|
|
|
/** |
* Declaration milieu : milieu d'observation |
* |
* @param milieu |
*/ |
|
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) { |
this.topPanel=topPanel; |
} |
477,7 → 599,8 |
} |
|
|
/* Panneau gauche |
/* |
* Declaration LeftPanel Panneau gauche filtre sur liste d'observation |
* |
*/ |
|
487,34 → 610,10 |
} |
|
|
// 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 |
*/ |
527,19 → 626,6 |
|
|
/** |
* 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,14 → 634,11 |
return user; |
} |
|
|
|
public void setUser(String user) { |
this.user=user; |
} |
|
|
|
public InventoryItemList getInventoryItemList() { |
return inventoryItemList; |
} |