Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 27 → Rev 28

/trunk/src/org/tela_botanica/client/Mediator.java
2,8 → 2,20
 
 
// TODO : sortie User vers une classe ...
// TODO : sortie les boutons supprimer et exporter et inclure ici
// TODO : sortie les boutons supprimer et exporter et inclure ici : vraiment ?
 
// TODO : optimisation, ne pas rechercher stations ou date si non affichés
 
 
 
 
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.widget.Viewport;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayout;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
import net.mygwt.ui.client.widget.layout.FillLayout;
 
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONBoolean;
16,23 → 28,32
 
public class Mediator implements AutoCompleteAsyncTextBoxListener {
// General
private WidgetContainer west = null;
private WidgetContainer south = null;
private WidgetContainer center = null;
private WidgetContainer north = null;
private String serviceBaseUrl = getServiceBaseUrlFromDictionnary(); // Recherche url de base des services distants
// Utilisateur
private TopPanel topPanel=null; // Information de connexion
private String user = null; // Utilisateur connecte ou bien identifiant de session
private boolean connected=false;
private ConnexionView connexionView=null; // Information de connexion
private String user = null; // Identifiant utilisateur connecte ou bien identifiant de session en cours
private boolean connected=false; // Positionne a vrai si identification reussie
 
// 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
// Filtres sur les releves
private InventoryFilterView inventoryFilterView=null; // Containeur filtre date, lieu, lieu-dit ...
private LocationFilterPanel locationFilterPanel = null; // Filtre sur lieu de releve
private DateFilterPanel dateFilterPanel = null; // Filtre sur date d'observation
private StationFilterPanel stationFilterPanel = null; // Filtre sur station d'observation
 
// Saisie d'une observation
private EntryPanel entryPanel=null; // Formulaire de saisie observation
private EntryView entryView=null; // Formulaire de saisie observation
private NameAssistant nameAssistant=null; // Assistant de saisie nom scientifique
private LocationAssistant locationAssistant=null; // Assistant de saisie nom de commune
43,29 → 64,107
private TextBox comment = null; // commentaire observation
private InventoryItem inventoryItem=null; // Une observation saisie
 
// Liste de releves saisis
private InventoryListView inventoryListView = null; // Liste de releves
 
// Liste des observations
private InventoryItemList inventoryItemList = null; // Liste de releves saisis
private ActionPanel actionPanel=null; // Action sur les observations
// Actions sur les releves
private ActionView actionView=null; // Action sur les observations
private SearchPanel searchPanel = null; // Recherche dans les relevés saisis
 
// Informations
private InfoPopup infoPopup=null; // Information complementaire sur un taxon (photo, repartition)
Mediator() {
 
// Point d'entree (pour fin d'initialisation)
// Recherche identifiant utilisateur connecte
HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
new ResponseTextHandler() {
 
private Cel cel = null;
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
}
_Mediator();
}
});
 
Mediator() {
}
// Fin initialisation
private void _Mediator() {
// Navigateur
Viewport viewport = new Viewport();
viewport.setStyleName("my-border-layout");
viewport.setBorders(true);
viewport.setLayout(new BorderLayout());
 
center = new WidgetContainer();
center.setLayout(new BorderLayout());
center.setBorders(true);
 
west = new WidgetContainer();
west.setLayout(new FillLayout());
west.setBorders(true);
south = new WidgetContainer();
south.setLayout(new FillLayout());
south.setBorders(true);
 
north = new WidgetContainer();
north.setLayout(new FillLayout());
north.setBorders(true);
 
inventoryListView = new InventoryListView(this); // Liste de releves
connexionView = new ConnexionView(this); // Identifiant de connection
inventoryFilterView = new InventoryFilterView(this); // Ensemble de filtres sur liste de releves
entryView = new EntryView(this); // Formulaire de saisie
actionView = new ActionView(this); // Action sur releves saisis
// searchPanel = new SearchPanel(this); // Recherche dans releves
//applicationPanel.add(searchPanel);
BorderLayoutData westData = new BorderLayoutData(Style.WEST, 200, 150, 300);
westData.resizeable = true;
viewport.add(west, westData);
 
BorderLayoutData centerData = new BorderLayoutData(Style.CENTER, 400, 400, 800);
viewport.add(center, centerData);
 
 
BorderLayoutData northData = new BorderLayoutData(Style.NORTH, 20, 20, 20);
viewport.add(north, northData);
 
BorderLayoutData southData = new BorderLayoutData(Style.SOUTH, 400, 400, 800);
// viewport.add(south, southData);
 
viewport.layout();
onInit();
 
// Methodes Private
}
/**
79,55 → 178,15
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
*
*/
public void initUser() {
getUserFromService(); // Appel distant recherche de l'utilisateur
}
// Actions declanchee par le systeme
/**
136,9 → 195,10
public void onInit() {
 
// Filtre par defaut : all et action selection de toutes les stations
locationList.setLocation("all");
locationList.updateCount();
locationFilterPanel.setLocation("all");
locationFilterPanel.updateCount();
 
this.onLocationSelected("all");
176,6 → 236,9
infoPopup.setImageUrl(value);
}
 
/**
187,11 → 250,11
// Lazy instantiation
if (inventoryItem==null) {
registerInventoryItem(new InventoryItem());
inventoryItem=new InventoryItem(this);
}
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),"null");
inventoryItemList.addelement();
inventoryItem.addelement();
}
206,29 → 269,16
 
// Lazy instantiation
if (inventoryItem==null) {
registerInventoryItem(new InventoryItem());
inventoryItem=new InventoryItem(this);
}
 
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),ordre);
inventoryItemList.updateElement();
inventoryItem.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
241,12 → 291,12
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
String str, String value) {
if (getEntryPanel().getOrdre()==null) { // Nouvelle observation
if (entryView.getOrdre()==null) { // Nouvelle observation
onAddInventoryItem();
}
else {
onModifyInventoryItem(getEntryPanel().getOrdre()); // Modification d'une observation
getEntryPanel().setOrdre(null);
onModifyInventoryItem(entryView.getOrdre()); // Modification d'une observation
entryView.setOrdre(null);
}
 
}
260,9 → 310,13
public void onInventoryUpdated(String location) {
if (location.compareTo("")==0) {
location="000null";
}
 
locationList.setLocation(location); // Mise a jour filtre localite
locationList.updateCount();
locationFilterPanel.setLocation(location); // Mise a jour filtre localite
locationFilterPanel.updateCount();
 
this.onLocationSelected(location); // Selection localite
275,8 → 329,8
public void onInventoryItemSelected(String ordre) {
entryPanel.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne
entryPanel.update();
entryView.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne
entryView.update();
}
 
285,9 → 339,9
* Action sur deselection d'une observation : remise a zero
*/
public void onInventoryItemUnselected(String ordre) {
public void onInventoryItemUnselected() {
entryPanel.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne
entryView.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne
}
 
309,12 → 363,12
this.user=user;
topPanel.getSignLabel().setText(user+ " (deconnexion)");
inventoryItemList.setUser(user);
dateList.setUser(user);
stationList.setUser(user);
entryPanel.setUser(user);
locationList.setUser(user);
connexionView.getSignLabel().setText(user+ " (deconnexion)");
inventoryListView.setUser(user);
dateFilterPanel.setUser(user);
stationFilterPanel.setUser(user);
entryView.setUser(user);
locationFilterPanel.setUser(user);
this.onInit();
}
329,12 → 383,12
public void onLogoff(String user) {
this.user=user;
topPanel.getSignLabel().setText("Connexion");
inventoryItemList.setUser(user);
dateList.setUser(user);
stationList.setUser(user);
entryPanel.setUser(user);
locationList.setUser(user);
connexionView.getSignLabel().setText("Connexion");
inventoryListView.setUser(user);
dateFilterPanel.setUser(user);
stationFilterPanel.setUser(user);
entryView.setUser(user);
locationFilterPanel.setUser(user);
this.onInit();
}
351,8 → 405,8
if (search.trim().compareTo("")==0) {
search="all";
}
inventoryItemList.setSearch(search);
inventoryItemList.updateCount();
inventoryListView.setSearch(search);
inventoryListView.updateCount();
}
 
361,23 → 415,28
// Filtre selection lieu
/**
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants
* TODO : gerer asynchronicite ?
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants au filtrage
*/
public void onLocationSelected(String loc) {
inventoryItemList.setLocation(loc);
inventoryItemList.updateCount();
inventoryItemList.displayFilter();
// Positionnement Filtre affichage
inventoryListView.setLocation(loc);
inventoryListView.updateCount();
 
dateList.setLocation(loc);
dateList.updateCount();
// Affichage des filtres
inventoryListView.displayFilter();
 
// Positionnement Filtre affichage
 
dateFilterPanel.setLocation(loc);
dateFilterPanel.updateCount();
 
// Positionnement Filtre affichage
 
stationFilterPanel.setLocation(loc);
stationFilterPanel.updateCount();
stationList.setLocation(loc);
stationList.updateCount();
}
 
389,10 → 448,10
public void onStationSelected(String station) {
 
inventoryItemList.setStation(station);
inventoryItemList.updateCount();
inventoryListView.setStation(station);
inventoryListView.updateCount();
inventoryItemList.displayFilter();
inventoryListView.displayFilter();
 
 
 
407,10 → 466,10
public void onDateSelected(String date) {
 
inventoryItemList.setDate(date);
inventoryItemList.updateCount();
inventoryListView.setDate(date);
inventoryListView.updateCount();
inventoryItemList.displayFilter();
inventoryListView.displayFilter();
 
 
 
417,88 → 476,57
}
 
// Declaration, enregistrement
 
/**
* Declaration InventoryItem : une observation
* @param cel
*/
 
public void registerInventoryItem(InventoryItem inventoryItem) {
this.inventoryItem=inventoryItem;
}
 
 
/**
* Declaration InventoryItemList : liste d'observation
* @param inventoryItemList
* Declaration date : date observation
* @param date
*/
public void registerInventoryItemList(InventoryItemList inventoryItemList) {
public void registerDate(TextBox date) {
this.date=date;
this.inventoryItemList=inventoryItemList;
}
/**
* Declaration LocationList : filtre lieu observation
* @param locationList
*/
public void registerLocationList(LocationList locationList) {
this.locationList=locationList;
}
/**
* Declaration DateList : filtre date observation
* @param locationList
* Declaration lieu dit : lieu dit d'observation
*
* @param milieu
*/
public void registerDateList(DateList dateList) {
public void registerLieudit(TextBox lieudit) {
this.lieudit=lieudit;
this.dateList=dateList;
}
 
 
/**
* Declaration InfoPopup : information complementaire taxon en cours
* @param infoPopup
* Declaration milieu : milieu d'observation
*
* @param milieu
*/
public void registerInfoPopup(InfoPopup infoPopup) {
public void registerMilieu(TextBox milieu) {
this.milieu=milieu;
this.infoPopup=infoPopup;
}
 
 
/**
* Declaration StationList : filtre par station
* @param locationList
* Declaration commentaire b
* @param commentaire
*/
public void registerStationList(StationList stationList) {
public void registerComment(TextBox comment) {
this.comment=comment;
this.stationList=stationList;
}
 
/**
* Declaration Cel : point d'entree
* @param cel
*/
 
public void registerCel(Cel cel) {
this.cel=cel;
}
 
/**
* Declaration NameAssistant : completion nom scientifique
* @param nameassistant
509,107 → 537,52
}
/**
* Declaration LocationAssistant : completion commune
* @param locationassistant
* Declaration DateFilterPanel : filtre date observation
* @param locationList
*/
public void registerLocationAssistant(LocationAssistant locationAssistant) {
this.locationAssistant=locationAssistant;
public void registerDateFilterPanel(DateFilterPanel dateFilterPanel) {
this.dateFilterPanel=dateFilterPanel;
}
 
 
/**
* Declaration date : date observation
* @param date
* Declaration LocationAssistant : completion commune
* @param locationassistant
*/
public void registerDate(TextBox date) {
this.date=date;
public void registerLocationAssistant(LocationAssistant locationAssistant) {
this.locationAssistant=locationAssistant;
}
/**
* Declaration lieu dit : lieu dit d'observation
*
* @param milieu
*/
public void registerLieudit(TextBox lieudit) {
this.lieudit=lieudit;
}
 
 
/**
* Declaration milieu : milieu d'observation
*
* @param milieu
* Declaration LocationFilterPanel : filtre lieu observation
* @param locationList
*/
public void registerMilieu(TextBox milieu) {
this.milieu=milieu;
public void registerLocationFilterPanel(LocationFilterPanel locationFilterPanel) {
this.locationFilterPanel=locationFilterPanel;
}
 
/**
* Declaration Entry Panel : formulaire de saisie observation
*/
 
public void registerEntryPanel(EntryPanel entryPanel) {
this.entryPanel=entryPanel;
}
 
 
/**
* Declaration Action Panel : actions sur liste des observations
* Declaration StationFilterPanel : filtre par station
* @param locationList
*/
 
public void registerActionPanel(ActionPanel actionPanel) {
this.actionPanel=actionPanel;
}
 
 
/**
* Declaration TopPanel : panneau de connexion
*/
 
public void registerTopPanel(TopPanel topPanel) {
this.topPanel=topPanel;
}
 
/**
* Declaration commentaire
* @param commentaire
*/
public void registerComment(TextBox comment) {
this.comment=comment;
public void registerStationFilterPanel(StationFilterPanel stationFilterPanel) {
this.stationFilterPanel=stationFilterPanel;
}
 
/*
* Declaration LeftPanel Panneau gauche filtre sur liste d'observation
*
*/
public void registerLeftPanel(LeftPanel leftPanel) {
this.leftPanel=leftPanel;
}
// Accesseurs et setteurs
638,20 → 611,31
this.user=user;
}
 
public WidgetContainer getCenterContainer() {
return center;
}
public InventoryItemList getInventoryItemList() {
return inventoryItemList;
public WidgetContainer getNorthContainer() {
return north;
}
 
public LocationList getLocationList() {
return locationList;
public WidgetContainer getWestContainer() {
return west;
}
 
public DateList getDateList() {
return dateList;
public WidgetContainer getSouthContainer() {
return south;
}
 
public InventoryListView getInventoryListView() {
return inventoryListView;
}
 
public LocationFilterPanel getLocationList() {
return locationFilterPanel;
}
 
public NameAssistant getNameAssistant() {
return nameAssistant;
}
664,13 → 648,13
return inventoryItem;
}
 
public EntryPanel getEntryPanel() {
return entryPanel;
public EntryView entryView() {
return entryView;
}
 
 
public LeftPanel getLeftPanel() {
return leftPanel;
public InventoryFilterView getInventoryFilterView() {
return inventoryFilterView;
}
 
public InfoPopup getInfoPopup() {
691,9 → 675,9
}
 
public ActionPanel getActionPanel() {
public ActionView getActionView() {
return this.actionPanel;
return this.actionView;
}
 
}