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; |
|
// 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 |
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 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 |
44,90 → 65,128 |
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 |
// Liste de releves saisis |
|
private InventoryListView inventoryListView = null; // Liste de releves |
|
|
// 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) |
|
|
// Point d'entree (pour fin d'initialisation) |
Mediator() { |
|
private Cel cel = null; |
|
// Recherche identifiant utilisateur connecte |
|
Mediator() { |
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 |
} |
_Mediator(); |
} |
}); |
|
} |
|
// Methodes Private |
// Fin initialisation |
|
private void _Mediator() { |
|
// Navigateur |
|
/** |
* Recuperation du prefixe d'appel des services |
* @return prefix appel des service |
*/ |
Viewport viewport = new Viewport(); |
viewport.setStyleName("my-border-layout"); |
viewport.setBorders(true); |
viewport.setLayout(new BorderLayout()); |
|
private String getServiceBaseUrlFromDictionnary() { |
|
Dictionary theme = Dictionary.getDictionary("Parameters"); |
return theme.get("serviceBaseUrl"); |
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); |
|
// Appel aux services : |
north = new WidgetContainer(); |
north.setLayout(new FillLayout()); |
north.setBorders(true); |
|
|
/** |
* Recherche distante et asynchrone de l'utilisateur connecte, en retour lancement methode initialisation |
* de l'appellant Cel. (initAsync) |
* |
*/ |
inventoryListView = new InventoryListView(this); // Liste de releves |
connexionView = new ConnexionView(this); // Identifiant de connection |
|
private void getUserFromService() { |
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 |
|
|
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(); |
} |
}); |
//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); |
|
// Methodes Public |
|
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); |
|
// Information sur Etat du systeme |
viewport.layout(); |
onInit(); |
|
|
|
// Methodes Private |
} |
|
|
/** |
* Recuperation information utilisateur |
* |
* Recuperation du prefixe d'appel des services |
* @return prefix appel des service |
*/ |
|
public void initUser() { |
getUserFromService(); // Appel distant recherche de l'utilisateur |
private String getServiceBaseUrlFromDictionnary() { |
|
Dictionary theme = Dictionary.getDictionary("Parameters"); |
return theme.get("serviceBaseUrl"); |
|
} |
|
|
|
// Methodes Public |
|
|
|
|
|
// 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"); |
|
178,6 → 238,9 |
|
|
|
|
|
|
/** |
* Action prealable a l'ajout d'une observation : controle presence champs requis et lancement mise a jour |
* |
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); |
} |
|
} |
261,9 → 311,13 |
|
public void onInventoryUpdated(String location) { |
|
locationList.setLocation(location); // Mise a jour filtre localite |
locationList.updateCount(); |
if (location.compareTo("")==0) { |
location="000null"; |
} |
|
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(); |
// Positionnement Filtre affichage |
inventoryListView.setLocation(loc); |
inventoryListView.updateCount(); |
|
inventoryItemList.displayFilter(); |
// Affichage des filtres |
inventoryListView.displayFilter(); |
|
dateList.setLocation(loc); |
dateList.updateCount(); |
// Positionnement Filtre affichage |
|
stationList.setLocation(loc); |
stationList.updateCount(); |
dateFilterPanel.setLocation(loc); |
dateFilterPanel.updateCount(); |
|
// Positionnement Filtre affichage |
|
stationFilterPanel.setLocation(loc); |
stationFilterPanel.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(); |
|
|
|
418,110 → 477,10 |
|
// Declaration, enregistrement |
|
/** |
* Declaration InventoryItem : une observation |
* @param cel |
*/ |
|
public void registerInventoryItem(InventoryItem inventoryItem) { |
|
this.inventoryItem=inventoryItem; |
} |
|
|
|
/** |
* Declaration InventoryItemList : liste d'observation |
* @param inventoryItemList |
*/ |
|
public void registerInventoryItemList(InventoryItemList inventoryItemList) { |
|
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 |
*/ |
|
public void registerDateList(DateList dateList) { |
|
this.dateList=dateList; |
} |
|
|
/** |
* Declaration InfoPopup : information complementaire taxon en cours |
* @param infoPopup |
*/ |
|
public void registerInfoPopup(InfoPopup infoPopup) { |
|
this.infoPopup=infoPopup; |
} |
|
|
|
/** |
* Declaration StationList : filtre par station |
* @param locationList |
*/ |
|
public void registerStationList(StationList stationList) { |
|
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 |
*/ |
|
public void registerNameAssistant(NameAssistant nameAssistant) { |
this.nameAssistant=nameAssistant; |
|
} |
|
/** |
* Declaration LocationAssistant : completion commune |
* @param locationassistant |
*/ |
|
public void registerLocationAssistant(LocationAssistant locationAssistant) { |
this.locationAssistant=locationAssistant; |
|
} |
|
|
|
/** |
* Declaration date : date observation |
* @param date |
*/ |
558,58 → 517,72 |
} |
|
/** |
* Declaration Entry Panel : formulaire de saisie observation |
* Declaration commentaire b |
* @param commentaire |
*/ |
|
public void registerComment(TextBox comment) { |
this.comment=comment; |
|
public void registerEntryPanel(EntryPanel entryPanel) { |
this.entryPanel=entryPanel; |
} |
|
|
/** |
* Declaration Action Panel : actions sur liste des observations |
* Declaration NameAssistant : completion nom scientifique |
* @param nameassistant |
*/ |
|
public void registerNameAssistant(NameAssistant nameAssistant) { |
this.nameAssistant=nameAssistant; |
|
public void registerActionPanel(ActionPanel actionPanel) { |
this.actionPanel=actionPanel; |
} |
|
|
/** |
* Declaration TopPanel : panneau de connexion |
* Declaration DateFilterPanel : filtre date observation |
* @param locationList |
*/ |
|
public void registerDateFilterPanel(DateFilterPanel dateFilterPanel) { |
|
public void registerTopPanel(TopPanel topPanel) { |
this.topPanel=topPanel; |
this.dateFilterPanel=dateFilterPanel; |
} |
|
|
|
/** |
* Declaration commentaire |
* @param commentaire |
* Declaration LocationAssistant : completion commune |
* @param locationassistant |
*/ |
|
public void registerComment(TextBox comment) { |
this.comment=comment; |
public void registerLocationAssistant(LocationAssistant locationAssistant) { |
this.locationAssistant=locationAssistant; |
|
} |
|
/** |
* Declaration LocationFilterPanel : filtre lieu observation |
* @param locationList |
*/ |
|
/* |
* Declaration LeftPanel Panneau gauche filtre sur liste d'observation |
* |
public void registerLocationFilterPanel(LocationFilterPanel locationFilterPanel) { |
|
this.locationFilterPanel=locationFilterPanel; |
} |
|
|
/** |
* Declaration StationFilterPanel : filtre par station |
* @param locationList |
*/ |
|
public void registerLeftPanel(LeftPanel leftPanel) { |
this.leftPanel=leftPanel; |
public void registerStationFilterPanel(StationFilterPanel stationFilterPanel) { |
|
this.stationFilterPanel=stationFilterPanel; |
} |
|
|
|
// 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; |
} |
|
} |