/trunk/src/org/tela_botanica/client/ConnexionView.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/EntryView.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/InventoryFilterView.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/LocationFilterPanel.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/DateFilterPanel.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/StationFilterPanel.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/ActionView.java |
---|
File deleted |
\ No newline at end of file |
/trunk/src/org/tela_botanica/client/InventoryListView.java |
---|
File deleted |
\ No newline at end of file |
/trunk/src/org/tela_botanica/client/Mediator.java |
---|
2,20 → 2,8 |
// TODO : sortie User vers une classe ... |
// TODO : sortie les boutons supprimer et exporter et inclure ici : vraiment ? |
// TODO : sortie les boutons supprimer et exporter et inclure ici |
// 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; |
28,32 → 16,23 |
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 EntryView entryView=null; // Formulaire de saisie 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 |
65,128 → 44,90 |
private InventoryItem inventoryItem=null; // Une observation saisie |
// Liste de releves saisis |
// Liste des observations |
private InventoryItemList inventoryItemList = null; // Liste de releves saisis |
private ActionPanel actionPanel=null; // Action sur les observations |
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) |
Mediator() { |
// Point d'entree (pour fin d'initialisation) |
private Cel cel = null; |
// Recherche identifiant utilisateur connecte |
HTTPRequest.asyncGet(serviceBaseUrl + "/User/", |
new ResponseTextHandler() { |
Mediator() { |
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(); |
} |
}); |
} |
// Fin initialisation |
// Methodes Private |
private void _Mediator() { |
// Navigateur |
Viewport viewport = new Viewport(); |
viewport.setStyleName("my-border-layout"); |
viewport.setBorders(true); |
viewport.setLayout(new BorderLayout()); |
/** |
* Recuperation du prefixe d'appel des services |
* @return prefix appel des service |
*/ |
private String getServiceBaseUrlFromDictionnary() { |
center = new WidgetContainer(); |
center.setLayout(new BorderLayout()); |
center.setBorders(true); |
Dictionary theme = Dictionary.getDictionary("Parameters"); |
return theme.get("serviceBaseUrl"); |
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); |
// Appel aux services : |
inventoryListView = new InventoryListView(this); // Liste de releves |
connexionView = new ConnexionView(this); // Identifiant de connection |
/** |
* Recherche distante et asynchrone de l'utilisateur connecte, en retour lancement methode initialisation |
* de l'appellant Cel. (initAsync) |
* |
*/ |
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 |
private void getUserFromService() { |
HTTPRequest.asyncGet(serviceBaseUrl + "/User/", |
new ResponseTextHandler() { |
//applicationPanel.add(searchPanel); |
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(); |
} |
}); |
} |
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); |
viewport.layout(); |
onInit(); |
// Information sur Etat du systeme |
// Methodes Private |
} |
/** |
* Recuperation du prefixe d'appel des services |
* @return prefix appel des service |
* Recuperation information utilisateur |
* |
*/ |
private String getServiceBaseUrlFromDictionnary() { |
Dictionary theme = Dictionary.getDictionary("Parameters"); |
return theme.get("serviceBaseUrl"); |
public void initUser() { |
getUserFromService(); // Appel distant recherche de l'utilisateur |
} |
// Methodes Public |
// Actions declanchee par le systeme |
/** |
195,10 → 136,9 |
public void onInit() { |
// Filtre par defaut : all et action selection de toutes les stations |
locationFilterPanel.setLocation("all"); |
locationFilterPanel.updateCount(); |
locationList.setLocation("all"); |
locationList.updateCount(); |
this.onLocationSelected("all"); |
238,9 → 178,6 |
/** |
* Action prealable a l'ajout d'une observation : controle presence champs requis et lancement mise a jour |
* |
250,11 → 187,11 |
// Lazy instantiation |
if (inventoryItem==null) { |
inventoryItem=new InventoryItem(this); |
registerInventoryItem(new InventoryItem()); |
} |
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),"null"); |
inventoryItem.addelement(); |
inventoryItemList.addelement(); |
} |
269,16 → 206,29 |
// Lazy instantiation |
if (inventoryItem==null) { |
inventoryItem=new InventoryItem(this); |
registerInventoryItem(new InventoryItem()); |
} |
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),ordre); |
inventoryItem.updateElement(); |
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 |
291,12 → 241,12 |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, |
String str, String value) { |
if (entryView.getOrdre()==null) { // Nouvelle observation |
if (getEntryPanel().getOrdre()==null) { // Nouvelle observation |
onAddInventoryItem(); |
} |
else { |
onModifyInventoryItem(entryView.getOrdre()); // Modification d'une observation |
entryView.setOrdre(null); |
onModifyInventoryItem(getEntryPanel().getOrdre()); // Modification d'une observation |
getEntryPanel().setOrdre(null); |
} |
} |
311,13 → 261,9 |
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 |
} |
329,8 → 275,8 |
public void onInventoryItemSelected(String ordre) { |
entryView.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne |
entryView.update(); |
entryPanel.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne |
entryPanel.update(); |
} |
339,9 → 285,9 |
* Action sur deselection d'une observation : remise a zero |
*/ |
public void onInventoryItemUnselected() { |
public void onInventoryItemUnselected(String ordre) { |
entryView.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne |
entryPanel.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne |
} |
363,12 → 309,12 |
this.user=user; |
connexionView.getSignLabel().setText(user+ " (deconnexion)"); |
inventoryListView.setUser(user); |
dateFilterPanel.setUser(user); |
stationFilterPanel.setUser(user); |
entryView.setUser(user); |
locationFilterPanel.setUser(user); |
topPanel.getSignLabel().setText(user+ " (deconnexion)"); |
inventoryItemList.setUser(user); |
dateList.setUser(user); |
stationList.setUser(user); |
entryPanel.setUser(user); |
locationList.setUser(user); |
this.onInit(); |
} |
383,12 → 329,12 |
public void onLogoff(String user) { |
this.user=user; |
connexionView.getSignLabel().setText("Connexion"); |
inventoryListView.setUser(user); |
dateFilterPanel.setUser(user); |
stationFilterPanel.setUser(user); |
entryView.setUser(user); |
locationFilterPanel.setUser(user); |
topPanel.getSignLabel().setText("Connexion"); |
inventoryItemList.setUser(user); |
dateList.setUser(user); |
stationList.setUser(user); |
entryPanel.setUser(user); |
locationList.setUser(user); |
this.onInit(); |
} |
405,8 → 351,8 |
if (search.trim().compareTo("")==0) { |
search="all"; |
} |
inventoryListView.setSearch(search); |
inventoryListView.updateCount(); |
inventoryItemList.setSearch(search); |
inventoryItemList.updateCount(); |
} |
415,28 → 361,23 |
// Filtre selection lieu |
/** |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants au filtrage |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
* TODO : gerer asynchronicite ? |
*/ |
public void onLocationSelected(String loc) { |
// Positionnement Filtre affichage |
inventoryListView.setLocation(loc); |
inventoryListView.updateCount(); |
inventoryItemList.setLocation(loc); |
inventoryItemList.updateCount(); |
// Affichage des filtres |
inventoryListView.displayFilter(); |
inventoryItemList.displayFilter(); |
// Positionnement Filtre affichage |
dateList.setLocation(loc); |
dateList.updateCount(); |
dateFilterPanel.setLocation(loc); |
dateFilterPanel.updateCount(); |
stationList.setLocation(loc); |
stationList.updateCount(); |
// Positionnement Filtre affichage |
stationFilterPanel.setLocation(loc); |
stationFilterPanel.updateCount(); |
} |
448,10 → 389,10 |
public void onStationSelected(String station) { |
inventoryListView.setStation(station); |
inventoryListView.updateCount(); |
inventoryItemList.setStation(station); |
inventoryItemList.updateCount(); |
inventoryListView.displayFilter(); |
inventoryItemList.displayFilter(); |
466,10 → 407,10 |
public void onDateSelected(String date) { |
inventoryListView.setDate(date); |
inventoryListView.updateCount(); |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
inventoryListView.displayFilter(); |
inventoryItemList.displayFilter(); |
477,10 → 418,110 |
// 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 |
*/ |
517,72 → 558,58 |
} |
/** |
* Declaration commentaire b |
* @param commentaire |
* Declaration Entry Panel : formulaire de saisie observation |
*/ |
public void registerComment(TextBox comment) { |
this.comment=comment; |
public void registerEntryPanel(EntryPanel entryPanel) { |
this.entryPanel=entryPanel; |
} |
/** |
* Declaration NameAssistant : completion nom scientifique |
* @param nameassistant |
* Declaration Action Panel : actions sur liste des observations |
*/ |
public void registerNameAssistant(NameAssistant nameAssistant) { |
this.nameAssistant=nameAssistant; |
public void registerActionPanel(ActionPanel actionPanel) { |
this.actionPanel=actionPanel; |
} |
/** |
* Declaration DateFilterPanel : filtre date observation |
* @param locationList |
* Declaration TopPanel : panneau de connexion |
*/ |
public void registerDateFilterPanel(DateFilterPanel dateFilterPanel) { |
this.dateFilterPanel=dateFilterPanel; |
public void registerTopPanel(TopPanel topPanel) { |
this.topPanel=topPanel; |
} |
/** |
* Declaration LocationAssistant : completion commune |
* @param locationassistant |
* Declaration commentaire |
* @param commentaire |
*/ |
public void registerLocationAssistant(LocationAssistant locationAssistant) { |
this.locationAssistant=locationAssistant; |
public void registerComment(TextBox comment) { |
this.comment=comment; |
} |
/** |
* Declaration LocationFilterPanel : filtre lieu observation |
* @param locationList |
*/ |
public void registerLocationFilterPanel(LocationFilterPanel locationFilterPanel) { |
this.locationFilterPanel=locationFilterPanel; |
} |
/** |
* Declaration StationFilterPanel : filtre par station |
* @param locationList |
/* |
* Declaration LeftPanel Panneau gauche filtre sur liste d'observation |
* |
*/ |
public void registerStationFilterPanel(StationFilterPanel stationFilterPanel) { |
public void registerLeftPanel(LeftPanel leftPanel) { |
this.leftPanel=leftPanel; |
this.stationFilterPanel=stationFilterPanel; |
} |
// Accesseurs et setteurs |
611,31 → 638,20 |
this.user=user; |
} |
public WidgetContainer getCenterContainer() { |
return center; |
} |
public WidgetContainer getNorthContainer() { |
return north; |
public InventoryItemList getInventoryItemList() { |
return inventoryItemList; |
} |
public WidgetContainer getWestContainer() { |
return west; |
public LocationList getLocationList() { |
return locationList; |
} |
public WidgetContainer getSouthContainer() { |
return south; |
public DateList getDateList() { |
return dateList; |
} |
public InventoryListView getInventoryListView() { |
return inventoryListView; |
} |
public LocationFilterPanel getLocationList() { |
return locationFilterPanel; |
} |
public NameAssistant getNameAssistant() { |
return nameAssistant; |
} |
648,13 → 664,13 |
return inventoryItem; |
} |
public EntryView entryView() { |
return entryView; |
public EntryPanel getEntryPanel() { |
return entryPanel; |
} |
public InventoryFilterView getInventoryFilterView() { |
return inventoryFilterView; |
public LeftPanel getLeftPanel() { |
return leftPanel; |
} |
public InfoPopup getInfoPopup() { |
675,9 → 691,9 |
} |
public ActionView getActionView() { |
public ActionPanel getActionPanel() { |
return this.actionView; |
return this.actionPanel; |
} |
} |
/trunk/src/org/tela_botanica/client/LocationList.java |
---|
New file |
0,0 → 1,487 |
/* |
* Copyright 2006 Google Inc. |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
* use this file except in compliance with the License. You may obtain a copy of |
* the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
* License for the specific language governing permissions and limitations under |
* the License. |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
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.ui.Button; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.DockPanel; |
import com.google.gwt.user.client.ui.FlexTable; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Widget; |
/** |
* A tree displaying a set of email folders. |
*/ |
public class LocationList extends Composite { |
// Barre de navigation |
private class NavBar extends Composite implements ClickListener { |
public final DockPanel bar = new DockPanel(); |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
status.setWordWrap(false); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(status); |
buttons.setCellHorizontalAlignment(status, |
HasHorizontalAlignment.ALIGN_RIGHT); |
buttons.setCellVerticalAlignment(status, |
HasVerticalAlignment.ALIGN_MIDDLE); |
buttons.setCellWidth(status, "100%"); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_LOCATION_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_LOCATION_COUNT; |
} else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_LOCATION_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} else { |
if (sender == gotoEnd) { |
gotoEnd(); |
} else { |
if (sender == gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
} |
private static final int VISIBLE_LOCATION_COUNT = 10; |
private static final String VALUE_UNKNOWN = "Inconnues"; |
private Grid header = new Grid(1, 2); |
private Grid selector = new Grid(1, 1); |
private FlexTable table = new FlexTable(); |
private VerticalPanel outer = new VerticalPanel(); |
private VerticalPanel inner = new VerticalPanel(); |
private int startIndex = 0; |
private String user; |
private String serviceBaseUrl = null; |
private String location = "all"; |
private NavBar navBar=null; |
private int count = 0; |
// Tous selectionn� |
private int selectedRow = -1; |
private Mediator mediator = null; |
public LocationList(Mediator med) { |
mediator=med; |
mediator.registerLocationList(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
navBar = new NavBar(); |
// Mise en forme du header |
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("location-ListHeader"); |
header.setWidget(0, 1,navBar); |
// Mise en forme de l'entree "Toutes localit�s" |
selector.setCellSpacing(0); |
selector.setCellPadding(0); |
selector.setWidth("100%"); |
selector.setHTML(0, 0, "Toutes"); |
selector.getCellFormatter().setWidth(0, 0, "100%"); |
// Hook up events. |
selector.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "location-SelectedRow"); |
mediator.onLocationSelected("all"); |
} |
}); |
selector.setStyleName("location-ListElement"); |
// Mise en forme du contenu |
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
table.setStyleName("location-ListElement"); |
// Mise en forme barre navigation |
navBar.setWidth("100%"); |
outer.add(header); |
inner.add(selector); // Toutes localit�s |
inner.add(table); |
inner.setStyleName("location-List"); |
inner.setWidth("100%"); |
outer.setWidth("100%"); |
outer.add(inner); |
// Hook up events. |
table.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String loc=table.getText(row,cell); |
if (loc.compareTo(VALUE_UNKNOWN)!=0) { |
location=loc; |
mediator.onLocationSelected(table.getText(row,cell)); |
} |
else { |
location="000null"; |
mediator.onLocationSelected("000null"); |
} |
} |
}); |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "location-SelectedRow"); |
// mediator.onLocationSelected("all"); |
//updateCount(); |
// update() |
initWidget(outer); |
} |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
* |
*/ |
public void updateCount() { |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" , |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
update(); |
} |
} |
}); |
} |
private void selectRow(int row) { |
styleRow(selectedRow, false); |
styleRow(row, true); |
selectedRow = row; |
} |
private void styleRow(int row, boolean selected) { |
if (row != -1) { |
selector.getRowFormatter().removeStyleName(0, "location-SelectedRow"); |
if (selected) |
table.getRowFormatter().addStyleName(row, "location-SelectedRow"); |
else |
if (row < table.getRowCount()) { |
table.getRowFormatter().removeStyleName(row, "location-SelectedRow"); |
} |
} |
} |
/** |
* |
* 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 |
* |
*/ |
public void update() { |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" + |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + |
+ startIndex + "/" + VISIBLE_LOCATION_COUNT, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
int arraySize = jsonArray.size(); |
for (i = 0; i < arraySize; ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
if (i>=table.getRowCount()) { |
row = table.insertRow(table.getRowCount()); |
} |
else { |
row = i; |
} |
// Lieu |
String loc=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString()); |
if (loc.compareTo("000null")!=0) { |
table.setText(row, 0,loc); |
} |
else { |
table.setText(row, 0,VALUE_UNKNOWN); |
} |
if (loc.compareTo(location)==0) { |
styleRow(row, true); |
} |
else { |
styleRow(row, false); |
} |
table.getFlexCellFormatter().setWidth(row, 0, "100%"); |
} |
} |
} |
if (location.compareTo("all")==0) { |
selector.getRowFormatter().addStyleName(0, "location-SelectedRow"); |
} |
// Suppression fin ancien affichage |
if (i<table.getRowCount()) { |
for (int j = table.getRowCount() -1 ; j >= i; j--) { |
table.removeRow(j); |
} |
} |
setStatusEnabled(); |
} |
}); |
} |
public void setLocation(String location) { |
this.location = location; |
} |
/* |
* Positionnement index de parcours (this.startIndex) pour affichage de la |
* derni�re page |
* |
* @param |
* @return void |
*/ |
private void gotoEnd() { |
if ((count == 0) || (count % VISIBLE_LOCATION_COUNT) > 0) { |
startIndex = count - (count % VISIBLE_LOCATION_COUNT); |
} else { |
startIndex = count - VISIBLE_LOCATION_COUNT; |
} |
} |
/** |
* Affichage message d'attente et d�sactivation navigation |
* |
* @param |
* @return void |
*/ |
private void setStatusDisabled() { |
navBar.gotoFirst.setEnabled(false); |
navBar.gotoPrev.setEnabled(false); |
navBar.gotoNext.setEnabled(false); |
navBar.gotoEnd.setEnabled(false); |
setStatusText("Patientez ..."); |
} |
/** |
* Affichage numero de page et gestion de la navigation |
* |
*/ |
private void setStatusEnabled() { |
// Il y a forcemment un disabled avant d'arriver ici |
if (count > 0) { |
if (startIndex >= VISIBLE_LOCATION_COUNT) { // Au dela de la |
// premiere page |
navBar.gotoPrev.setEnabled(true); |
navBar.gotoFirst.setEnabled(true); |
if (startIndex < (count - VISIBLE_LOCATION_COUNT)) { // Pas la |
// derniere |
// page |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count ); |
} else { // Derniere page |
setStatusText((startIndex + 1) + " - " + count + " sur " + count ); |
} |
} else { // Premiere page |
if (count > VISIBLE_LOCATION_COUNT) { // Des pages derrieres |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count); |
} else { |
setStatusText((startIndex + 1) + " - " + count + " sur " + count); |
} |
} |
} |
else { // Pas d'inventaire, pas de navigation |
setStatusText("0 - 0 sur 0"); |
} |
} |
private void setStatusText(String text) { |
navBar.status.setText(text); |
} |
public void setUser(String user) { |
this.user = user; |
} |
} |
/trunk/src/org/tela_botanica/client/InventoryItemList.java |
---|
New file |
0,0 → 1,1067 |
/** |
David Delon david.delon@clapas.net 2007 |
*/ |
/* |
* InventoryItemList.java (Composite de Panel) |
* |
* Cas d'utilisation : |
* |
* Affichage de releve |
* |
* 1 : Recherche du nombre de releves associe au navigateur ou a l'utilisateur est connecte, en fonction des criteres de selection |
* 2 : Recherche des releves correspondant au critere precedent |
* 3 : Affichage des releves avec positionnement sur le dernier releve |
* |
* Selection de releve |
* |
* 1 : L'utilisateur selectionne un releve : lancement de l'affichage detaille pour le releve selectionne |
* |
* |
* Pagination : |
* |
* 1 : Avancement ou recul d'une page |
* |
* |
* C(R)UD Element d'inventaire : (TODO : creer un nouvel objet pour cela) |
* |
* 1 : Ajoute d'un element |
* 2 : Modification d'un element |
* 3 : Suppression d'un element |
*/ |
/* Actions declenchees : |
* |
* onInventoryItemSelected(numero d'ordre de la ligne selectionne) : selection d'une ligne |
* onInventoryItemUnselected(numero d'ordre de la ligne selectionne) : deselection d'une ligne |
* onInventoryUpdated(location) : action suite a la modification, suppression, creation d'un element d'inventaire |
* |
*/ |
package org.tela_botanica.client; |
import java.util.Iterator; |
import java.util.Vector; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
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.ui.Composite; |
import com.google.gwt.user.client.ui.FlexTable; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.Image; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.CheckBox; |
import com.google.gwt.user.client.ui.Widget; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
public class InventoryItemList extends Composite |
{ |
// Debut Barre de navigation |
private class NavBar extends Composite implements ClickListener { |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
HorizontalPanel bar = new HorizontalPanel(); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
bar.add(status); |
bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT); |
bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE); |
bar.setCellWidth(status, "100%"); |
bar.add(gotoFirst); |
bar.add(gotoPrev); |
bar.add(gotoNext); |
bar.add(gotoEnd); |
initWidget(bar); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_TAXON_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_TAXON_COUNT; |
} else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_TAXON_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} else { |
if (sender == gotoEnd) { |
gotoEnd(); |
} else { |
if (sender == gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
} |
// Fin Barre de navigation |
// Conteneur (header et table sont dans panel) |
private Grid header = new Grid(1, 3); |
private FlexTable table = new FlexTable(); |
private VerticalPanel panel = new VerticalPanel(); |
// Services |
private String serviceBaseUrl = null; |
private String user; |
private Mediator mediator = null; |
// Navigation |
private int startIndex = 0; |
private int count = 0; |
private static final int VISIBLE_TAXON_COUNT = 15; |
private NavBar navBar=null; |
private int selectedRow = -1; |
// Filtre par defaut : |
private String location = "all"; |
private String date = "all"; |
private String search = "all"; |
private String station = "all"; |
public InventoryItemList(Mediator med) { |
// Traitement contexte utilisateur et service |
mediator=med; |
mediator.registerInventoryItemList(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
// Barre navigation integree au header |
navBar = new NavBar(); |
// Mise en forme du header |
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("inventoryItem-ListHeader"); |
header.setWidget(0, 2, navBar); |
// Mise en forme de la table (contenu) |
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
table.setStyleName("inventoryItem-List"); |
panel.add(header); |
panel.add(table); |
table.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
if ((table.getWidget(row, 0)!=null) && (cell>0)){ |
if (row!=selectedRow) { |
selectRow(row); |
// Numero d'ordre |
mediator.onInventoryItemSelected(table.getText(row, 5)); |
} |
// Deselection |
else { |
styleRow(row, false); |
selectedRow=-1; |
// Numero d'ordre |
mediator.onInventoryItemUnselected(table.getText(row, 5)); |
} |
} |
} |
}); |
initWidget(panel); |
} |
/** |
* Gestion affichage selection/deselection d'un element d'inventaire |
* |
*/ |
private void selectRow(int row) { |
styleRow(selectedRow, false); |
styleRow(row, true); |
selectedRow = row; |
} |
private void styleRow(int row, boolean selected) { |
if (row != -1) { |
if (selected) |
table.getRowFormatter().addStyleName(row, "inventoryItem-SelectedRow"); |
else |
if (row < table.getRowCount()) { |
table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow"); |
} |
} |
} |
/** |
* Lancement de la mise a jour d'une ligne d'inventaire (appele par Mediator.onModifyInventoryItem()) |
* |
*/ |
public void updateElement() { |
if (mediator.inventoryItemIsValid()) { |
final InventoryItem inventoryItem=mediator.getInventoryItem(); |
setStatusDisabled(); |
// Modification d'un nom faisant parti du referentiel : recherche du nom valide correspondant |
if (inventoryItem.getNomenclaturalNumber() !=null) { |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(), |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, Famille |
updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(), |
Util.toCelString(((JSONString) jsonArray.get(0)) |
.toString()), |
((JSONString) jsonArray.get(1)) |
.stringValue(), |
((JSONString) jsonArray.get(2)) |
.stringValue(), |
Util.toCelString(((JSONString) jsonArray.get(3)) |
.toString()), |
inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getMilieu(),inventoryItem.getComment()); |
} |
} |
}); |
} |
// Modification d'un nom ne faisant pas parti du referentiel (saisie libre) |
else { |
updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getMilieu(),inventoryItem.getComment()); |
} |
} |
else { |
// TODO : message d'erreur |
return; |
} |
} |
/** |
* Lancement de la creation d'une ligne d'inventaire (appele par Mediator.onAddInventoryItem()) |
* |
*/ |
public void addelement() { |
if (mediator.inventoryItemIsValid()) { |
final InventoryItem inventoryItem=mediator.getInventoryItem(); |
setStatusDisabled(); |
// Creation d'un nom faisant parti du referentiel : recherche du nom valide correspondant |
if (inventoryItem.getNomenclaturalNumber() !=null) { |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(), |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, |
// Famille |
addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(), |
Util.toCelString(((JSONString) jsonArray.get(0)) |
.toString()), |
((JSONString) jsonArray.get(1)) |
.stringValue(), |
((JSONString) jsonArray.get(2)) |
.stringValue(), |
Util.toCelString(((JSONString) jsonArray.get(3)) |
.toString()), |
inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getMilieu(),inventoryItem.getComment()); |
} |
} |
}); |
} |
// Saisie libre |
else { |
addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getMilieu(),inventoryItem.getComment()); |
} |
} |
else { |
// TODO : message d'erreur |
return; |
} |
} |
/** |
* Ajoute effectif d'un element a l'inventaire (appel interne) |
* |
* @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 |
*/ |
private void addElement(String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String milieu, String comment) { |
count++; |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant=" |
+ user + "&nom_sel=" + URL.encodeComponent(nom_sel) + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + URL.encodeComponent(nom_ret) + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + URL.encodeComponent(famille) + "&location=" + URL.encodeComponent(loc) + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ URL.encodeComponent(milieu) + "&commentaire="+ URL.encodeComponent(comment), |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
location=loc; |
if (location.compareTo("")==0) { |
location="000null"; |
} |
mediator.onInventoryUpdated(location); |
} |
}); |
} |
/** |
* Modification effective d'un element de l'inventaire (appel interne) |
* |
* @param ordre : numero d'ordre |
* @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 |
*/ |
private void updateElement(String ordre, String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String milieu, String comment) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user + "/" +ordre + "/", |
"&nom_sel=" + URL.encodeComponent(nom_sel) + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + URL.encodeComponent(nom_ret) + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + URL.encodeComponent(famille) + "&location=" + URL.encodeComponent(loc) + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ URL.encodeComponent(milieu) + "&commentaire="+ URL.encodeComponent(comment), |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
mediator.onInventoryUpdated(location); |
} |
}); |
} |
/** |
* Suppression effective d'un element lde l'inventaire, a partir de son numero d'ordre |
* |
*/ |
public void deleteElement() { |
setStatusDisabled(); |
Vector parseChecked = new Vector(); |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
// Numero ordre |
parseChecked.add(table.getText(i, 5)); |
count--; |
} |
} |
} |
StringBuffer ids=new StringBuffer(); |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
if (ids.length()>0) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + ids.toString(), "action=DELETE", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
mediator.onInventoryUpdated(location); |
} |
}); |
} |
setStatusEnabled(); |
} |
/** |
* Transmission de releve a Tela (TODO : a appeler par Mediator) |
*/ |
public void transmitElement() { |
setStatusDisabled(); |
Vector parseChecked = new Vector(); |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
// Numero ordre |
parseChecked.add(table.getText(i, 5)); |
} |
} |
} |
StringBuffer ids=new StringBuffer(); |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
if (ids.length()>0) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user |
+ "/" + ids.toString(), "transmission=1", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
update(); // Pour affichage logo |
} |
}); |
} |
setStatusEnabled(); |
} |
/** |
* Selection/Deselection de l'ensemble des elements affiches |
* |
*/ |
public void selectAll() { |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) |
((CheckBox) table.getWidget(i, 0)).setChecked(true); |
} |
} |
public void deselectAll() { |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) |
((CheckBox) table.getWidget(i, 0)).setChecked(false); |
} |
} |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours |
* |
*/ |
public void updateCount () { |
setStatusDisabled(); |
// Transformation de la date selectionne vers date time stamp |
String adate="all"; |
if (date.compareTo("all")!=0) { |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00"; |
} |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) + "/" + adate + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(station), |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
// if (location.compareTo("")==0) location="000null"; |
gotoEnd(); // Derniere page |
update(); |
} |
} |
}); |
} |
// Utilitaire affichage |
private String subLeft(String text, int length) { |
return (text.length() < length) ? text : text.substring(0, length)+ " ..."; |
} |
/** |
* Mise a jour de l'affichage, a partir des donnaes d'inventaire deja |
* saisies. La valeur de this.startIndex permet de determiner quelles |
* donnaes seront affichees |
* |
*/ |
public void update() { |
// table.setBorderWidth(1); // Debug |
// Ligne d'information |
setStatusDisabled(); |
String adate="all"; |
if (date.compareTo("all")!=0) { |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00"; |
} |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) +"/" + adate + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(station) + "/" |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
StringBuffer left=new StringBuffer(); |
StringBuffer center=new StringBuffer(); |
StringBuffer right=new StringBuffer(); |
int arraySize = jsonArray.size(); |
for (i = 0; i < arraySize; ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
// Optimisation |
if (i>=table.getRowCount()) { |
row = table.insertRow(table.getRowCount()); |
} |
else { |
row = i; |
} |
left=new StringBuffer(); |
center=new StringBuffer(); |
right=new StringBuffer(); |
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Statut Observation transmise ? |
String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue(); |
if (atransmit.compareTo("1")==0) { |
table.setWidget(row,1,new Image("tela.gif")); |
} |
else { |
table.setWidget(row,1,new HTML(" ")); |
} |
// Nom saisi |
left.append("<b>"+Util.toCelString(((JSONString) jsonArrayNested .get(0)).toString())+"</b>"); |
// Nom retenu |
String aname=Util.toCelString(((JSONString) jsonArrayNested .get(2)).toString()); |
if (aname.compareTo("null")==0) { |
} |
else { |
center.append(aname+", "); |
} |
// Num nomenclatural |
String ann=((JSONString) jsonArrayNested .get(3)).stringValue(); |
if (ann.compareTo("0")!=0) { |
center.append(""+ann+"-"); |
} |
else { |
center.append("0-"); |
} |
// Num Taxonomique |
String ant=((JSONString) jsonArrayNested .get(4)).stringValue(); |
if (ant.compareTo("0")!=0) { |
center.append(ant+", "); |
} |
else { |
center.append("0, "); |
} |
// Famille |
String afamily=Util.toCelString(((JSONString) jsonArrayNested .get(5)).toString()); |
if (afamily.compareTo("null")==0) { |
// |
} |
else { |
center.append(afamily+", "); |
} |
String aloc=Util.toCelString(((JSONString) jsonArrayNested .get(6)).toString()); |
// Localisation - Lieu |
if (aloc.compareTo("000null")==0) { |
if (center.length()==0) { |
center.append("Commune absente"); |
} |
else { |
center.append("commune absente"); |
} |
} |
else { |
if (center.length()==0) { |
center.append("Commune de "+aloc); |
} |
else { |
center.append("commune de "+aloc); |
} |
} |
String alieudit=Util.toCelString(((JSONString) jsonArrayNested .get(9)).toString()); |
// Localisation - Lieu dit |
if (alieudit.compareTo("000null")!=0) { |
center.append(", "+alieudit); |
} |
String acomment=Util.toCelString(((JSONString) jsonArrayNested .get(10)).toString()); |
// Commentaire |
if (acomment.compareTo("null")!=0) { |
center.append(", "+acomment); |
} |
String adate=((JSONString) jsonArrayNested .get(8)).stringValue(); |
// Date |
if (adate.compareTo("0000-00-00 00:00:00")!=0) { |
right.append("<b>"+adate+"</b>"); |
} |
else { |
// right.append("<b>00/00/0000</b>"); |
} |
table.setHTML(row, 2, subLeft(" "+left,40)); |
table.setHTML(row, 3, subLeft(" "+center,120)); |
table.setHTML(row, 4, subLeft(" "+right,25)); |
table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow"); |
table.getCellFormatter().setWidth(row,0,"2%"); |
table.getCellFormatter().setWidth(row,1,"2%"); |
table.getCellFormatter().setWordWrap(row,2,false); |
table.getCellFormatter().setWidth(row,2,"10%"); |
table.getCellFormatter().setWordWrap(row,3,false); |
table.getCellFormatter().setWordWrap(row,4,false); |
table.getCellFormatter().setWidth(row,4,"7%"); |
String aordre=((JSONString) jsonArrayNested.get(7)).stringValue(); |
// Numero d'ordre (cache) |
table.setText(row, 5, aordre); |
table.getCellFormatter().setVisible(row, 5, false); |
} |
} |
} |
// Suppression fin ancien affichage |
for (int j=i;j<VISIBLE_TAXON_COUNT;j++) { |
table.setHTML(j,0," "); |
table.setHTML(j,1," "); |
table.setHTML(j,2," "); |
table.setHTML(j,3," "); |
table.setHTML(j,4," "); |
table.setHTML(j,5," "); |
table.getCellFormatter().setVisible(j, 5, false); |
table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow"); |
} |
setStatusEnabled(); |
} |
}); |
} |
/** |
* Affichage message d'attente et desactivation navigation |
* |
* @param |
* @return void |
*/ |
private void setStatusDisabled() { |
navBar.gotoFirst.setEnabled(false); |
navBar.gotoPrev.setEnabled(false); |
navBar.gotoNext.setEnabled(false); |
navBar.gotoEnd.setEnabled(false); |
navBar.status.setText("Patientez ..."); |
} |
/** |
* Affichage numero de page et gestion de la navigation |
* |
*/ |
private void setStatusEnabled() { |
// Il y a forcemment un disabled avant d'arriver ici |
if (count > 0) { |
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 |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
navBar.status.setText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count ); |
} else { // Derniere page |
navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count ); |
} |
} else { // Premiere page |
if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
navBar.status.setText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count); |
} else { |
navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count); |
} |
} |
} |
else { // Pas d'inventaire, pas de navigation |
navBar.status.setText("0 - 0 sur 0"); |
} |
} |
/* |
* Positionnement index de parcours (this.startIndex) pour affichage de la |
* derniere page |
* |
* @param |
* @return void |
*/ |
private void gotoEnd() { |
if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) { |
startIndex = count - (count % VISIBLE_TAXON_COUNT); |
} else { |
startIndex = count - VISIBLE_TAXON_COUNT; |
} |
} |
/* |
* Recherche en cours |
* |
*/ |
public void setSearch(String search) { |
this.search = search; |
} |
/* |
* Localite en cours |
* |
*/ |
public void setLocation(String location) { |
this.location = location; |
} |
/* |
* Station en cours |
* |
*/ |
public void setStation(String station) { |
this.station = station; |
} |
/* |
* Date en cours |
* |
*/ |
public void setDate(String date) { |
this.date = date; |
} |
/* |
* Utilisateur en cours |
* |
*/ |
public void setUser(String user) { |
this.user = user; |
} |
public String getDate() { |
return date; |
} |
public String getLocation() { |
return location; |
} |
public String getSearch() { |
return search; |
} |
public String getStation() { |
return station; |
} |
public Grid getHeader() { |
return header; |
} |
public void displayFilter() { |
// Mise a jour boutton export feuille de calcul |
mediator.getActionPanel().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" |
+ user + "/" |
+ URL.encodeComponent(location) + "/" |
+ URL.encodeComponent(station)+ "/" |
+ URL.encodeComponent(search) + "/" |
+ date + |
"\">"+"Export tableur</a>"); |
// Mise a jour ligne de selection |
String com; |
if (location.compareTo("all")==0) { |
com="Toutes communes"; |
} |
else { |
if (location.compareTo("000null")==0) { |
com="Communes non renseignées"; |
} |
else { |
com="Commune de "+location; |
} |
} |
String dat; |
if (date.compareTo("all")==0) { |
dat=", toutes périodes"; |
} |
else { |
if (date.compareTo("00/00/0000")==0) { |
dat=", périodes non renseignées"; |
} |
else { |
dat=", le "+ date; |
} |
} |
String stat; |
if (station.compareTo("all")==0) { |
stat=", toutes stations"; |
} |
else { |
if (station.compareTo("000null")==0) { |
stat=", stations non renseignées"; |
} |
else { |
stat=", station "+ station; |
} |
} |
header.setHTML(0, 0, com + dat + stat ); |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.7 2007-09-17 19:25:34 ddelon |
* Documentation |
* |
*/ |
/trunk/src/org/tela_botanica/client/DateList.java |
---|
New file |
0,0 → 1,501 |
/* |
* Copyright 2006 Google Inc. |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
* use this file except in compliance with the License. You may obtain a copy of |
* the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
* License for the specific language governing permissions and limitations under |
* the License. |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
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.ui.Button; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.DockPanel; |
import com.google.gwt.user.client.ui.FlexTable; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Widget; |
/** |
* A tree displaying a set of email folders. |
*/ |
public class DateList extends Composite { |
// Barre de navigation |
private class NavBar extends Composite implements ClickListener { |
public final DockPanel bar = new DockPanel(); |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
status.setWordWrap(false); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(status); |
buttons.setCellHorizontalAlignment(status, |
HasHorizontalAlignment.ALIGN_RIGHT); |
buttons.setCellVerticalAlignment(status, |
HasVerticalAlignment.ALIGN_MIDDLE); |
buttons.setCellWidth(status, "100%"); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_DATE_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_DATE_COUNT; |
} else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_DATE_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} else { |
if (sender == gotoEnd) { |
gotoEnd(); |
} else { |
if (sender == gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
} |
private static final int VISIBLE_DATE_COUNT = 10; |
private static final String VALUE_UNKNOWN = "Inconnues"; |
private Grid header = new Grid(1, 2); |
private Grid selector = new Grid(1, 2); |
private FlexTable table = new FlexTable(); |
private VerticalPanel outer = new VerticalPanel(); |
private VerticalPanel inner = new VerticalPanel(); |
private int startIndex = 0; |
private String user; |
private String serviceBaseUrl = null; |
private String location = "all"; |
private String date = "all"; |
private NavBar navBar=null; |
private int count = 65000; |
// Tous selectionné |
private int selectedRow = -1; |
private Mediator mediator = null; |
public DateList(Mediator med) { |
mediator=med; |
mediator.registerDateList(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
navBar = new NavBar(); |
// Mise en forme du header |
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("date-ListHeader"); |
header.setWidget(0, 1,navBar); |
// header.getCellFormatter().setWidth(0, 0, "100%"); |
// Mise en forme de l'entree "Toutes localités" |
selector.setCellSpacing(0); |
selector.setCellPadding(0); |
selector.setWidth("100%"); |
selector.setHTML(0, 0, "Toutes"); |
selector.getCellFormatter().setWidth(0, 0, "100%"); |
// Hook up events. |
selector.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "date-SelectedRow"); |
mediator.onDateSelected("all"); |
date="all"; |
} |
}); |
selector.setStyleName("date-ListElement"); |
// Mise en forme du contenu |
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
table.setStyleName("date-ListElement"); |
outer.add(header); |
inner.add(selector); // Toutes localités |
inner.add(table); |
inner.setStyleName("date-List"); |
inner.setWidth("100%"); |
outer.setWidth("100%"); |
outer.add(inner); |
// Hook up events. |
table.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String adate=table.getText(row,cell); |
if (adate.compareTo(VALUE_UNKNOWN)!=0) { |
date=adate; |
mediator.onDateSelected(adate); |
} |
else { |
date="00/00/0000"; |
mediator.onDateSelected("00/00/0000"); |
} |
} |
}); |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "date-SelectedRow"); |
//updateCount(); |
// update() |
initWidget(outer); |
} |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
* |
*/ |
public void updateCount() { |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + URL.encodeComponent(location) , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
update(); |
} |
} |
}); |
} |
private void selectRow(int row) { |
styleRow(selectedRow, false); |
styleRow(row, true); |
selectedRow = row; |
} |
private void styleRow(int row, boolean selected) { |
if (row != -1) { |
selector.getRowFormatter().removeStyleName(0, "date-SelectedRow"); |
if (selected) |
table.getRowFormatter().addStyleName(row, "date-SelectedRow"); |
else |
if (row < table.getRowCount()) { |
table.getRowFormatter().removeStyleName(row, "date-SelectedRow"); |
} |
} |
} |
/** |
* |
* 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 |
* |
*/ |
public void update() { |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + URL.encodeComponent(location) + "/" |
+ startIndex + "/" + VISIBLE_DATE_COUNT, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
int arraySize = jsonArray.size(); |
for (i = 0; i < arraySize; ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
if (i>=table.getRowCount()) { |
row = table.insertRow(table.getRowCount()); |
} |
else { |
row = i; |
} |
// Lieu |
String adate=((JSONString)jsonArrayNested.get(0)).stringValue(); |
if (adate.compareTo("0000-00-00 00:00:00")!=0) { |
table.setText(row, 0,adate); |
} |
else { |
table.setText(row, 0,VALUE_UNKNOWN); |
} |
if ((adate.compareTo(date)==0) || ( date.compareTo("00/00/0000")==0) && adate.compareTo("0000-00-00 00:00:00")==0 ) { |
styleRow(row, true); |
} |
else { |
styleRow(row, false); |
} |
table.getFlexCellFormatter().setWidth(row, 0, "100%"); |
} |
} |
} |
if (date.compareTo("all")==0) { |
selector.getRowFormatter().addStyleName(0, "date-SelectedRow"); |
} |
// Suppression fin ancien affichage |
if (i<table.getRowCount()) { |
for (int j = table.getRowCount() -1 ; j >= i; j--) { |
table.removeRow(j); |
} |
} |
setStatusEnabled(); |
} |
}); |
} |
public void setLocation(String location) { |
this.location = location; |
} |
/* |
* Positionnement index de parcours (this.startIndex) pour affichage de la |
* dernière page |
* |
* @param |
* @return void |
*/ |
private void gotoEnd() { |
if ((count == 0) || (count % VISIBLE_DATE_COUNT) > 0) { |
startIndex = count - (count % VISIBLE_DATE_COUNT); |
} else { |
startIndex = count - VISIBLE_DATE_COUNT; |
} |
} |
/** |
* Affichage message d'attente et désactivation navigation |
* |
* @param |
* @return void |
*/ |
private void setStatusDisabled() { |
navBar.gotoFirst.setEnabled(false); |
navBar.gotoPrev.setEnabled(false); |
navBar.gotoNext.setEnabled(false); |
navBar.gotoEnd.setEnabled(false); |
setStatusText("Patientez ..."); |
} |
/** |
* Affichage numero de page et gestion de la navigation |
* |
*/ |
private void setStatusEnabled() { |
// Il y a forcemment un disabled avant d'arriver ici |
if (count > 0) { |
if (startIndex >= VISIBLE_DATE_COUNT) { // Au dela de la |
// premiere page |
navBar.gotoPrev.setEnabled(true); |
navBar.gotoFirst.setEnabled(true); |
if (startIndex < (count - VISIBLE_DATE_COUNT)) { // Pas la |
// derniere |
// page |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_DATE_COUNT) + " sur " + count ); |
} else { // Derniere page |
setStatusText((startIndex + 1) + " - " + count + " sur " + count ); |
} |
} else { // Premiere page |
if (count > VISIBLE_DATE_COUNT) { // Des pages derrieres |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_DATE_COUNT) + " sur " + count); |
} else { |
setStatusText((startIndex + 1) + " - " + count + " sur " + count); |
} |
} |
} |
else { // Pas d'inventaire, pas de navigation |
setStatusText("0 - 0 sur 0"); |
} |
} |
private void setStatusText(String text) { |
navBar.status.setText(text); |
} |
public void setUser(String user) { |
this.user = user; |
} |
public void setDate(String date) { |
this.date = date; |
} |
} |
/trunk/src/org/tela_botanica/client/NameAssistant.java |
---|
17,7 → 17,7 |
import org.tela_botanica.client.AutoCompleteAsyncTextBox; |
/** |
* Affiche une liste de nom pour selection. Son retournes le nom selectionne (gettext()) et un code associe (getvalue()). |
* Affiche une liste de nom pour selection. Son retourn�s le nom selectionn� (gettext()) et un code associ� (getvalue()). |
*/ |
public class NameAssistant extends Composite implements EventListener, ResponseTextHandler { |
/trunk/src/org/tela_botanica/client/LeftPanel.java |
---|
New file |
0,0 → 1,66 |
/** |
David Delon david.delon@clapas.net 2007 |
*/ |
/* |
* LeftPanel.java : filtrage des releves (par communes, lieu-dit, dates ....) |
* |
* |
* 1: Le programme initialise les filtres communes, lieu-dit et dates) |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.StackPanel; |
import org.tela_botanica.client.LocationList; |
/** |
*/ |
public class LeftPanel extends Composite { |
private LocationList locationList = null; |
private DateList dateList = null; |
private StationList stationList = null; |
private Mediator mediator=null; |
public LeftPanel(Mediator med) { |
mediator=med; |
mediator.registerLeftPanel(this); |
dateList = new DateList(mediator); |
locationList = new LocationList(mediator); |
stationList = new StationList(mediator); |
dateList.setStyleName("dateList"); |
locationList.setStyleName("locationList"); |
locationList.setStyleName("stationList"); |
StackPanel outer = new StackPanel(); |
// Create the groups within the stack panel. |
outer.add(locationList, "<b>Localités</b>", true); |
outer.add(stationList,"<b>Stations</b>",true); |
outer.add(dateList, "<b>Dates</b>", true); |
outer.showStack(0); |
initWidget(outer); |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* |
*/ |
/trunk/src/org/tela_botanica/client/InventoryItem.java |
---|
1,13 → 1,5 |
package org.tela_botanica.client; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
public class InventoryItem { |
// TODO : Singleton ? |
21,23 → 13,15 |
private String comment=null; |
private String ordre=null; |
private Mediator mediator = null; |
private String serviceBaseUrl = null; |
// Constructeur |
// Constructeur sur saisie |
public InventoryItem(Mediator med) { |
public InventoryItem() { |
mediator=med; |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
} |
67,202 → 51,44 |
} |
public boolean isValid() { |
// TODO : controle date |
if (name.compareTo("")==0) { |
return false; |
public String getLocation() { |
return location; |
} |
else { |
return true; |
} |
public String getLocation_id() { |
return location_id; |
} |
/** |
* Lancement de la creation d'une ligne d'inventaire (appele par Mediator.onAddInventoryItem()) |
* |
*/ |
public void addelement() { |
if (isValid()) { |
// Creation d'un nom faisant parti du referentiel : recherche du nom valide correspondant |
if (nomenclaturalNumber !=null) { |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + nomenclaturalNumber, |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, |
// Famille |
addElement(name, nomenclaturalNumber, |
Util.toCelString(((JSONString) jsonArray.get(0)) |
.toString()), |
((JSONString) jsonArray.get(1)) |
.stringValue(), |
((JSONString) jsonArray.get(2)) |
.stringValue(), |
Util.toCelString(((JSONString) jsonArray.get(3)) |
.toString()), |
location,location_id,date,milieu,comment); |
public String getName() { |
return name; |
} |
} |
}); |
} |
// Saisie libre |
else { |
addElement(name, " ", " ", " ", " ", " ",location,location_id,date,milieu,comment); |
} |
public String getNomenclaturalNumber() { |
return nomenclaturalNumber; |
} |
else { |
// TODO : message d'erreur |
return; |
} |
} |
/** |
* Ajoute effectif d'un element a l'inventaire (appel interne) |
* |
* @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 |
*/ |
private void addElement(String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String milieu, String comment) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant=" |
+ mediator.getUser() + "&nom_sel=" + URL.encodeComponent(nom_sel) + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + URL.encodeComponent(nom_ret) + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + URL.encodeComponent(famille) + "&location=" + URL.encodeComponent(loc) + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ URL.encodeComponent(milieu) + "&commentaire="+ URL.encodeComponent(comment), |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
mediator.onInventoryUpdated(location); |
public String getComment() { |
return comment; |
} |
}); |
} |
/** |
* Lancement de la mise a jour d'une ligne d'inventaire (appele par Mediator.onModifyInventoryItem()) |
* |
*/ |
public void updateElement() { |
if (isValid()) { |
// Modification d'un nom faisant parti du referentiel : recherche du nom valide correspondant |
if (nomenclaturalNumber !=null) { |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + nomenclaturalNumber, |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, Famille |
updateElement(ordre,name, nomenclaturalNumber, |
Util.toCelString(((JSONString) jsonArray.get(0)) |
.toString()), |
((JSONString) jsonArray.get(1)) |
.stringValue(), |
((JSONString) jsonArray.get(2)) |
.stringValue(), |
Util.toCelString(((JSONString) jsonArray.get(3)) |
.toString()), |
location,location_id,date,milieu,comment); |
public String getMilieu() { |
return milieu; |
} |
} |
}); |
} |
// Modification d'un nom ne faisant pas parti du referentiel (saisie libre) |
else { |
updateElement(ordre,name, " ", " ", " ", " ", " ",location,location_id,date,milieu,comment); |
} |
public String getDate() { |
return date; |
} |
else { |
// TODO : message d'erreur |
return; |
} |
} |
/** |
* Modification effective d'un element de l'inventaire (appel interne) |
* |
* @param ordre : numero d'ordre |
* @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 |
*/ |
private void updateElement(String ordre, String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String milieu, String comment) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + mediator.getUser() + "/" +ordre + "/", |
"&nom_sel=" + URL.encodeComponent(nom_sel) + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + URL.encodeComponent(nom_ret) + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + URL.encodeComponent(famille) + "&location=" + URL.encodeComponent(loc) + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ URL.encodeComponent(milieu) + "&commentaire="+ URL.encodeComponent(comment), |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
mediator.onInventoryUpdated(location); |
public String getOrdre() { |
return ordre; |
} |
}); |
} |
} |
/trunk/src/org/tela_botanica/client/StationList.java |
---|
New file |
0,0 → 1,467 |
/* |
* Copyright 2006 Google Inc. |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
* use this file except in compliance with the License. You may obtain a copy of |
* the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
* License for the specific language governing permissions and limitations under |
* the License. |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
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.ui.Button; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.FlexTable; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Widget; |
/** |
* A tree displaying a set of email folders. |
*/ |
public class StationList extends Composite { |
// Debut Barre de navigation |
private class NavBar extends Composite implements ClickListener { |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
HorizontalPanel bar = new HorizontalPanel(); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
bar.add(status); |
bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT); |
bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE); |
bar.setCellWidth(status, "100%"); |
bar.add(gotoFirst); |
bar.add(gotoPrev); |
bar.add(gotoNext); |
bar.add(gotoEnd); |
initWidget(bar); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_STATION_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_STATION_COUNT; |
} else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_STATION_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} else { |
if (sender == gotoEnd) { |
gotoEnd(); |
} else { |
if (sender == gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
} |
// Fin Barre de navigation |
private static final int VISIBLE_STATION_COUNT = 10; |
private static final String VALUE_UNKNOWN = "Inconnues"; |
private Grid header = new Grid(1, 2); |
private Grid selector = new Grid(1, 2); |
private FlexTable table = new FlexTable(); |
private VerticalPanel outer = new VerticalPanel(); |
private VerticalPanel inner = new VerticalPanel(); |
private int startIndex = 0; |
private String user; |
private String serviceBaseUrl = null; |
private String location = "all"; |
private String station = "all"; |
private NavBar navBar=null; |
private int count = 65000; |
// Tous selectionn� |
private int selectedRow = -1; |
private Mediator mediator = null; |
public StationList(Mediator med) { |
mediator=med; |
mediator.registerStationList(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
navBar = new NavBar(); |
// Mise en forme du header |
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("station-ListHeader"); |
header.setWidget(0, 1,navBar); |
selector.setCellSpacing(0); |
selector.setCellPadding(0); |
selector.setWidth("100%"); |
selector.setHTML(0, 0, "Toutes"); |
selector.getCellFormatter().setWidth(0, 0, "100%"); |
// Hook up events. |
selector.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "station-SelectedRow"); |
mediator.onStationSelected("all"); |
station="all"; |
} |
}); |
selector.setStyleName("station-ListElement"); |
// Mise en forme du contenu |
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
table.setStyleName("station-ListElement"); |
outer.add(header); |
inner.add(selector); // Toutes station |
inner.add(table); |
inner.setStyleName("station-List"); |
inner.setWidth("100%"); |
outer.setWidth("100%"); |
outer.add(inner); |
// Hook up events. |
table.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String astation=table.getText(row,cell); |
if (astation.compareTo(VALUE_UNKNOWN)!=0) { |
station=astation; |
mediator.onStationSelected(astation); |
} |
else { |
station="000null"; |
mediator.onStationSelected("000null"); |
} |
} |
}); |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "station-SelectedRow"); |
initWidget(outer); |
} |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
* |
*/ |
public void updateCount() { |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + URL.encodeComponent(location) , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
update(); |
} |
} |
}); |
} |
private void selectRow(int row) { |
styleRow(selectedRow, false); |
styleRow(row, true); |
selectedRow = row; |
} |
private void styleRow(int row, boolean selected) { |
if (row != -1) { |
selector.getRowFormatter().removeStyleName(0, "station-SelectedRow"); |
if (selected) |
table.getRowFormatter().addStyleName(row, "station-SelectedRow"); |
else |
if (row < table.getRowCount()) { |
table.getRowFormatter().removeStyleName(row, "station-SelectedRow"); |
} |
} |
} |
/** |
* |
* 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 |
* |
*/ |
public void update() { |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + URL.encodeComponent(location) + "/" |
+ startIndex + "/" + VISIBLE_STATION_COUNT, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
int arraySize = jsonArray.size(); |
for (i = 0; i < arraySize; ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
if (i>=table.getRowCount()) { |
row = table.insertRow(table.getRowCount()); |
} |
else { |
row = i; |
} |
String astation=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString()); |
if (astation.compareTo("000null")!=0) { |
table.setText(row, 0,astation); |
} |
else { |
table.setText(row, 0,VALUE_UNKNOWN); |
} |
if (astation.compareTo(station)==0) { |
styleRow(row, true); |
} |
else { |
styleRow(row, false); |
} |
table.getFlexCellFormatter().setWidth(row, 0, "100%"); |
} |
} |
} |
if (station.compareTo("all")==0) { |
selector.getRowFormatter().addStyleName(0, "station-SelectedRow"); |
} |
// Suppression fin ancien affichage |
if (i<table.getRowCount()) { |
for (int j = table.getRowCount() -1 ; j >= i; j--) { |
table.removeRow(j); |
} |
} |
setStatusEnabled(); |
} |
}); |
} |
public void setLocation(String location) { |
this.location = location; |
} |
/* |
* Positionnement index de parcours (this.startIndex) pour affichage de la |
* derni�re page |
* |
* @param |
* @return void |
*/ |
private void gotoEnd() { |
if ((count == 0) || (count % VISIBLE_STATION_COUNT) > 0) { |
startIndex = count - (count % VISIBLE_STATION_COUNT); |
} else { |
startIndex = count - VISIBLE_STATION_COUNT; |
} |
} |
/** |
* Affichage message d'attente et d�sactivation navigation |
* |
* @param |
* @return void |
*/ |
private void setStatusDisabled() { |
navBar.gotoFirst.setEnabled(false); |
navBar.gotoPrev.setEnabled(false); |
navBar.gotoNext.setEnabled(false); |
navBar.gotoEnd.setEnabled(false); |
navBar.status.setText("Patientez ..."); |
} |
/** |
* Affichage numero de page et gestion de la navigation |
* |
*/ |
private void setStatusEnabled() { |
// Il y a forcemment un disabled avant d'arriver ici |
if (count > 0) { |
if (startIndex >= VISIBLE_STATION_COUNT) { // Au dela de la |
// premiere page |
navBar.gotoPrev.setEnabled(true); |
navBar.gotoFirst.setEnabled(true); |
if (startIndex < (count - VISIBLE_STATION_COUNT)) { // Pas la |
// derniere |
// page |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
navBar.status.setText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_STATION_COUNT) + " sur " + count ); |
} else { // Derniere page |
navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count ); |
} |
} else { // Premiere page |
if (count > VISIBLE_STATION_COUNT) { // Des pages derrieres |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
navBar.status.setText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_STATION_COUNT) + " sur " + count); |
} else { |
navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count); |
} |
} |
} |
else { // Pas d'inventaire, pas de navigation |
navBar.status.setText("0 - 0 sur 0"); |
} |
} |
public void setUser(String user) { |
this.user = user; |
} |
public void setStation(String station) { |
this.station = station; |
} |
} |
/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBox.java |
---|
22,7 → 22,6 |
// TODO : traiter latence (augmenter en fonction rapidit� saisie + texte vide) |
// TODO : traitement espace apres l'espece (%20) |
// TODO : Utiliser Suggestbox et les Associating Data Transfer Objects (DTOs) with Suggestion Objects |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
29,6 → 28,7 |
import com.google.gwt.user.client.ui.KeyboardListener; |
import com.google.gwt.user.client.ui.ListBox; |
import com.google.gwt.user.client.ui.PopupPanel; |
import com.google.gwt.user.client.ui.RootPanel; |
import com.google.gwt.user.client.ui.TextBox; |
import com.google.gwt.user.client.ui.Widget; |
import com.google.gwt.user.client.DOM; |
58,6 → 58,7 |
} |
}; |
protected Vector items = new Vector(); |
protected boolean popupAdded = false; |
protected boolean visible = false; |
/** |
281,15 → 282,17 |
choices.setSelectedIndex(0); |
choices.setVisibleItemCount(items.size()); |
if(!popupAdded) |
{ |
RootPanel.get().add(choicesPopup); |
popupAdded = true; |
} |
choicesPopup.show(); |
visible = true; |
choicesPopup.setPopupPosition(this.getAbsoluteLeft(), this.getAbsoluteTop() + this.getOffsetHeight()); |
choicesPopup.setPopupPosition(this.getAbsoluteLeft(), this.getAbsoluteTop() + this.getOffsetHeight()); |
choicesPopup.setPopupPosition(this.getAbsoluteLeft(), |
this.getAbsoluteTop() + this.getOffsetHeight()); |
choicesPopup.setWidth(this.getOffsetWidth() + "px"); |
choices.setWidth(this.getOffsetWidth() + "px"); |
choicesPopup.show(); |
// } |
} else { |
/trunk/src/org/tela_botanica/client/InfoPopup.java |
---|
95,8 → 95,9 |
public void setImageTop(String url) { |
if (url.compareTo("null")!=0) { |
// setPopupPosition(3*(Window.getClientWidth()/4), mediator.getInventoryItemList().getAbsoluteTop()+50); |
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +15); |
setPopupPosition(mediator.getLeftPanel().getAbsoluteLeft()+10, mediator.getLeftPanel().getAbsoluteTop() + (mediator.getLeftPanel().getOffsetHeight()/2)+50); |
show(); |
imageTop.setUrl(url); |
} |
109,7 → 110,8 |
public void setImageBottom(String url) { |
if (url.compareTo("null")!=0) { |
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +15); |
// setPopupPosition(3*(Window.getClientWidth()/4), mediator.getInventoryItemList().getAbsoluteTop()+50); |
setPopupPosition(mediator.getLeftPanel().getAbsoluteLeft()+10, mediator.getLeftPanel().getAbsoluteTop() + (mediator.getLeftPanel().getOffsetHeight()/2) + 50); |
show(); |
imageBottom.setUrl(url); |
} |
/trunk/src/org/tela_botanica/client/EntryPanel.java |
---|
New file |
0,0 → 1,507 |
/** |
David Delon david.delon@clapas.net 2007 |
*/ |
/* |
* EntryPanel.java (Composite de Panel) |
* |
* Cas d'utilisation : |
* Saisie assistee (completion nom et completion commune) de releves. |
* L'identification n'est pas obligatoire |
* |
* 1 : L'utilisateur saisit a minima un nom de plante |
* 1: Le nom de plante provient d'une application externe : il est deduit du nuremo nomenclatural transmis en historique |
* 2 : Le programme assiste la saisie de nom de plante ou de localite par interrogation du systeme distant |
* 3 : L'utilisateur choisi le type de mise (ajout ou modification) |
* 3 : L'utilisateur valide sa saisie |
* 4 : Le programme transmet au systeme distant la nouvelle saisie pour l'identifiant en cours |
* 5 : Le programme transmet au systeme local un evenement annoncant une nouvelle saisie |
* |
* |
* Affichage detail d'un observation |
* 1 : Le programme affiche les donnees d'inventaire pour l'identifiant enregistre et pour le numero d'ordre transmis |
* |
*/ |
package org.tela_botanica.client; |
import java.util.Date; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.History; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ChangeListener; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.KeyboardListener; |
import com.google.gwt.user.client.ui.PopupPanel; |
import com.google.gwt.user.client.ui.TextBox; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Widget; |
public class EntryPanel extends Composite { |
private NameAssistant nameAssistant = null; |
private LocationAssistant locationAssistant = null; |
private TextBox date = new TextBox(); |
private TextBox lieudit = new TextBox(); |
private TextBox milieu = new TextBox(); |
private TextBox comment = new TextBox(); |
private Button dateSelector = new Button("..."); |
private Button validButton = new Button("Ajouter"); |
boolean visible=false; |
private Mediator mediator=null; |
private String user= null; |
private String ordre =null; |
private CalendarWidget calendar = null; // Lazy instantiation |
private PopupPanel choicesPopup = null; // Lazy instantiation |
public EntryPanel(final Mediator med) { |
Grid observation = new Grid(4,4); |
// Formatage affichage |
for (int i=0; i<4;i++) { |
observation.getCellFormatter().setWidth(i, 0, "3%"); |
observation.getCellFormatter().setWidth(i, 1, "47%"); |
observation.getCellFormatter().setWidth(i, 2, "3%"); |
observation.getCellFormatter().setWidth(i, 3, "47%"); |
} |
mediator=med; |
user=mediator.getUser(); |
// Declaration des elements du dialogue de saisie aupres du mediator |
mediator.registerEntryPanel(this); |
mediator.registerDate(date); |
mediator.registerComment(comment); |
mediator.registerMilieu(milieu); |
mediator.registerLieudit(lieudit); |
VerticalPanel outer = new VerticalPanel(); |
// Name assistant et location assistant : widget auto-completion sur nom scientifique ou commune |
nameAssistant = new NameAssistant(mediator); |
locationAssistant = new LocationAssistant(mediator); |
// Saisie Commune |
observation.setHTML(2,0,"Commune: "); |
observation.setWidget(2,1,locationAssistant); |
locationAssistant.setWidth("100%"); |
// Saisie lieu-dit |
observation.setHTML(2,2,"Lieu-dit: "); |
observation.setWidget(2,3,lieudit); |
lieudit.setWidth("100%"); |
lieudit.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
onValidateTextBox(lieudit); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { } |
public void onKeyPress(Widget arg0, char arg1, int arg2) { } |
} |
); |
// Saisie (milieu) |
observation.setHTML(3,0,"Milieu: "); |
observation.setWidget(3,1,milieu); |
milieu.setWidth("100%"); |
// Validation par entree sur cette zone de texte |
milieu.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
onValidateTextBox(milieu); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { } |
public void onKeyPress(Widget arg0, char arg1, int arg2) { } |
} |
); |
// Selecteur de Date |
// Releve |
dateSelector.addClickListener(new ClickListener () { |
public void onClick(Widget w) { |
if (visible) { |
visible=false; |
choicesPopup.hide(); |
} |
else { |
visible=true; |
if (calendar==null) { // Lazy instantiation |
calendar = new CalendarWidget(); |
choicesPopup = new PopupPanel(true); |
choicesPopup.add(calendar); |
calendar.addChangeListener(new ChangeListener() { |
public void onChange(Widget sender) { |
Date dateSelected=calendar.getDate(); |
date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900)); |
visible=false; |
choicesPopup.hide(); |
} |
}); |
} |
choicesPopup.show(); |
choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(), |
dateSelector.getAbsoluteTop() - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight()); |
choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px"); |
} |
} |
}); |
// Saisie Espece |
observation.setHTML(0,0,"Espèce: "); |
observation.setWidget(0,1,nameAssistant); |
nameAssistant.setWidth("100%"); |
observation.setHTML(0,2,"Date: "); |
HorizontalPanel datePanel = new HorizontalPanel(); |
datePanel.add(date); |
datePanel.add(dateSelector); |
observation.setWidget(0,3,datePanel); |
// Saisie date |
// Validation par entree sur cette zone de texte |
date.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
onValidateTextBox(date); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { } |
public void onKeyPress(Widget arg0, char arg1, int arg2) { } |
} |
); |
// Saisie Commentaire |
observation.setHTML(1,0,"Notes: "); |
observation.setWidget(1,1,comment); |
comment.setWidth("100%"); |
// Validation par entree sur cette zone de texte |
comment.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
onValidateTextBox(comment); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { } |
public void onKeyPress(Widget arg0, char arg1, int arg2) { } |
} |
); |
// Validation par click sur bouton valider |
validButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget w) { |
// Numero ordre vide : ajout d'une observation |
if (ordre==null) { |
mediator.onAddInventoryItem(); |
} |
else { |
mediator.onModifyInventoryItem(ordre); |
ordre=null; |
} |
} |
} |
); |
HorizontalPanel actionPanel= new HorizontalPanel(); |
actionPanel.add(validButton); |
observation.setWidth("100%"); |
outer.add(observation); |
outer.setCellWidth(observation, "100%"); |
outer.setSpacing(10); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); |
outer.add(actionPanel); |
// Initialisation si provenance d'un lien |
if (History.getToken().length()>0) { |
final String anum=History.getToken(); |
HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Name/" + anum, |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
String aname = Util.toCelString(((JSONString) jsonArray.get(0)).toString()); |
// Nom |
if (aname.compareTo("null")!=0) { |
nameAssistant.setText(aname); |
// Numero nomenclatural |
nameAssistant.setValue(anum); |
} |
} |
} |
}); |
} |
initWidget(outer); |
} |
/* |
* Numero d'ordre du releve affiche + mise à jour bouton |
* |
*/ |
public void setOrdre(String ordre) { |
this.ordre = ordre; |
if (ordre==null) { |
this.validButton.setText("Ajouter"); |
} |
else { |
this.validButton.setText("Modifier"); |
} |
} |
/* |
* Numero d'ordre du releve affiche |
* |
*/ |
public String getOrdre() { |
return this.ordre; |
} |
// Validation par entree sur cette zone de texte |
private void onValidateTextBox(TextBox textbox) { |
if (ordre==null) { |
// Numero ordre vide : ajout d'une observation |
mediator.onAddInventoryItem(); |
textbox.setText(""); |
} |
else { |
mediator.onModifyInventoryItem(ordre); |
ordre=null; |
} |
} |
/** |
* Mise a jour de l'affichage a partir de donnees deja saisie |
* |
*/ |
public void update() { |
HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom saisi |
nameAssistant.setText(Util.toCelString(((JSONString) jsonArray.get(0)).toString())); |
// Numero nomenclatural |
String ann=((JSONString) jsonArray .get(3)).stringValue(); |
if (ann.compareTo("0")!=0) { |
nameAssistant.setValue(ann); |
mediator.getInfoPopup().setImageUrl(ann); |
} |
else { |
nameAssistant.setValue(null); |
} |
// Commune |
String aloc=Util.toCelString(((JSONString) jsonArray .get(6)).toString()); |
if (aloc.compareTo("000null")!=0) { |
locationAssistant.setText(aloc); |
} |
else { |
locationAssistant.setText(""); |
} |
String adate=((JSONString) jsonArray .get(8)).stringValue(); |
// Date |
if (adate.compareTo("0000-00-00 00:00:00")!=0) { |
date.setText(adate); |
} |
else { |
date.setText(""); |
} |
String astation=Util.toCelString(((JSONString) jsonArray .get(9)).toString()); |
// Station |
if (astation.compareTo("000null")!=0) { |
milieu.setText(astation); |
} |
else { |
milieu.setText(""); |
} |
String acomment=Util.toCelString(((JSONString) jsonArray .get(10)).toString()); |
// Notes |
if (acomment.compareTo("null")!=0) { |
comment.setText(acomment); |
} |
else { |
comment.setText(""); |
} |
} |
} |
}); |
} |
public void setUser(String user) { |
this.user = user; |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.7 2007-09-17 19:25:34 ddelon |
* Documentation |
* |
* Revision 1.6 2007-06-06 13:29:30 ddelon |
* v0.09 |
* |
* Revision 1.5 2007-05-22 14:27:08 ddelon |
* reglage modification |
* |
* Revision 1.4 2007-05-21 21:01:35 ddelon |
* Modification comportement boutons |
* |
* |
*/ |
/trunk/src/org/tela_botanica/client/TopPanel.java |
---|
New file |
0,0 → 1,140 |
/** |
David Delon david.delon@clapas.net 2007 |
*/ |
/* |
* TopPanel.java : affichage information portant sur le statut de la connexion utilisateur |
* |
* |
* 1: Le programme affiche le statut connecte si l'utilisateur s'est connecte precedemment, sinon s'affiche le statut deconnecte |
* 2: Le programme arme les actions liees a la connection ou a la deconnection |
* - Connection : affichage de la boite de connexion |
* - Deconnexion : appel du service de deconnexion, et appel de la re-initialisation de l'affichage pour le nouvel identifiant utilisateur obtenu (identifiant de session) |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONBoolean; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
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.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.ui.Widget; |
public class TopPanel extends Composite { |
private Mediator mediator=null; |
private String user =null; |
private Label signLabel = new Label() ; |
private String serviceBaseUrl = null; |
public TopPanel(final Mediator med) { |
mediator=med; |
mediator.registerTopPanel(this); |
user=mediator.getUser(); |
signLabel.setStyleName("selection_label"); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
if (!mediator.getConnected()) { |
signLabel.setText("Connexion"); |
} |
else { |
signLabel.setText(user+ " (deconnexion)"); |
} |
HorizontalPanel outer = new HorizontalPanel(); |
HorizontalPanel inner = new HorizontalPanel(); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); |
inner.add(signLabel); |
inner.add(new HTML("<b>Carnet en ligne</b>")); |
inner.setSpacing(3); |
outer.add(inner); |
signLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// Non connecte ? Lien vers boite de connection |
if (!mediator.getConnected()) { |
LoginDialog loginDialog = new LoginDialog(med); |
// Position it roughly in the middle of the screen. |
int left = (Window.getClientWidth() - 512) / 2; |
int top = (Window.getClientHeight() - 256) / 2; |
loginDialog.setPopupPosition(left, top); |
loginDialog.show(); |
} |
else { |
// Deja Connecte : lancement deconnexion sur selection de l'action |
HTTPRequest.asyncGet(serviceBaseUrl + "/User/" + user , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
user = Util.toCelString(((JSONString) jsonArray.get(0)).toString()); // Identifiant utilisateur : identifant de session |
mediator.setConnected(((JSONBoolean) jsonArray.get(1)).booleanValue()); |
} |
if (!mediator.getConnected()) { // La deconnexion a ete accepte : |
mediator.onLogoff(user); |
} |
} |
}); |
} |
} |
} |
); |
initWidget(outer); |
} |
public Label getSignLabel() { |
return signLabel; |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.5 2007-09-17 19:25:34 ddelon |
* Documentation |
* |
* |
*/ |
/trunk/src/org/tela_botanica/client/SearchPanel.java |
---|
35,7 → 35,7 |
public SearchPanel(final Mediator med) { |
HorizontalPanel panel=new HorizontalPanel(); |
HorizontalPanel outer=new HorizontalPanel(); |
mediator=med; |
79,14 → 79,14 |
panel.setSpacing(5); |
panel.add(search); |
outer.setSpacing(5); |
outer.add(search); |
panel.add(searchButton); |
outer.add(searchButton); |
initWidget(panel); |
initWidget(outer); |
} |
96,9 → 96,6 |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.4 2007-12-22 14:48:53 ddelon |
* Documentation et refactorisation |
* |
* Revision 1.5 2007-09-17 19:25:34 ddelon |
* Documentation |
* |
/trunk/src/org/tela_botanica/client/ActionPanel.java |
---|
New file |
0,0 → 1,150 |
/** |
David Delon david.delon@clapas.net 2007 |
*/ |
/* |
* ActionPanel.java : affichage actions sur releves saisie ou affiches (suppression, export etc...) |
* |
* TODO : appel de fonction du mediator, au lieu de passer par les methode de la classe de gestion d'affichage des releves (voir les TODO dans le |
* corps de ce programme) |
* |
* 1: Le programme affiche les boutons commandant les actions sur les releves et arme les actions correspondantes |
* - Transmission d'elements (vers tela botanica) |
* - Suppression d'elements selectionnes |
* - Export vers tableur |
* - Selection / Deselection des releves affiches |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.ui.Widget; |
public class ActionPanel extends Composite { |
private Mediator mediator=null; |
private HTML exportButton=null; |
public ActionPanel(final Mediator med) { |
mediator=med; |
mediator.registerActionPanel(this); |
HorizontalPanel outer = new HorizontalPanel(); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.setSpacing(3); |
// Transmission d'elements |
HTML transButton=new HTML("Transmettre Tela Botanica"); |
transButton.setStyleName("html_button_long"); |
transButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// TODO : une action dans le mediator |
if (mediator.getConnected()) { |
mediator.getInventoryItemList().transmitElement(); |
} |
else { |
Window.alert("Identifiez-vous pour transmettre"); |
} |
} |
} |
); |
buttons.add(transButton); |
// Suppression d'elements |
HTML delButton=new HTML("Suppression"); |
delButton.setStyleName("html_button"); |
delButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// TODO : une action dans le mediator |
mediator.getInventoryItemList().deleteElement(); |
} |
} |
); |
buttons.add(delButton); |
// Export (renseigne lors de l'affichage des releves ) |
exportButton=new HTML(); |
buttons.add(exportButton); |
exportButton.setStyleName("html_button"); |
// Selections de l'affichage |
HorizontalPanel selections = new HorizontalPanel(); |
selections.setSpacing(3); |
selections.add(new HTML("Sélection : ")); |
Label allLabel = new Label("Tous"); |
Label separatorLabel = new Label(","); |
Label noneLabel = new Label("Aucun"); |
allLabel.setStyleName("selection_label"); |
noneLabel.setStyleName("selection_label"); |
selections.add(allLabel); |
allLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// TODO : une action dans le mediator |
mediator.getInventoryItemList().selectAll(); |
} |
} |
); |
selections.add(separatorLabel); |
selections.add(noneLabel); |
noneLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// TODO : une action dans le mediator |
mediator.getInventoryItemList().deselectAll(); |
} |
} |
); |
outer.add(buttons); |
outer.add(selections); |
initWidget(outer); |
this.setStyleName("action-Panel"); |
} |
public HTML getExportButton() { |
return exportButton; |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.5 2007-09-17 19:25:34 ddelon |
* Documentation |
* |
* |
*/ |
/trunk/src/org/tela_botanica/client/CenterPanel.java |
---|
New file |
0,0 → 1,50 |
/** |
David Delon david.delon@clapas.net 2007 |
*/ |
/* |
* CenterPanel.java (Container de liste de releve) |
* |
* Cas d'utilisation : |
* |
* 1: Le programme initialise la classe controlant l'affichage de la liste des objets |
* |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import org.tela_botanica.client.InventoryItemList; |
public class CenterPanel extends Composite { |
private InventoryItemList inventoryItemList = null; |
public CenterPanel(Mediator mediator) { |
inventoryItemList = new InventoryItemList(mediator); |
inventoryItemList.setStyleName("inventoryItemList"); |
VerticalPanel outer = new VerticalPanel(); |
outer.add(inventoryItemList); |
inventoryItemList.setWidth("100%"); |
initWidget(outer); |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* |
*/ |
/trunk/src/org/tela_botanica/client/LocationAssistant.java |
---|
17,8 → 17,8 |
import org.tela_botanica.client.AutoCompleteAsyncTextBox; |
/** |
* Affiche une liste de localite qui peuvent etre selectionnees, retourne la valeur de la localite selectionne et une code associe |
* (gettext et getvalue pour le code associe) |
* Affiche une liste de localite qui peuvent être selectionnées, retourne la valeur de la localité selectionne et une code associé |
* (gettext et getvalue pour le code associé) |
* Utilise un assistant de saisie asynchrone. |
*/ |
/trunk/src/org/tela_botanica/client/Cel.java |
---|
18,8 → 18,14 |
package org.tela_botanica.client; |
import com.google.gwt.core.client.EntryPoint; |
import com.google.gwt.user.client.Command; |
import com.google.gwt.user.client.DeferredCommand; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.WindowResizeListener; |
import com.google.gwt.user.client.ui.DockPanel; |
import com.google.gwt.user.client.ui.RootPanel; |
import com.google.gwt.user.client.ui.VerticalPanel; |
26,22 → 32,127 |
/** |
* Entry point classes define <code>onModuleLoad()</code>. |
*/ |
public class Cel implements EntryPoint { |
public class Cel implements EntryPoint, WindowResizeListener { |
private TopPanel topPanel = null; // Identifiant de connexion et titre |
private CenterPanel centerPanel = null; // Liste de releves |
private LeftPanel leftPanel = null; // Filtres sur liste de releves |
private EntryPanel entryPanel = null; // Saisie d'un releve |
private ActionPanel actionPanel = null; // Action sur les relevés saisis |
private SearchPanel searchPanel = null; // Recherche dans les relevés saisis |
private VerticalPanel rightPanel = null; // Container panneau précedents (sauf left et popup) |
private Mediator mediator = null; // Intermediaire entre les differents classes |
/** |
* Point d'entree : recherche du pres-requis : information de connection. |
*/ |
public void onModuleLoad() { |
new Mediator(); |
mediator= new Mediator(); |
mediator.registerCel(this); // Declaration point d'entree aupres de la classe intercesseur |
mediator.initUser(); // Initialisation environnement utilisateur (Cette methode appelle la methode initAsync() suivante) |
} |
/** |
* Fin de l'initialisation |
* |
*/ |
public void initAsync() { |
centerPanel = new CenterPanel(mediator); // Liste de releves |
topPanel = new TopPanel(mediator); // Identifiant de connection |
leftPanel = new LeftPanel(mediator); // Filte de liste de releves |
entryPanel = new EntryPanel(mediator); // Formulaire de saisie |
actionPanel = new ActionPanel(mediator); // Action sur releves saisis |
searchPanel = new SearchPanel(mediator); // Recherche dans releves |
rightPanel = new VerticalPanel(); // Container des panneaux precedents |
entryPanel.setStyleName("item-Input"); |
// Assemblage des differents panneaux |
rightPanel.add(searchPanel); |
rightPanel.add(entryPanel); |
rightPanel.add(centerPanel); |
rightPanel.add(actionPanel); |
rightPanel.setWidth("100%"); |
centerPanel.setWidth("100%"); |
entryPanel.setWidth("100%"); |
topPanel.setWidth("100%"); |
rightPanel.setSpacing(2); |
// Disposition générale : |
DockPanel outer = new DockPanel(); |
outer.add(topPanel, DockPanel.NORTH); |
outer.add(rightPanel, DockPanel.CENTER); |
outer.add(leftPanel, DockPanel.WEST); |
outer.setWidth("100%"); |
outer.setSpacing(2); |
outer.setCellWidth(rightPanel, "100%"); |
// Window.enableScrolling(false); |
Window.setMargin("0px"); |
// Initialisation des differents contenus ... |
mediator.onInit(); |
RootPanel.get().add(outer); |
// Call the window resized handler to get the initial sizes setup. Doing |
// this in a deferred command causes it to occur after all widgets' sizes |
// have been computed by the browser. |
DeferredCommand.add(new Command() { |
public void execute() { |
onWindowResized(Window.getClientWidth(), Window.getClientHeight()); |
} |
}); |
} |
public void onWindowResized(int width, int height) { |
// Adjust the shortcut panel and detail area to take up the available room |
// in the window. |
int shortcutHeight = height - leftPanel.getAbsoluteTop() - 8; |
if (shortcutHeight < 1) |
shortcutHeight = 1; |
leftPanel.setHeight("" + shortcutHeight); |
} |
} |
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.10 2007-09-17 19:25:34 ddelon |
* Documentation |
* |
* |
*/ |