Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 27 → Rev 28

/trunk/src/org/tela_botanica/client/ActionPanel.java
File deleted
\ No newline at end of file
/trunk/src/org/tela_botanica/client/CenterPanel.java
File deleted
/trunk/src/org/tela_botanica/client/LocationList.java
File deleted
/trunk/src/org/tela_botanica/client/InventoryItemList.java
File deleted
\ No newline at end of file
/trunk/src/org/tela_botanica/client/DateList.java
File deleted
/trunk/src/org/tela_botanica/client/LeftPanel.java
File deleted
/trunk/src/org/tela_botanica/client/StationList.java
File deleted
/trunk/src/org/tela_botanica/client/EntryPanel.java
File deleted
/trunk/src/org/tela_botanica/client/TopPanel.java
File deleted
/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 être selectionnées, retourne la valeur de la localité selectionne et une code associé
* (gettext et getvalue pour le code associé)
* 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)
* Utilise un assistant de saisie asynchrone.
*/
 
/trunk/src/org/tela_botanica/client/DateFilterPanel.java
New file
0,0 → 1,479
/*
* 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.Label;
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;
 
public class DateFilterPanel 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 Label status = new Label();
 
public NavBar() {
initWidget(bar);
status.setWordWrap(false);
HorizontalPanel buttons = new HorizontalPanel();
buttons.add(status);
 
 
buttons.add(gotoFirst);
buttons.add(gotoPrev);
buttons.add(gotoNext);
buttons.add(gotoEnd);
bar.add(buttons, DockPanel.EAST);
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
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 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 = 0;
// Tous selectionné
private int selectedRow = -1;
private Mediator mediator = null;
 
public DateFilterPanel(Mediator med) {
mediator=med;
 
mediator.registerDateFilterPanel(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");
 
navBar.setWidth("100%");
VerticalPanel panel = new VerticalPanel();
VerticalPanel inner = new VerticalPanel();
 
panel.add(header);
inner.add(selector); // Toutes localités
inner.add(table);
inner.setStyleName("date-List");
inner.setWidth("100%");
panel.setWidth("100%");
panel.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");
initWidget(panel);
 
 
}
 
/**
* 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/Cel.java
18,14 → 18,8
 
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;
 
 
 
32,127 → 26,22
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Cel implements EntryPoint, WindowResizeListener {
public class Cel implements EntryPoint {
 
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() {
 
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() {
new Mediator();
 
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$
* $Log$
* Revision 1.10 2007-09-17 19:25:34 ddelon
* Documentation
*
*
*/
/trunk/src/org/tela_botanica/client/Mediator.java
2,8 → 2,20
 
 
// TODO : sortie User vers une classe ...
// TODO : sortie les boutons supprimer et exporter et inclure ici
// TODO : sortie les boutons supprimer et exporter et inclure ici : vraiment ?
 
// TODO : optimisation, ne pas rechercher stations ou date si non affichés
 
 
 
 
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.widget.Viewport;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayout;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
import net.mygwt.ui.client.widget.layout.FillLayout;
 
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONBoolean;
16,23 → 28,32
 
public class Mediator implements AutoCompleteAsyncTextBoxListener {
// General
private WidgetContainer west = null;
private WidgetContainer south = null;
private WidgetContainer center = null;
private WidgetContainer north = null;
private String serviceBaseUrl = getServiceBaseUrlFromDictionnary(); // Recherche url de base des services distants
// Utilisateur
private TopPanel topPanel=null; // Information de connexion
private String user = null; // Utilisateur connecte ou bien identifiant de session
private boolean connected=false;
private ConnexionView connexionView=null; // Information de connexion
private String user = null; // Identifiant utilisateur connecte ou bien identifiant de session en cours
private boolean connected=false; // Positionne a vrai si identification reussie
 
// Filtres
private LeftPanel leftPanel=null; // Containeur filtre date, lieu, lieu-dit ...
private LocationList locationList = null; // Filtre sur lieu de releve
private DateList dateList = null; // Filtre sur date d'observation
private StationList stationList = null; // Filtre sur station d'observation
// Filtres sur les releves
private InventoryFilterView inventoryFilterView=null; // Containeur filtre date, lieu, lieu-dit ...
private LocationFilterPanel locationFilterPanel = null; // Filtre sur lieu de releve
private DateFilterPanel dateFilterPanel = null; // Filtre sur date d'observation
private StationFilterPanel stationFilterPanel = null; // Filtre sur station d'observation
 
// Saisie d'une observation
private EntryPanel entryPanel=null; // Formulaire de saisie observation
private EntryView entryView=null; // Formulaire de saisie observation
private NameAssistant nameAssistant=null; // Assistant de saisie nom scientifique
private LocationAssistant locationAssistant=null; // Assistant de saisie nom de commune
43,29 → 64,107
private TextBox comment = null; // commentaire observation
private InventoryItem inventoryItem=null; // Une observation saisie
 
// Liste de releves saisis
private InventoryListView inventoryListView = null; // Liste de releves
 
// Liste des observations
private InventoryItemList inventoryItemList = null; // Liste de releves saisis
private ActionPanel actionPanel=null; // Action sur les observations
// Actions sur les releves
private ActionView actionView=null; // Action sur les observations
private SearchPanel searchPanel = null; // Recherche dans les relevés saisis
 
// Informations
private InfoPopup infoPopup=null; // Information complementaire sur un taxon (photo, repartition)
Mediator() {
 
// Point d'entree (pour fin d'initialisation)
// Recherche identifiant utilisateur connecte
HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
new ResponseTextHandler() {
 
private Cel cel = null;
public void onCompletion(String str) {
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
user = ((JSONString) jsonArray.get(0)).stringValue(); // Identifiant utilisateur ou identifiant de session si non connecte
connected = ((JSONBoolean) jsonArray.get(1)).booleanValue(); // Drapeau leve si utilisateur identifie
}
_Mediator();
}
});
 
Mediator() {
}
// Fin initialisation
private void _Mediator() {
// Navigateur
Viewport viewport = new Viewport();
viewport.setStyleName("my-border-layout");
viewport.setBorders(true);
viewport.setLayout(new BorderLayout());
 
center = new WidgetContainer();
center.setLayout(new BorderLayout());
center.setBorders(true);
 
west = new WidgetContainer();
west.setLayout(new FillLayout());
west.setBorders(true);
south = new WidgetContainer();
south.setLayout(new FillLayout());
south.setBorders(true);
 
north = new WidgetContainer();
north.setLayout(new FillLayout());
north.setBorders(true);
 
inventoryListView = new InventoryListView(this); // Liste de releves
connexionView = new ConnexionView(this); // Identifiant de connection
inventoryFilterView = new InventoryFilterView(this); // Ensemble de filtres sur liste de releves
entryView = new EntryView(this); // Formulaire de saisie
actionView = new ActionView(this); // Action sur releves saisis
// searchPanel = new SearchPanel(this); // Recherche dans releves
//applicationPanel.add(searchPanel);
BorderLayoutData westData = new BorderLayoutData(Style.WEST, 200, 150, 300);
westData.resizeable = true;
viewport.add(west, westData);
 
BorderLayoutData centerData = new BorderLayoutData(Style.CENTER, 400, 400, 800);
viewport.add(center, centerData);
 
 
BorderLayoutData northData = new BorderLayoutData(Style.NORTH, 20, 20, 20);
viewport.add(north, northData);
 
BorderLayoutData southData = new BorderLayoutData(Style.SOUTH, 400, 400, 800);
// viewport.add(south, southData);
 
viewport.layout();
onInit();
 
// Methodes Private
}
/**
79,55 → 178,15
return theme.get("serviceBaseUrl");
 
}
 
 
// Appel aux services :
 
/**
* Recherche distante et asynchrone de l'utilisateur connecte, en retour lancement methode initialisation
* de l'appellant Cel. (initAsync)
*
*/
private void getUserFromService() {
 
 
HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
new ResponseTextHandler() {
 
public void onCompletion(String str) {
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
user = ((JSONString) jsonArray.get(0)).stringValue(); // Identifiant utilisateur ou identifiant de session si non connecte
connected = ((JSONBoolean) jsonArray.get(1)).booleanValue(); // Drapeau leve si utilisateur identifie
}
cel.initAsync();
}
});
 
}
 
 
// Methodes Public
// Information sur Etat du systeme
/**
* Recuperation information utilisateur
*
*/
public void initUser() {
getUserFromService(); // Appel distant recherche de l'utilisateur
}
// Actions declanchee par le systeme
/**
136,9 → 195,10
public void onInit() {
 
// Filtre par defaut : all et action selection de toutes les stations
locationList.setLocation("all");
locationList.updateCount();
locationFilterPanel.setLocation("all");
locationFilterPanel.updateCount();
 
this.onLocationSelected("all");
176,6 → 236,9
infoPopup.setImageUrl(value);
}
 
/**
187,11 → 250,11
// Lazy instantiation
if (inventoryItem==null) {
registerInventoryItem(new InventoryItem());
inventoryItem=new InventoryItem(this);
}
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),"null");
inventoryItemList.addelement();
inventoryItem.addelement();
}
206,29 → 269,16
 
// Lazy instantiation
if (inventoryItem==null) {
registerInventoryItem(new InventoryItem());
inventoryItem=new InventoryItem(this);
}
 
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),ordre);
inventoryItemList.updateElement();
inventoryItem.updateElement();
 
}
 
public boolean inventoryItemIsValid() {
// TODO : controle date
if (inventoryItem.getName().compareTo("")==0) {
return false;
}
else {
return true;
}
}
 
 
 
/**
* Action lancee par la selection d'un nom dans un assistant de saisie. Lance
* la recherche d'informations complementaires (famille, numero
241,12 → 291,12
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
String str, String value) {
if (getEntryPanel().getOrdre()==null) { // Nouvelle observation
if (entryView.getOrdre()==null) { // Nouvelle observation
onAddInventoryItem();
}
else {
onModifyInventoryItem(getEntryPanel().getOrdre()); // Modification d'une observation
getEntryPanel().setOrdre(null);
onModifyInventoryItem(entryView.getOrdre()); // Modification d'une observation
entryView.setOrdre(null);
}
 
}
260,9 → 310,13
public void onInventoryUpdated(String location) {
if (location.compareTo("")==0) {
location="000null";
}
 
locationList.setLocation(location); // Mise a jour filtre localite
locationList.updateCount();
locationFilterPanel.setLocation(location); // Mise a jour filtre localite
locationFilterPanel.updateCount();
 
this.onLocationSelected(location); // Selection localite
275,8 → 329,8
public void onInventoryItemSelected(String ordre) {
entryPanel.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne
entryPanel.update();
entryView.setOrdre(ordre); // Mise a jour du formulaire de saisie avec l'element selectionne
entryView.update();
}
 
285,9 → 339,9
* Action sur deselection d'une observation : remise a zero
*/
public void onInventoryItemUnselected(String ordre) {
public void onInventoryItemUnselected() {
entryPanel.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne
entryView.setOrdre(null); // Mise a jour du formulaire de saisie avec l'element selectionne
}
 
309,12 → 363,12
this.user=user;
topPanel.getSignLabel().setText(user+ " (deconnexion)");
inventoryItemList.setUser(user);
dateList.setUser(user);
stationList.setUser(user);
entryPanel.setUser(user);
locationList.setUser(user);
connexionView.getSignLabel().setText(user+ " (deconnexion)");
inventoryListView.setUser(user);
dateFilterPanel.setUser(user);
stationFilterPanel.setUser(user);
entryView.setUser(user);
locationFilterPanel.setUser(user);
this.onInit();
}
329,12 → 383,12
public void onLogoff(String user) {
this.user=user;
topPanel.getSignLabel().setText("Connexion");
inventoryItemList.setUser(user);
dateList.setUser(user);
stationList.setUser(user);
entryPanel.setUser(user);
locationList.setUser(user);
connexionView.getSignLabel().setText("Connexion");
inventoryListView.setUser(user);
dateFilterPanel.setUser(user);
stationFilterPanel.setUser(user);
entryView.setUser(user);
locationFilterPanel.setUser(user);
this.onInit();
}
351,8 → 405,8
if (search.trim().compareTo("")==0) {
search="all";
}
inventoryItemList.setSearch(search);
inventoryItemList.updateCount();
inventoryListView.setSearch(search);
inventoryListView.updateCount();
}
 
361,23 → 415,28
// Filtre selection lieu
/**
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants
* TODO : gerer asynchronicite ?
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants au filtrage
*/
public void onLocationSelected(String loc) {
inventoryItemList.setLocation(loc);
inventoryItemList.updateCount();
inventoryItemList.displayFilter();
// Positionnement Filtre affichage
inventoryListView.setLocation(loc);
inventoryListView.updateCount();
 
dateList.setLocation(loc);
dateList.updateCount();
// Affichage des filtres
inventoryListView.displayFilter();
 
// Positionnement Filtre affichage
 
dateFilterPanel.setLocation(loc);
dateFilterPanel.updateCount();
 
// Positionnement Filtre affichage
 
stationFilterPanel.setLocation(loc);
stationFilterPanel.updateCount();
stationList.setLocation(loc);
stationList.updateCount();
}
 
389,10 → 448,10
public void onStationSelected(String station) {
 
inventoryItemList.setStation(station);
inventoryItemList.updateCount();
inventoryListView.setStation(station);
inventoryListView.updateCount();
inventoryItemList.displayFilter();
inventoryListView.displayFilter();
 
 
 
407,10 → 466,10
public void onDateSelected(String date) {
 
inventoryItemList.setDate(date);
inventoryItemList.updateCount();
inventoryListView.setDate(date);
inventoryListView.updateCount();
inventoryItemList.displayFilter();
inventoryListView.displayFilter();
 
 
 
417,88 → 476,57
}
 
// Declaration, enregistrement
 
/**
* Declaration InventoryItem : une observation
* @param cel
*/
 
public void registerInventoryItem(InventoryItem inventoryItem) {
this.inventoryItem=inventoryItem;
}
 
 
/**
* Declaration InventoryItemList : liste d'observation
* @param inventoryItemList
* Declaration date : date observation
* @param date
*/
public void registerInventoryItemList(InventoryItemList inventoryItemList) {
public void registerDate(TextBox date) {
this.date=date;
this.inventoryItemList=inventoryItemList;
}
/**
* Declaration LocationList : filtre lieu observation
* @param locationList
*/
public void registerLocationList(LocationList locationList) {
this.locationList=locationList;
}
/**
* Declaration DateList : filtre date observation
* @param locationList
* Declaration lieu dit : lieu dit d'observation
*
* @param milieu
*/
public void registerDateList(DateList dateList) {
public void registerLieudit(TextBox lieudit) {
this.lieudit=lieudit;
this.dateList=dateList;
}
 
 
/**
* Declaration InfoPopup : information complementaire taxon en cours
* @param infoPopup
* Declaration milieu : milieu d'observation
*
* @param milieu
*/
public void registerInfoPopup(InfoPopup infoPopup) {
public void registerMilieu(TextBox milieu) {
this.milieu=milieu;
this.infoPopup=infoPopup;
}
 
 
/**
* Declaration StationList : filtre par station
* @param locationList
* Declaration commentaire b
* @param commentaire
*/
public void registerStationList(StationList stationList) {
public void registerComment(TextBox comment) {
this.comment=comment;
this.stationList=stationList;
}
 
/**
* Declaration Cel : point d'entree
* @param cel
*/
 
public void registerCel(Cel cel) {
this.cel=cel;
}
 
/**
* Declaration NameAssistant : completion nom scientifique
* @param nameassistant
509,107 → 537,52
}
/**
* Declaration LocationAssistant : completion commune
* @param locationassistant
* Declaration DateFilterPanel : filtre date observation
* @param locationList
*/
public void registerLocationAssistant(LocationAssistant locationAssistant) {
this.locationAssistant=locationAssistant;
public void registerDateFilterPanel(DateFilterPanel dateFilterPanel) {
this.dateFilterPanel=dateFilterPanel;
}
 
 
/**
* Declaration date : date observation
* @param date
* Declaration LocationAssistant : completion commune
* @param locationassistant
*/
public void registerDate(TextBox date) {
this.date=date;
public void registerLocationAssistant(LocationAssistant locationAssistant) {
this.locationAssistant=locationAssistant;
}
/**
* Declaration lieu dit : lieu dit d'observation
*
* @param milieu
*/
public void registerLieudit(TextBox lieudit) {
this.lieudit=lieudit;
}
 
 
/**
* Declaration milieu : milieu d'observation
*
* @param milieu
* Declaration LocationFilterPanel : filtre lieu observation
* @param locationList
*/
public void registerMilieu(TextBox milieu) {
this.milieu=milieu;
public void registerLocationFilterPanel(LocationFilterPanel locationFilterPanel) {
this.locationFilterPanel=locationFilterPanel;
}
 
/**
* Declaration Entry Panel : formulaire de saisie observation
*/
 
public void registerEntryPanel(EntryPanel entryPanel) {
this.entryPanel=entryPanel;
}
 
 
/**
* Declaration Action Panel : actions sur liste des observations
* Declaration StationFilterPanel : filtre par station
* @param locationList
*/
 
public void registerActionPanel(ActionPanel actionPanel) {
this.actionPanel=actionPanel;
}
 
 
/**
* Declaration TopPanel : panneau de connexion
*/
 
public void registerTopPanel(TopPanel topPanel) {
this.topPanel=topPanel;
}
 
/**
* Declaration commentaire
* @param commentaire
*/
public void registerComment(TextBox comment) {
this.comment=comment;
public void registerStationFilterPanel(StationFilterPanel stationFilterPanel) {
this.stationFilterPanel=stationFilterPanel;
}
 
/*
* Declaration LeftPanel Panneau gauche filtre sur liste d'observation
*
*/
public void registerLeftPanel(LeftPanel leftPanel) {
this.leftPanel=leftPanel;
}
// Accesseurs et setteurs
638,20 → 611,31
this.user=user;
}
 
public WidgetContainer getCenterContainer() {
return center;
}
public InventoryItemList getInventoryItemList() {
return inventoryItemList;
public WidgetContainer getNorthContainer() {
return north;
}
 
public LocationList getLocationList() {
return locationList;
public WidgetContainer getWestContainer() {
return west;
}
 
public DateList getDateList() {
return dateList;
public WidgetContainer getSouthContainer() {
return south;
}
 
public InventoryListView getInventoryListView() {
return inventoryListView;
}
 
public LocationFilterPanel getLocationList() {
return locationFilterPanel;
}
 
public NameAssistant getNameAssistant() {
return nameAssistant;
}
664,13 → 648,13
return inventoryItem;
}
 
public EntryPanel getEntryPanel() {
return entryPanel;
public EntryView entryView() {
return entryView;
}
 
 
public LeftPanel getLeftPanel() {
return leftPanel;
public InventoryFilterView getInventoryFilterView() {
return inventoryFilterView;
}
 
public InfoPopup getInfoPopup() {
691,9 → 675,9
}
 
public ActionPanel getActionPanel() {
public ActionView getActionView() {
return this.actionPanel;
return this.actionView;
}
 
}
/trunk/src/org/tela_botanica/client/StationFilterPanel.java
New file
0,0 → 1,472
/*
* 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.Label;
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 StationFilterPanel extends Composite {
// Debut Barre de navigation
 
private class NavBar extends Composite implements ClickListener {
 
public final DockPanel bar = new DockPanel();
 
public final Button gotoFirst = new Button("&lt;&lt;", this);
public final Button gotoNext = new Button("&gt;", this);
public final Button gotoPrev = new Button("&lt;", this);
public final Button gotoEnd = new Button("&gt;&gt;", this);
public final Label status = new Label();
 
public NavBar() {
initWidget(bar);
status.setWordWrap(false);
HorizontalPanel buttons = new HorizontalPanel();
buttons.add(status);
 
 
buttons.add(gotoFirst);
buttons.add(gotoPrev);
buttons.add(gotoNext);
buttons.add(gotoEnd);
bar.add(buttons, DockPanel.EAST);
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
}
 
 
 
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 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 StationFilterPanel(Mediator med) {
mediator=med;
 
mediator.registerStationFilterPanel(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");
 
navBar.setWidth("100%");
VerticalPanel panel = new VerticalPanel();
VerticalPanel inner = new VerticalPanel();
 
 
panel.add(header);
inner.add(selector); // Toutes station
inner.add(table);
inner.setStyleName("station-List");
inner.setWidth("100%");
panel.setWidth("100%");
panel.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(panel);
 
 
}
 
/**
* 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/ActionView.java
New file
0,0 → 1,114
/**
David Delon david.delon@clapas.net 2007
*/
 
/*
* ActionView.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 net.mygwt.ui.client.Style;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
 
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
public class ActionView {
private Mediator mediator=null;
private HTML exportButton=null;
 
public ActionView(final Mediator med) {
mediator=med;
HorizontalPanel panel = new HorizontalPanel();
HorizontalPanel buttons = new HorizontalPanel();
buttons.setSpacing(3);
 
// Transmission d'elements
HTML transButton=new HTML("Transmettre&nbsp;Tela&nbsp;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.getInventoryListView().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.getInventoryListView().deleteElement();
}
}
);
buttons.add(delButton);
 
// Export (renseigne lors de l'affichage des releves )
exportButton=new HTML();
buttons.add(exportButton);
exportButton.setStyleName("html_button");
 
 
panel.add(buttons);
 
WidgetContainer center=mediator.getCenterContainer();
BorderLayoutData centerData = new BorderLayoutData(Style.SOUTH, .05f, 100, 300);
center.add(panel,centerData);
 
}
 
 
public HTML getExportButton() {
return exportButton;
}
}
 
 
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.5 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/NameAssistant.java
17,7 → 17,7
import org.tela_botanica.client.AutoCompleteAsyncTextBox;
 
/**
* Affiche une liste de nom pour selection. Son retourn�s le nom selectionn� (gettext()) et un code associ� (getvalue()).
* Affiche une liste de nom pour selection. Son retournes le nom selectionne (gettext()) et un code associe (getvalue()).
*/
 
public class NameAssistant extends Composite implements EventListener, ResponseTextHandler {
/trunk/src/org/tela_botanica/client/InventoryItem.java
1,5 → 1,13
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 ?
13,15 → 21,23
private String comment=null;
private String ordre=null;
 
private Mediator mediator = null;
private String serviceBaseUrl = null;
 
// Constructeur
// Constructeur sur saisie
public InventoryItem() {
public InventoryItem(Mediator med) {
 
mediator=med;
serviceBaseUrl = mediator.getServiceBaseUrl();
}
 
50,45 → 66,203
}
 
public boolean isValid() {
// TODO : controle date
if (name.compareTo("")==0) {
return false;
}
else {
return true;
}
}
 
/**
* 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
 
public String getLocation() {
return location;
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);
}
}
});
}
// Saisie libre
else {
addElement(name, " ", " ", " ", " ", " ",location,location_id,date,milieu,comment);
}
}
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) {
 
public String getLocation_id() {
return location_id;
}
 
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),
 
public String getName() {
return name;
new ResponseTextHandler() {
 
public void onCompletion(String str) {
mediator.onInventoryUpdated(location);
}
});
}
 
 
public String getNomenclaturalNumber() {
return nomenclaturalNumber;
/**
* 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);
}
}
});
}
// Modification d'un nom ne faisant pas parti du referentiel (saisie libre)
else {
updateElement(ordre,name, " ", " ", " ", " ", " ",location,location_id,date,milieu,comment);
}
}
else {
// TODO : message d'erreur
return;
}
}
 
 
public String getComment() {
return comment;
}
 
/**
* 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
*/
 
public String getMilieu() {
return milieu;
}
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) {
 
 
public String getDate() {
return date;
}
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 String getOrdre() {
return ordre;
public void onCompletion(String str) {
mediator.onInventoryUpdated(location);
}
});
}
}
/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBox.java
22,6 → 22,7
 
// 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;
28,7 → 29,6
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,7 → 58,6
}
};
protected Vector items = new Vector();
protected boolean popupAdded = false;
protected boolean visible = false;
/**
282,17 → 281,15
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,9 → 95,8
public void setImageTop(String url) {
if (url.compareTo("null")!=0) {
// setPopupPosition(3*(Window.getClientWidth()/4), mediator.getInventoryItemList().getAbsoluteTop()+50);
setPopupPosition(mediator.getLeftPanel().getAbsoluteLeft()+10, mediator.getLeftPanel().getAbsoluteTop() + (mediator.getLeftPanel().getOffsetHeight()/2)+50);
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +15);
show();
imageTop.setUrl(url);
}
110,8 → 109,7
public void setImageBottom(String url) {
if (url.compareTo("null")!=0) {
// setPopupPosition(3*(Window.getClientWidth()/4), mediator.getInventoryItemList().getAbsoluteTop()+50);
setPopupPosition(mediator.getLeftPanel().getAbsoluteLeft()+10, mediator.getLeftPanel().getAbsoluteTop() + (mediator.getLeftPanel().getOffsetHeight()/2) + 50);
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +15);
show();
imageBottom.setUrl(url);
}
/trunk/src/org/tela_botanica/client/InventoryListView.java
New file
0,0 → 1,808
/**
David Delon david.delon@clapas.net 2007
*/
 
 
/*
* InventoryListView.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
*
*
*
* Suppression d'une liste d'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 net.mygwt.ui.client.Events;
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.event.BaseEvent;
import net.mygwt.ui.client.event.Listener;
import net.mygwt.ui.client.widget.ContentPanel;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
import net.mygwt.ui.client.widget.layout.FillLayout;
import net.mygwt.ui.client.widget.table.Table;
import net.mygwt.ui.client.widget.table.TableColumn;
import net.mygwt.ui.client.widget.table.TableColumnModel;
import net.mygwt.ui.client.widget.table.TableItem;
 
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.DockPanel;
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.Button;
import com.google.gwt.user.client.ui.Label;
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 InventoryListView
{
 
// Debut Barre de navigation
 
private class NavBar extends Composite implements ClickListener {
 
public final DockPanel bar = new DockPanel();
 
public final Button gotoFirst = new Button("&lt;&lt;", this);
public final Button gotoNext = new Button("&gt;", this);
public final Button gotoPrev = new Button("&lt;", this);
public final Button gotoEnd = new Button("&gt;&gt;", this);
public final Label status = new Label();
 
public NavBar() {
initWidget(bar);
status.setWordWrap(false);
 
HorizontalPanel buttons = new HorizontalPanel();
buttons.add(status);
buttons.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
buttons.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
 
 
buttons.add(gotoFirst);
buttons.add(gotoPrev);
buttons.add(gotoNext);
buttons.add(gotoEnd);
bar.add(buttons, DockPanel.EAST);
 
}
 
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 ContentPanel panel =null;
private Table table = null;
// 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;
 
// Filtre par defaut :
private String location = "all";
private String date = "all";
private String search = "all";
private String station = "all";
private String ordre= null;
 
 
public InventoryListView(Mediator med) {
// Traitement contexte utilisateur et service
 
mediator=med;
 
user=mediator.getUser();
serviceBaseUrl = mediator.getServiceBaseUrl();
panel= new ContentPanel(Style.HEADER);
panel.setLayout(new FillLayout());
// Barre navigation integree au header
navBar = new NavBar();
panel.getHeader().addWidget(navBar);
// Contenu :
// Colonnes :
TableColumn[] columns = new TableColumn[5];
// TODO : renderer date, alignement etc
columns[0] = new TableColumn("etat","Transmis", 50);
columns[0].setSortable(false);
 
columns[1] = new TableColumn("nom","Nom saisi", 200);
columns[1].setSortable(false);
columns[2] = new TableColumn("observation","Observation", 650);
columns[2].setSortable(false);
 
columns[3] = new TableColumn("date","Date", 75);
columns[3].setSortable(false);
 
columns[4] = new TableColumn("ordre","Ordre", 50);
columns[4].setSortable(false);
TableColumnModel cm = new TableColumnModel(columns);
// Table :
table = new Table(Style.MULTI | Style.HORIZONTAL, cm);
table.setBorders(false);
panel.add(table);
WidgetContainer center=mediator.getCenterContainer();
BorderLayoutData centerData = new BorderLayoutData(Style.CENTER, .75f, 100, 1000);
center.add(panel,centerData);
 
 
table.addListener(Events.RowClick, new Listener() {
 
public void handleEvent(BaseEvent be) {
TableItem item=(TableItem) be.item;
if (item!=null) {
if (ordre==null) {
ordre= (String) item.getValue(4);
mediator.onInventoryItemSelected(ordre);
}
else {
if (ordre.compareTo((String) item.getValue(4))==0) {
ordre=null;
table.deselect(be.rowIndex);
mediator.onInventoryItemUnselected();
}
else {
ordre= (String) item.getValue(4);
mediator.onInventoryItemSelected(ordre);
}
}
}
}
});
 
 
}
/**
* Suppression d'un ensemble d'element de la liste d'inventaire, on garde ici car s'applique a plusieurs elements
*
*/
 
public void deleteElement() {
 
setStatusDisabled();
TableItem[] selection=table.getSelection();
 
StringBuffer ids=new StringBuffer();
for (int i = 0; i < selection.length; i++) {
ids.append((String)(((TableItem) selection[i]).getValue(4)));
if (i<(selection.length-1)) 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, on garde ici car s'applique a plusieurs elements
*/
 
public void transmitElement() {
setStatusDisabled();
TableItem[] selection=table.getSelection();
 
StringBuffer ids=new StringBuffer();
for (int i = 0; i < selection.length; i++) {
ids.append((String)(((TableItem) selection[i]).getValue(4)));
if (i<(selection.length-1)) 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();
 
}
/**
* 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();
}
}
});
 
}
/**
* 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() {
 
// TODO : optimisation (ne pas supprimer mais remplacer)
 
// Ligne d'information
 
// Toutes date par defaut
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 observationText=null;
 
int arraySize = jsonArray.size();
for (i = 0; i < arraySize; ++i) {
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
 
Object[] values = new Object[5];
observationText=new StringBuffer();
// Statut Observation transmise ?
String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue();
if (atransmit.compareTo("1")==0) {
values[0] = new Image("tela.gif");
}
else {
values[0] = new HTML("&nbsp;");
}
// Nom saisi
values[1] = new HTML("<b>"+Util.toCelString(((JSONString) jsonArrayNested .get(0)).toString())+"</b>");
// Texte decrivant l'observation
// Nom retenu
String aname=Util.toCelString(((JSONString) jsonArrayNested .get(2)).toString());
if (aname.compareTo("null")==0) {
}
else {
observationText.append(aname+", ");
}
// Num nomenclatural
String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
if (ann.compareTo("0")!=0) {
observationText.append(""+ann+"-");
}
else {
observationText.append("0-");
}
 
// Num Taxonomique
String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
if (ant.compareTo("0")!=0) {
observationText.append(ant+", ");
}
else {
observationText.append("0, ");
}
 
// Famille
String afamily=Util.toCelString(((JSONString) jsonArrayNested .get(5)).toString());
if (afamily.compareTo("null")==0) {
//
}
else {
observationText.append(afamily+", ");
}
 
String aloc=Util.toCelString(((JSONString) jsonArrayNested .get(6)).toString());
// Localisation - Lieu
if (aloc.compareTo("000null")==0) {
if (observationText.length()==0) {
observationText.append("Commune absente");
}
else {
observationText.append("commune absente");
}
}
else {
if (observationText.length()==0) {
observationText.append("Commune de "+aloc);
}
else {
observationText.append("commune de "+aloc);
}
}
String alieudit=Util.toCelString(((JSONString) jsonArrayNested .get(9)).toString());
// Localisation - Lieu dit
if (alieudit.compareTo("000null")!=0) {
observationText.append(", "+alieudit);
}
String acomment=Util.toCelString(((JSONString) jsonArrayNested .get(10)).toString());
// Commentaire
if (acomment.compareTo("null")!=0) {
observationText.append(", "+acomment);
}
 
String adate=((JSONString) jsonArrayNested .get(8)).stringValue();
// Date
if (adate.compareTo("0000-00-00 00:00:00")!=0) {
values[3]=new HTML("<b>"+adate+"</b>");
}
else {
values[3] = new HTML("&nbsp;");
}
 
 
values[2] = observationText;
String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
// Numero d'ordre (cache)
values[4] = aordre;
if (i>=table.getItemCount()) {
TableItem item = new TableItem(values);
table.add(item);
}
else {
TableItem item=table.getItem(i);
item.setValue(0,values[0]);
item.setValue(1,values[1]);
item.setValue(2,values[2]);
item.setValue(3,values[3]);
item.setValue(4,values[4]);
}
// Spagetti
if (ordre!=null) {
if (aordre.compareTo(ordre)==0) {
table.select(i);
}
else {
table.deselect(i);
}
}
}
 
}
}
 
// Suppression fin ancien affichage
if (i<table.getItemCount()) {
for (int j = table.getItemCount() -1 ; j >= i; j--) {
TableItem item=table.getItem(j);
table.remove(item);
}
}
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 void displayFilter() {
// Mise a jour boutton export feuille de calcul
mediator.getActionView().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/"
+ user + "/"
+ URL.encodeComponent(location) + "/"
+ URL.encodeComponent(station)+ "/"
+ URL.encodeComponent(search) + "/"
+ date +
"\">"+"Export&nbsp;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&eacute;es";
}
else {
com="Commune de "+location;
}
}
 
String dat;
if (date.compareTo("all")==0) {
dat=", toutes p&eacute;riodes";
}
else {
if (date.compareTo("00/00/0000")==0) {
dat=", p&eacute;riodes non renseign&eacute;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&eacute;es";
}
else {
stat=", station "+ station;
}
}
 
panel.getHeader().setText(com + dat + stat );
 
 
}
 
 
}
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.8 2007-12-22 14:48:53 ddelon
* Documentation et refactorisation
*
* Revision 1.7 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 outer=new HorizontalPanel();
HorizontalPanel panel=new HorizontalPanel();
mediator=med;
 
79,14 → 79,14
 
outer.setSpacing(5);
outer.add(search);
panel.setSpacing(5);
panel.add(search);
outer.add(searchButton);
panel.add(searchButton);
 
initWidget(outer);
initWidget(panel);
}
95,7 → 95,10
}
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* $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/ConnexionView.java
New file
0,0 → 1,141
/**
David Delon david.delon@clapas.net 2007
*/
 
/*
* ConnexionView.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 net.mygwt.ui.client.widget.WidgetContainer;
 
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.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 ConnexionView {
 
private Mediator mediator=null;
private String user =null;
private Label signLabel = new Label() ;
private String serviceBaseUrl = null;
public ConnexionView(final Mediator med) {
 
mediator=med;
user=mediator.getUser();
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);
}
}
});
 
}
}
}
);
 
WidgetContainer north=mediator.getNorthContainer();
north.add(outer);
 
}
 
public Label getSignLabel() {
return signLabel;
}
 
 
}
 
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.6 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/EntryView.java
New file
0,0 → 1,534
/**
David Delon david.delon@clapas.net 2007
*/
 
/*
* EntryView.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
*
*/
 
 
// TODO : onvalidate dans mediator
 
 
package org.tela_botanica.client;
 
import java.util.Date;
 
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.widget.ContentPanel;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
import net.mygwt.ui.client.widget.layout.FlowLayout;
 
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.Grid;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.Label;
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 EntryView {
private ContentPanel panel=null;
private Label infoOrdre=new Label("Nouvelle observation");
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 EntryView(final Mediator med) {
Grid observation = new Grid(4,4);
infoOrdre.setWordWrap(false);
// 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.registerDate(date);
mediator.registerComment(comment);
mediator.registerMilieu(milieu);
mediator.registerLieudit(lieudit);
panel= new ContentPanel(Style.HEADER);
panel.setLayout(new FlowLayout());
panel.setText("Observation");
 
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:&nbsp;");
observation.setWidget(2,1,locationAssistant);
locationAssistant.setWidth("100%");
 
 
// Saisie lieu-dit
observation.setHTML(2,2,"Lieu-dit:&nbsp;");
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:&nbsp;");
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&egrave;ce:&nbsp;");
observation.setWidget(0,1,nameAssistant);
nameAssistant.setWidth("100%");
 
observation.setHTML(0,2,"Date:&nbsp;");
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:&nbsp;");
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);
outer.setWidth("100%");
 
panel.add(outer);
panel.getHeader().addWidget(infoOrdre);
WidgetContainer center=mediator.getCenterContainer();
BorderLayoutData centerData = new BorderLayoutData(Style.NORTH, .25f, 100, 300);
center.add(panel,centerData);
 
 
// 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);
}
}
}
 
});
 
}
 
}
 
/*
* Numero d'ordre du releve affiche + mise à jour bouton
*
*/
public void setOrdre(String ordre) {
this.ordre = ordre;
if (ordre==null) {
infoOrdre.setText("Nouvelle observation");
}
else {
infoOrdre.setText("Modification de l'observation n°: "+ordre);
}
}
 
 
/*
* 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("");
infoOrdre.setText("Nouvelle observation");
}
else {
// Modification d'une observation
mediator.onModifyInventoryItem(ordre);
infoOrdre.setText(ordre);
}
}
 
/**
* 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.8 2007-12-22 14:48:53 ddelon
* Documentation et refactorisation
*
* 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/LocationFilterPanel.java
New file
0,0 → 1,470
/*
* 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.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
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 LocationFilterPanel extends Composite {
// Barre de navigation
 
private class NavBar extends Composite implements ClickListener {
 
public final DockPanel bar = new DockPanel();
 
public final Button gotoFirst = new Button("&lt;&lt;", this);
public final Button gotoNext = new Button("&gt;", this);
public final Button gotoPrev = new Button("&lt;", this);
public final Button gotoEnd = new Button("&gt;&gt;", this);
 
public final Label status = new Label();
 
public NavBar() {
initWidget(bar);
status.setWordWrap(false);
HorizontalPanel buttons = new HorizontalPanel();
buttons.add(status);
 
 
buttons.add(gotoFirst);
buttons.add(gotoPrev);
buttons.add(gotoNext);
buttons.add(gotoEnd);
bar.add(buttons, DockPanel.EAST);
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
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 int startIndex = 0;
 
private String user;
 
private String serviceBaseUrl = null;
 
private String location = "all";
 
private NavBar navBar=null;
 
private int count = 0;
// Tous selectionne
private int selectedRow = -1;
private Mediator mediator = null;
 
public LocationFilterPanel(Mediator med) {
mediator=med;
 
mediator.registerLocationFilterPanel(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%");
 
VerticalPanel panel = new VerticalPanel();
VerticalPanel inner = new VerticalPanel();
 
panel.add(header);
inner.add(selector); // Toutes localites
inner.add(table);
inner.setStyleName("location-List");
inner.setWidth("100%");
panel.setWidth("100%");
panel.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(panel);
 
 
}
 
/**
* 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/InventoryFilterView.java
New file
0,0 → 1,85
/**
David Delon david.delon@clapas.net 2007
*/
 
/*
* InventoryFilterView.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;
 
//TODO : regler taille
 
 
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.widget.ExpandBar;
import net.mygwt.ui.client.widget.ExpandItem;
import net.mygwt.ui.client.widget.WidgetContainer;
 
import org.tela_botanica.client.LocationFilterPanel;
 
/**
*/
 
public class InventoryFilterView {
 
private LocationFilterPanel locationFilterPanel = null;
private DateFilterPanel dateFilterPanel = null;
private StationFilterPanel stationFilterPanel = null;
private Mediator mediator=null;
 
public InventoryFilterView(Mediator med) {
 
mediator=med;
dateFilterPanel = new DateFilterPanel(mediator);
locationFilterPanel = new LocationFilterPanel(mediator);
stationFilterPanel = new StationFilterPanel(mediator);
ExpandBar expandBar = new ExpandBar(Style.SINGLE | Style.HEADER);
expandBar.setSize(300, 300);
ExpandItem locationfilter = new ExpandItem();
locationfilter.setText("Localités");
locationfilter.getContainer().add(locationFilterPanel);
expandBar.add(locationfilter);
locationfilter.setExpanded(true);
 
ExpandItem stationfilter = new ExpandItem();
stationfilter.setText("Stations");
stationfilter.getContainer().add(stationFilterPanel);
expandBar.add(stationfilter);
ExpandItem dateFilter = new ExpandItem();
dateFilter.setText("Dates");
dateFilter.getContainer().add(dateFilterPanel);
expandBar.add(dateFilter);
 
WidgetContainer west=mediator.getWestContainer();
west.add(expandBar);
 
}
 
 
}
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.7 2007-09-17 19:25:34 ddelon
* Documentation
*
*
*/