Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Regard whitespace Rev 29 → Rev 28

/trunk/src/org/tela_botanica/client/LocationFilterView.java
File deleted
/trunk/src/org/tela_botanica/client/DateFilterView.java
File deleted
/trunk/src/org/tela_botanica/client/EntryView.java
33,9 → 33,6
import java.util.Date;
 
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.event.BaseEvent;
import net.mygwt.ui.client.event.SelectionListener;
import net.mygwt.ui.client.widget.Button;
import net.mygwt.ui.client.widget.ContentPanel;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
48,10 → 45,10
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.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.Label;
70,9 → 67,10
private LocationAssistant locationAssistant = null;
private TextBox date = new TextBox();
private TextBox lieudit = new TextBox();
private TextBox station = 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;
111,7 → 109,7
mediator.registerDate(date);
mediator.registerComment(comment);
mediator.registerStation(station);
mediator.registerMilieu(milieu);
mediator.registerLieudit(lieudit);
panel= new ContentPanel(Style.HEADER);
129,8 → 127,8
 
// Saisie Commune
observation.setHTML(0,0,"Commune: ");
observation.setWidget(0,1,locationAssistant);
observation.setHTML(2,0,"Commune: ");
observation.setWidget(2,1,locationAssistant);
locationAssistant.setWidth("100%");
 
137,8 → 135,8
 
// Saisie lieu-dit
observation.setHTML(0,2,"Lieu-dit: ");
observation.setWidget(0,3,lieudit);
observation.setHTML(2,2,"Lieu-dit: ");
observation.setWidget(2,3,lieudit);
lieudit.setWidth("100%");
 
163,22 → 161,22
 
 
// Saisie (station)
// Saisie (milieu)
observation.setHTML(1,0,"Station: ");
observation.setWidget(1,1,station);
observation.setHTML(3,0,"Milieu: ");
observation.setWidget(3,1,milieu);
 
station.setWidth("100%");
milieu.setWidth("100%");
 
// Validation par entree sur cette zone de texte
station.addKeyboardListener( new KeyboardListener() {
milieu.addKeyboardListener( new KeyboardListener() {
 
public void onKeyDown(Widget arg0, char arg1, int arg2) {
if(arg1 == KEY_ENTER)
{
onValidateTextBox(station);
onValidateTextBox(milieu);
}
 
}
195,10 → 193,9
// Releve
 
dateSelector.addSelectionListener(
dateSelector.addClickListener(new ClickListener () {
new SelectionListener() {
public void widgetSelected(BaseEvent be) {
public void onClick(Widget w) {
if (visible) {
visible=false;
235,17 → 232,17
// Saisie Espece
observation.setHTML(2,0,"Espèce: ");
observation.setWidget(2,1,nameAssistant);
observation.setHTML(0,0,"Espèce: ");
observation.setWidget(0,1,nameAssistant);
nameAssistant.setWidth("100%");
 
observation.setHTML(1,2,"Date: ");
observation.setHTML(0,2,"Date: ");
HorizontalPanel datePanel = new HorizontalPanel();
datePanel.add(date);
datePanel.add(dateSelector);
observation.setWidget(1,3,datePanel);
observation.setWidget(0,3,datePanel);
// Saisie date
// Validation par entree sur cette zone de texte
271,8 → 268,8
// Saisie Commentaire
observation.setHTML(3,0,"Notes: ");
observation.setWidget(3,1,comment);
observation.setHTML(1,0,"Notes: ");
observation.setWidget(1,1,comment);
 
comment.setWidth("100%");
 
296,6 → 293,28
);
 
// 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);
315,38 → 334,8
panel.add(outer);
HorizontalPanel inner=new HorizontalPanel();
panel.getHeader().addWidget(infoOrdre);
Button newButton=new Button("#",
// Init
new SelectionListener() {
public void widgetSelected(BaseEvent be) {
nameAssistant.setText("");
nameAssistant.setValue(null);
locationAssistant.setText("");
locationAssistant.setValue(null); // Null ?
date.setText("");
lieudit.setText("");
station.setText("");
comment.setText("");
ordre=null;
infoOrdre.setText("Nouvelle observation");
 
}
}
);
inner.add(infoOrdre);
inner.add(newButton);
 
inner.setCellHorizontalAlignment(infoOrdre, HasHorizontalAlignment.ALIGN_RIGHT);
inner.setCellVerticalAlignment(infoOrdre, HasVerticalAlignment.ALIGN_MIDDLE);
inner.setWidth("100%");
panel.getHeader().addWidget(inner);
WidgetContainer center=mediator.getCenterContainer();
BorderLayoutData centerData = new BorderLayoutData(Style.NORTH, .25f, 100, 300);
center.add(panel,centerData);
427,7 → 416,7
else {
// Modification d'une observation
mediator.onModifyInventoryItem(ordre);
infoOrdre.setText("Modification de l'observation n°: "+ordre);
infoOrdre.setText(ordre);
}
}
 
478,18 → 467,8
locationAssistant.setText("");
}
// Departement
String adep=Util.toCelString(((JSONString) jsonArray .get(7)).toString());
String adate=((JSONString) jsonArray .get(8)).stringValue();
if (adep.compareTo("000null")!=0) {
locationAssistant.setValue(adep);
}
else {
locationAssistant.setValue(null);
}
String adate=((JSONString) jsonArray .get(9)).stringValue();
// Date
if (adate.compareTo("0000-00-00 00:00:00")!=0) {
date.setText(adate);
499,28 → 478,18
}
 
 
String alieudit=Util.toCelString(((JSONString) jsonArray .get(10)).toString());
String astation=Util.toCelString(((JSONString) jsonArray .get(9)).toString());
// Lieudit
if (alieudit.compareTo("000null")!=0) {
lieudit.setText(alieudit);
}
else {
lieudit.setText("");
}
String astation=Util.toCelString(((JSONString) jsonArray .get(11)).toString());
// Station
if (astation.compareTo("000null")!=0) {
station.setText(astation);
milieu.setText(astation);
}
else {
station.setText("");
milieu.setText("");
}
 
String acomment=Util.toCelString(((JSONString) jsonArray .get(12)).toString());
String acomment=Util.toCelString(((JSONString) jsonArray .get(10)).toString());
// Notes
if (acomment.compareTo("null")!=0) {
comment.setText(acomment);
546,9 → 515,6
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.1 2008-01-02 21:26:04 ddelon
* mise en place mygwt
*
* Revision 1.8 2007-12-22 14:48:53 ddelon
* Documentation et refactorisation
*
/trunk/src/org/tela_botanica/client/InventoryFilterView.java
21,6 → 21,7
import net.mygwt.ui.client.widget.ExpandItem;
import net.mygwt.ui.client.widget.WidgetContainer;
 
import org.tela_botanica.client.LocationFilterPanel;
 
/**
*/
27,9 → 28,9
 
public class InventoryFilterView {
 
private LocationFilterView locationFilterView = null;
private DateFilterView dateFilterView = null;
private ExpandBar expandBar=null;
private LocationFilterPanel locationFilterPanel = null;
private DateFilterPanel dateFilterPanel = null;
private StationFilterPanel stationFilterPanel = null;
private Mediator mediator=null;
 
public InventoryFilterView(Mediator med) {
36,14 → 37,34
 
mediator=med;
dateFilterPanel = new DateFilterPanel(mediator);
locationFilterPanel = new LocationFilterPanel(mediator);
stationFilterPanel = new StationFilterPanel(mediator);
expandBar = new ExpandBar(Style.SINGLE | Style.HEADER);
ExpandBar expandBar = new ExpandBar(Style.SINGLE | Style.HEADER);
expandBar.setSize(300, 300);
 
locationFilterView = new LocationFilterView(mediator,this);
dateFilterView = new DateFilterView(mediator,this);
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);
51,19 → 72,12
}
 
public ExpandBar getExpandBar() {
return expandBar;
}
 
 
}
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.1 2008-01-02 21:26:04 ddelon
* mise en place mygwt
*
* Revision 1.7 2007-09-17 19:25:34 ddelon
* Documentation
*
/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("<<", 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_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/LocationAssistant.java
73,9 → 73,6
autoCompletebox.setText(str);
}
 
public void setValue(String value) {
autoCompletebox.setValue(value);
}
 
public String getValue() {
return autoCompletebox.getValue();
/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("&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_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/Mediator.java
47,8 → 47,9
 
// Filtres sur les releves
private InventoryFilterView inventoryFilterView=null; // Containeur filtre date, lieu, lieu-dit ...
private LocationFilterView locationFilterView=null; // Filtre sur lieu de releve
private DateFilterView dateFilterView = null; // Filtre sur date d'observation
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
58,7 → 59,7
private LocationAssistant locationAssistant=null; // Assistant de saisie nom de commune
private TextBox date = null; // date observation
private TextBox station = null; // station observation
private TextBox milieu = null; // milieu observation
private TextBox lieudit = null; // lieu dit observation
private TextBox comment = null; // commentaire observation
private InventoryItem inventoryItem=null; // Une observation saisie
107,27 → 108,27
// Navigateur
Viewport viewport = new Viewport();
// viewport.setStyleName("my-border-layout");
// viewport.setBorders(true);
viewport.setStyleName("my-border-layout");
viewport.setBorders(true);
viewport.setLayout(new BorderLayout());
 
center = new WidgetContainer();
center.setLayout(new BorderLayout());
// center.setBorders(true);
center.setBorders(true);
 
west = new WidgetContainer();
west.setLayout(new FillLayout());
// west.setBorders(true);
west.setBorders(true);
south = new WidgetContainer();
south.setLayout(new FillLayout());
// south.setBorders(true);
south.setBorders(true);
 
north = new WidgetContainer();
north.setLayout(new FillLayout());
north.setBorders(true);
 
// north.setBorders(true);
inventoryListView = new InventoryListView(this); // Liste de releves
connexionView = new ConnexionView(this); // Identifiant de connection
194,23 → 195,13
public void onInit() {
 
locationFilterView.setIDLocation("all"); // Mise a jour filtre localite
locationFilterView.setLocation("all"); // Mise a jour filtre localite
locationFilterView.setLieudit("all"); // Mise a jour filtre localite
locationFilterView.update(); // Mise a jour affichage
// Filtre par defaut : all et action selection de toutes les stations
locationFilterPanel.setLocation("all");
locationFilterPanel.updateCount();
dateFilterView.setYear("all");
dateFilterView.setMonth("all");
dateFilterView.setDay("all");
this.onLocationSelected("all");
dateFilterView.update();
this.onLocationSelected("all","all","all");
}
234,7 → 225,7
/**
* Action suivant la completion d'un nom : affichage popup information
* Action suivant la completion d'un nom
*
*/
 
262,7 → 253,7
inventoryItem=new InventoryItem(this);
}
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),lieudit.getText(),station.getText(),comment.getText(),"null");
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),"null");
inventoryItem.addelement();
}
281,7 → 272,7
inventoryItem=new InventoryItem(this);
}
 
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),lieudit.getText(),station.getText(),comment.getText(),ordre);
inventoryItem.setContent(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),milieu.getText(),comment.getText(),ordre);
inventoryItem.updateElement();
 
}
318,34 → 309,17
*/
public void onInventoryUpdated(String id_location,String loc, String lieu) {
public void onInventoryUpdated(String location) {
if (id_location.compareTo("")==0) {
id_location="000null";
if (location.compareTo("")==0) {
location="000null";
}
if (loc.compareTo("")==0) {
loc="000null";
}
locationFilterPanel.setLocation(location); // Mise a jour filtre localite
locationFilterPanel.updateCount();
 
if (lieu.compareTo("")==0) {
lieu="000null";
}
this.onLocationSelected(location); // Selection localite
 
 
locationFilterView.setIDLocation(id_location); // Mise a jour filtre localite
locationFilterView.setLocation(loc); // Mise a jour filtre localite
locationFilterView.setLieudit(lieu); // Mise a jour filtre localite
locationFilterView.update(); // Mise a jour affichage
 
dateFilterView.setYear("all");
dateFilterView.setMonth("all");
dateFilterView.setDay("all");
dateFilterView.update();
this.onLocationSelected(id_location,loc,lieu); // Selection localite
}
391,9 → 365,10
this.user=user;
connexionView.getSignLabel().setText(user+ " (deconnexion)");
inventoryListView.setUser(user);
dateFilterView.setUser(user);
dateFilterPanel.setUser(user);
stationFilterPanel.setUser(user);
entryView.setUser(user);
locationFilterView.setUser(user);
locationFilterPanel.setUser(user);
this.onInit();
}
410,9 → 385,10
this.user=user;
connexionView.getSignLabel().setText("Connexion");
inventoryListView.setUser(user);
dateFilterView.setUser(user);
dateFilterPanel.setUser(user);
stationFilterPanel.setUser(user);
entryView.setUser(user);
locationFilterView.setUser(user);
locationFilterPanel.setUser(user);
this.onInit();
}
442,22 → 418,45
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants au filtrage
*/
public void onLocationSelected(String id_loc, String loc,String lieu) {
public void onLocationSelected(String loc) {
// Positionnement Filtre affichage
inventoryListView.setIdLocation(id_loc);
inventoryListView.setLocation(loc);
inventoryListView.setLieudit(lieu);
inventoryListView.updateCount();
 
// Affichage des filtres
inventoryListView.displayFilter();
 
// Positionnement Filtre affichage
dateFilterPanel.setLocation(loc);
dateFilterPanel.updateCount();
 
// Positionnement Filtre affichage
 
stationFilterPanel.setLocation(loc);
stationFilterPanel.updateCount();
}
 
// Filtre station
 
/**
* Action sur selection d'une station : affichage de la liste des taxons correspondants
*/
public void onStationSelected(String station) {
 
inventoryListView.setStation(station);
inventoryListView.updateCount();
inventoryListView.displayFilter();
 
 
 
}
 
// Filtre date d'observation
 
465,12 → 464,9
* Action sur selection d'une date : affichage de la liste des taxons correspondants
*/
public void onDateSelected(String year,String month,String day) {
public void onDateSelected(String date) {
 
inventoryListView.setYear(year);
inventoryListView.setMonth(month);
inventoryListView.setDay(day);
inventoryListView.setDate(date);
inventoryListView.updateCount();
inventoryListView.displayFilter();
499,7 → 495,7
/**
* Declaration lieu dit : lieu dit d'observation
*
* @param lieudit
* @param milieu
*/
public void registerLieudit(TextBox lieudit) {
510,13 → 506,13
 
/**
* Declaration station : station d'observation
* Declaration milieu : milieu d'observation
*
* @param station
* @param milieu
*/
public void registerStation(TextBox station) {
this.station=station;
public void registerMilieu(TextBox milieu) {
this.milieu=milieu;
}
543,19 → 539,17
/**
* Declaration DateFilterView : filtre date observation
* Declaration DateFilterPanel : filtre date observation
* @param locationList
*/
public void registerDateFilterView(DateFilterView dateFilterView) {
public void registerDateFilterPanel(DateFilterPanel dateFilterPanel) {
this.dateFilterView=dateFilterView;
this.dateFilterPanel=dateFilterPanel;
}
 
 
/**
* Declaration LocationAssistant : completion commune
* @param locationassistant
567,17 → 561,28
}
 
/**
* Declaration LocationFilterView : filtre lieu observation
* Declaration LocationFilterPanel : filtre lieu observation
* @param locationList
*/
public void registerLocationFilterView(LocationFilterView locationFilterView) {
public void registerLocationFilterPanel(LocationFilterPanel locationFilterPanel) {
this.locationFilterView=locationFilterView;
this.locationFilterPanel=locationFilterPanel;
}
/**
* Declaration StationFilterPanel : filtre par station
* @param locationList
*/
public void registerStationFilterPanel(StationFilterPanel stationFilterPanel) {
this.stationFilterPanel=stationFilterPanel;
}
 
// Accesseurs et setteurs
627,9 → 632,8
return inventoryListView;
}
 
 
public LocationFilterView getLocationFilterView() {
return locationFilterView;
public LocationFilterPanel getLocationList() {
return locationFilterPanel;
}
 
public NameAssistant getNameAssistant() {
/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
20,16 → 20,14
 
 
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.event.BaseEvent;
import net.mygwt.ui.client.event.SelectionListener;
import net.mygwt.ui.client.widget.Button;
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;
47,9 → 45,12
// Transmission d'elements
 
Button transButton= new Button("Transmettre&nbsp;Tela&nbsp;Botanica",
new SelectionListener() {
public void widgetSelected(BaseEvent be) {
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();
}
64,9 → 65,11
// Suppression d'elements
 
Button delButton = new Button("Suppression",
new SelectionListener() {
public void widgetSelected(BaseEvent be) {
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();
}
79,7 → 82,9
exportButton=new HTML();
buttons.add(exportButton);
exportButton.setStyleName("html_button");
 
 
panel.add(buttons);
 
WidgetContainer center=mediator.getCenterContainer();
99,9 → 104,6
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.1 2008-01-02 21:26:05 ddelon
* mise en place mygwt
*
* Revision 1.5 2007-12-22 14:48:53 ddelon
* Documentation et refactorisation
*
/trunk/src/org/tela_botanica/client/InventoryItem.java
17,8 → 17,7
private String location=null;
private String location_id=null;
private String date=null;
private String lieudit=null;
private String station=null;
private String milieu=null;
private String comment=null;
private String ordre=null;
 
44,7 → 43,7
// Alimentation contenu depuis saisie
public void setContent(String name,String nomenclaturalNumber, String location, String location_id, String date, String lieudit, String station, String comment,String ordre) {
public void setContent(String name,String nomenclaturalNumber, String location, String location_id, String date, String milieu, String comment,String ordre) {
 
this.name=name;
60,11 → 59,8
}
this.location_id=location_id;
if (location.compareTo("")==0) this.location_id="";
if (location_id==null) this.location_id="";
this.date=date;
this.lieudit=lieudit;
this.station=station;
this.milieu=milieu;
this.comment=comment;
this.ordre=ordre;
119,7 → 115,7
.stringValue(),
Util.toCelString(((JSONString) jsonArray.get(3))
.toString()),
location,location_id,date,lieudit,station,comment);
location,location_id,date,milieu,comment);
}
}
127,7 → 123,7
}
// Saisie libre
else {
addElement(name, " ", " ", " ", " ", " ",location,location_id,date,lieudit,station,comment);
addElement(name, " ", " ", " ", " ", " ",location,location_id,date,milieu,comment);
}
}
157,7 → 153,7
*/
 
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 lieu, String sta, String comment) {
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String milieu, String comment) {
 
 
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
164,12 → 160,12
+ 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
+ "&lieudit="+ URL.encodeComponent(lieu) + "&station="+ URL.encodeComponent(sta) + "&commentaire="+ URL.encodeComponent(comment),
+ "&station="+ URL.encodeComponent(milieu) + "&commentaire="+ URL.encodeComponent(comment),
 
new ResponseTextHandler() {
 
public void onCompletion(String str) {
mediator.onInventoryUpdated(location_id,location,"all");
mediator.onInventoryUpdated(location);
}
});
}
210,7 → 206,7
.stringValue(),
Util.toCelString(((JSONString) jsonArray.get(3))
.toString()),
location,location_id,date,lieudit,station,comment);
location,location_id,date,milieu,comment);
}
}
218,7 → 214,7
}
// Modification d'un nom ne faisant pas parti du referentiel (saisie libre)
else {
updateElement(ordre,name, " ", " ", " ", " ", " ",location,location_id,date,lieudit,station,comment);
updateElement(ordre,name, " ", " ", " ", " ", " ",location,location_id,date,milieu,comment);
}
}
251,7 → 247,7
*/
 
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 lieu, String sta, String comment) {
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String milieu, String comment) {
 
 
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + mediator.getUser() + "/" +ordre + "/",
258,12 → 254,12
"&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
+ "&lieudit="+ URL.encodeComponent(lieu) + "&station="+ URL.encodeComponent(sta) + "&commentaire="+ URL.encodeComponent(comment),
+ "&station="+ URL.encodeComponent(milieu) + "&commentaire="+ URL.encodeComponent(comment),
 
new ResponseTextHandler() {
 
public void onCompletion(String str) {
mediator.onInventoryUpdated(location_id,location,"all");
mediator.onInventoryUpdated(location);
}
});
}
/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBox.java
186,7 → 186,6
}
currentValue=null;
this.setText("");
this.setValue(null);
}
 
}
212,8 → 211,6
if(text.length() > 0)
{
currentValue=null;
 
items.clear();
if (getFromCache(text)!=null) {
/trunk/src/org/tela_botanica/client/InfoPopup.java
96,7 → 96,7
public void setImageTop(String url) {
if (url.compareTo("null")!=0) {
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +20);
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +15);
show();
imageTop.setUrl(url);
}
109,7 → 109,7
public void setImageBottom(String url) {
if (url.compareTo("null")!=0) {
setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop() + (mediator.getWestContainer().getOffsetHeight()/3) +20);
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
164,13 → 164,10
 
// Filtre par defaut :
private String id_location = "all";
private String location = "all";
private String year = "all";
private String month = "all";
private String day = "all";
private String date = "all";
private String search = "all";
private String lieudit = "all";
private String station = "all";
private String ordre= null;
238,25 → 235,23
 
 
// Selection d'une ligne
table.addListener(Events.RowClick, new Listener() {
 
public void handleEvent(BaseEvent be) {
TableItem item=(TableItem) be.item;
if (item!=null) {
if (ordre==null) { // Affichage de la ligne selectionne
if (ordre==null) {
ordre= (String) item.getValue(4);
mediator.onInventoryItemSelected(ordre);
}
else {
// Si une ligne etait deja selectionne
if (ordre.compareTo((String) item.getValue(4))==0) { // C'est la meme, on la deselectionne
if (ordre.compareTo((String) item.getValue(4))==0) {
ordre=null;
table.deselect(be.rowIndex);
mediator.onInventoryItemUnselected();
}
else {
ordre= (String) item.getValue(4); // C'est une autre, on la selectionne
ordre= (String) item.getValue(4);
mediator.onInventoryItemSelected(ordre);
}
295,7 → 290,7
new ResponseTextHandler() {
public void onCompletion(String str) {
mediator.onInventoryUpdated(id_location,"all","all");
mediator.onInventoryUpdated(location);
}
});
}
354,8 → 349,12
// 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 + "/" + id_location + "/" + URL.encodeComponent(location) + "/" + year + "/" + month + "/" + day + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(lieudit),
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) + "/" + adate + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(station),
new ResponseTextHandler() {
 
public void onCompletion(String str) {
392,8 → 391,12
 
// 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 + "/" + id_location + "/" + URL.encodeComponent(location) +"/" + year + "/" + month + "/" + day + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(lieudit) + "/"
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) +"/" + adate + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(station) + "/"
+ startIndex + "/" + VISIBLE_TAXON_COUNT,
 
new ResponseTextHandler() {
404,6 → 407,7
JSONArray jsonArray;
JSONArray jsonArrayNested;
int row=0;
int i=0;
 
if ((jsonArray = jsonValue.isArray()) != null) {
423,7 → 427,7
// Statut Observation transmise ?
String atransmit=((JSONString) jsonArrayNested .get(12)).stringValue();
String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue();
if (atransmit.compareTo("1")==0) {
values[0] = new Image("tela.gif");
513,18 → 517,7
observationText.append(", "+alieudit);
}
// Station -
String astation=Util.toCelString(((JSONString) jsonArrayNested .get(10)).toString());
 
if (astation.compareTo("000null")!=0) {
observationText.append(", "+astation);
}
 
String acomment=Util.toCelString(((JSONString) jsonArrayNested .get(11)).toString());
String acomment=Util.toCelString(((JSONString) jsonArrayNested .get(10)).toString());
// Commentaire
if (acomment.compareTo("null")!=0) {
688,19 → 681,7
}
 
 
/*
* Departement en cours
*
*/
public void setIdLocation(String id_location) {
this.id_location = id_location;
}
 
 
/*
* Localite en cours
*
*/
716,8 → 697,8
*
*/
 
public void setLieudit(String lieudit) {
this.lieudit = lieudit;
public void setStation(String station) {
this.station = station;
}
 
728,20 → 709,11
*/
 
public void setYear(String year) {
this.year = year;
public void setDate(String date) {
this.date = date;
}
 
 
public void setMonth(String month) {
this.month = month;
}
 
public void setDay(String day) {
this.day = day;
}
 
/*
* Utilisateur en cours
*
762,111 → 734,64
mediator.getActionView().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/"
+ user + "/"
+ URL.encodeComponent(id_location) + "/"
+ URL.encodeComponent(location) + "/"
+ URL.encodeComponent(lieudit)+ "/"
+ year + "/"
+ month + "/"
+ day
+ "\">"+"Export&nbsp;tableur</a>");
+ URL.encodeComponent(station)+ "/"
+ URL.encodeComponent(search) + "/"
+ date +
"\">"+"Export&nbsp;tableur</a>");
 
// Mise a jour ligne de selection
String dep;
if (id_location.compareTo("all")==0) {
dep="Tous d&eacute;partements";
}
else {
if (id_location.compareTo("000null")==0) {
dep="D&eacute;partements non renseign&eacute;es ";
}
else {
dep="Département "+id_location;
}
}
String com;
if (location.compareTo("all")==0) {
com=", toutes communes";
com="Toutes communes";
}
else {
if (location.compareTo("000null")==0) {
com=", communes non renseign&eacute;es";
com="Communes non renseign&eacute;es";
}
else {
com=", commune de "+location;
com="Commune de "+location;
}
}
 
String dat;
String lieu;
if (lieudit.compareTo("all")==0) {
lieu=", tous lieux dits";
if (date.compareTo("all")==0) {
dat=", toutes p&eacute;riodes";
}
else {
if (lieudit.compareTo("000null")==0) {
lieu=", lieu-dit non renseign&eacute;es";
if (date.compareTo("00/00/0000")==0) {
dat=", p&eacute;riodes non renseign&eacute;es";
}
else {
lieu=", lieu-dit "+ lieudit;
dat=", le "+ date;
}
}
String dat;
if ((year.compareTo("all")==0) && (month.compareTo("all")==0) && (day.compareTo("all")==0)) {
dat=", toutes periodes";
}
String stat;
else {
String yea="";
String da="";
String mont="";
if (year.compareTo("all")==0) {
yea=", toutes ann&eacute;es";
if (station.compareTo("all")==0) {
stat=", toutes stations";
}
else {
if (year.compareTo("0")==0) {
yea=", periode non renseign&eacute;e";
if (station.compareTo("000null")==0) {
stat=", stations non renseign&eacute;es";
}
else {
yea=", "+ year;
if (month.compareTo("all")==0) {
mont=", tous mois";
stat=", station "+ station;
}
else {
mont="/"+ month;
}
if (day.compareTo("all")==0) {
da=", tous jours";
}
else {
da="/"+ day;
}
}
}
panel.getHeader().setText(com + dat + stat );
dat=yea + mont + da;
}
 
panel.getHeader().setText(dep + com + lieu + dat);
 
 
}
 
 
874,9 → 799,6
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.1 2008-01-02 21:26:04 ddelon
* mise en place mygwt
*
* Revision 1.8 2007-12-22 14:48:53 ddelon
* Documentation et refactorisation
*