/trunk/src/org/tela_botanica/client/TopPanel.java |
---|
15,32 → 15,117 |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONBoolean; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.ui.Widget; |
/** |
* Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget() |
*/ |
public class TopPanel extends Composite { |
private Mediator mediator=null; |
private String user =null; |
private Label signLabel = new Label() ; |
private String serviceBaseUrl = null; |
public TopPanel(final Mediator med) { |
mediator=med; |
VerticalPanel outer = new VerticalPanel(); |
mediator.registerTopPanel(this); |
user=mediator.getUser(); |
signLabel.setStyleName("selection_label"); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
if (!mediator.getConnected()) { |
signLabel.setText("Connexion"); |
} |
else { |
signLabel.setText(user+ " (deconnexion)"); |
} |
HorizontalPanel outer = new HorizontalPanel(); |
HorizontalPanel inner = new HorizontalPanel(); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); |
outer.add(new HTML("<b>Carnet en ligne</b>")); |
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) { |
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 { |
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 = ((JSONString) jsonArray.get(0)).stringValue(); |
mediator.setConnected(((JSONBoolean) jsonArray.get(1)).booleanValue()); |
} |
if (!mediator.getConnected()) { |
mediator.onLogoff(user); |
} |
} |
}); |
} |
} |
} |
); |
initWidget(outer); |
} |
public Label getSignLabel() { |
return signLabel; |
} |
} |
/trunk/src/org/tela_botanica/client/SearchPanel.java |
---|
30,10 → 30,8 |
public class SearchPanel extends Composite { |
Mediator mediator=null; |
private String serviceBaseUrl = null; |
private Mediator mediator=null; |
private String user= null; |
private TextBox search = null; |
50,8 → 48,8 |
// Recherche |
HTML searchButton=new HTML("Rechercher"); |
searchButton.setStyleName("html_button"); |
HTML searchButton=new HTML("Rechercher dans les relevés"); |
searchButton.setStyleName("html_button_long"); |
searchButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
89,11 → 87,8 |
outer.add(searchButton); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
initWidget(outer); |
/trunk/src/org/tela_botanica/client/LoginDialog.java |
---|
New file |
0,0 → 1,201 |
/* |
* 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.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.ui.ClickListener; |
import com.google.gwt.user.client.ui.DialogBox; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.KeyboardListener; |
import com.google.gwt.user.client.ui.PasswordTextBox; |
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 LoginDialog extends DialogBox { |
Mediator mediator=null; |
private String serviceBaseUrl = null; |
private TextBox login = new TextBox(); |
private PasswordTextBox password = new PasswordTextBox(); |
private String user=null; |
public LoginDialog(final Mediator med) { |
setText("Connexion"); |
mediator=med; |
mediator.registerLoginDialog(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
VerticalPanel outer = new VerticalPanel(); |
Grid inner = new Grid(3,2); |
HTML textLogin = new HTML("E-mail:"); |
HTML textPassword = new HTML("Mot de passe:"); |
HTML okButton=new HTML("Ok"); |
okButton.setStyleName("html_button"); |
okButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
loginFromService(login.getText(),password.getText()); |
hide(); |
} |
} |
); |
HTML cancelButton=new HTML("Annuler"); |
cancelButton.setStyleName("html_button"); |
cancelButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
hide(); |
} |
} |
); |
login.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
loginFromService(login.getText(),password.getText()); |
hide(); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
} |
public void onKeyPress(Widget arg0, char arg1, int arg2) { |
} |
} |
); |
password.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
loginFromService(login.getText(),password.getText()); |
hide(); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
} |
public void onKeyPress(Widget arg0, char arg1, int arg2) { |
} |
} |
); |
inner.setWidget(0,0,textLogin); |
inner.setWidget(0,1,login); |
inner.setWidget(1,0,textPassword); |
inner.setWidget(1,1,password); |
inner.setWidget(2,0,okButton); |
inner.setWidget(2,1,cancelButton); |
inner.setCellPadding(10); |
outer.add(inner); |
setWidget(outer); |
} |
/** |
* |
*/ |
private void loginFromService(String login, String password) { |
HTTPRequest.asyncGet(serviceBaseUrl + "/User/" + login + "/" + password , |
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(); |
mediator.setConnected(((JSONBoolean) jsonArray.get(1)).booleanValue()); |
} |
if (mediator.getConnected()) { |
mediator.onLogin(user); |
} |
} |
}); |
} |
public boolean onKeyDownPreview(char key, int modifiers) { |
// Use the popup's key preview hooks to close the dialog when either |
// escape is pressed. |
switch (key) { |
case KeyboardListener.KEY_ESCAPE: |
hide(); |
break; |
} |
return true; |
} |
} |
/trunk/src/org/tela_botanica/client/ActionPanel.java |
---|
16,6 → 16,7 |
package org.tela_botanica.client; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.HTML; |
40,8 → 41,30 |
HorizontalPanel outer = new HorizontalPanel(); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.setSpacing(3); |
// Transmission d'elements |
HTML transButton=new HTML("Transmettre Tela Botanica"); |
transButton.setStyleName("html_button_long"); |
transButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// TODO : une action dans le mediator |
if (mediator.getConnected()) { |
mediator.getInventoryItemList().transmitElement(); |
} |
else { |
Window.alert("Identifiez-vous pour transmettre"); |
} |
} |
} |
); |
buttons.add(transButton); |
// Suppression d'elements |
HTML delButton=new HTML("Suppression"); |
55,21 → 78,19 |
} |
); |
outer.add(delButton); |
buttons.add(delButton); |
// Export de la totalité |
HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>"); |
outer.add(exportButton); |
HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>"); |
buttons.add(exportButton); |
exportButton.setStyleName("html_button"); |
outer.setSpacing(5); |
// Selections de l'affichage |
HorizontalPanel selections = new HorizontalPanel(); |
selections.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); |
selections.setSpacing(3); |
106,6 → 127,7 |
); |
outer.add(buttons); |
outer.add(selections); |
initWidget(outer); |
/trunk/src/org/tela_botanica/client/Cel.java |
---|
3,6 → 3,7 |
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.History; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.WindowResizeListener; |
import com.google.gwt.user.client.ui.DockPanel; |
62,12 → 63,11 |
entryPanel.setStyleName("item-Input"); |
rightPanel.add(searchPanel); |
rightPanel.add(entryPanel); |
rightPanel.add(centerPanel); |
rightPanel.add(actionPanel); |
rightPanel.add(centerPanel); |
rightPanel.add(entryPanel); |
rightPanel.setWidth("100%"); |
centerPanel.setWidth("100%"); |
93,7 → 93,7 |
outer.setWidth("100%"); |
outer.setSpacing(4); |
outer.setSpacing(2); |
outer.setCellWidth(rightPanel, "100%"); |
// Window.enableScrolling(false); |
/trunk/src/org/tela_botanica/client/Mediator.java |
---|
5,11 → 5,14 |
// TODO : sortie les boutons supprimer et exporter et inclure ici |
import com.google.gwt.i18n.client.Dictionary; |
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.ui.Label; |
import com.google.gwt.user.client.ui.TextBox; |
public class Mediator { |
20,6 → 23,7 |
private InventoryItemList inventoryItemList = null; |
private LocationList locationList = null; |
private DateList dateList = null; |
private StationList stationList = null; |
private NameAssistant nameAssistant=null; |
private LocationAssistant locationAssistant=null; |
private InventoryItem inventoryItem=null; |
26,14 → 30,16 |
private EntryPanel entryPanel=null; |
private ActionPanel actionPanel=null; |
private SearchPanel searchPanel=null; |
private LoginDialog loginDialog=null; |
private TopPanel topPanel=null; |
private TextBox date = null; |
private TextBox complementLocation = null; |
private TextBox comment = null; |
boolean connected=false; |
private Cel cel = null; |
60,12 → 66,31 |
public void onInit() { |
locationList.setLocation("all"); |
locationList.updateCount(); |
this.onLocationSelected("all"); |
} |
/** |
* Action suite ajout, modification, suppression element inventaire |
*/ |
public void onInventoryUpdated(String location) { |
locationList.setLocation(location); |
locationList.updateCount(); |
this.onLocationSelected(location); |
} |
/** |
* Action sur selection d'une observation : affichage du detail |
*/ |
80,7 → 105,7 |
/** |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
* Action sur recherche : affichage de la liste des taxons correspondants |
*/ |
public void onSearch(String search) { |
97,6 → 122,7 |
/** |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
* TODO : gerer asynchronicite ? |
*/ |
public void onLocationSelected(String loc) { |
103,68 → 129,86 |
inventoryItemList.setLocation(loc); |
inventoryItemList.setDate("all"); |
inventoryItemList.setStation("all"); |
inventoryItemList.updateCount(); |
dateList.setLocation(loc); |
dateList.setDate("all"); |
dateList.updateCount(); |
stationList.setLocation(loc); |
stationList.setStation("all"); |
stationList.updateCount(); |
if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) { |
locationAssistant.setText(""); |
} |
else { |
locationAssistant.setText(loc); |
} |
} |
/** |
* Action sur selection d'une date : affichage de la liste des taxons correspondants |
* Action sur login |
* @param user |
*/ |
public void onDateSelected(String date) { |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
public void onLogin(String user) { |
/* |
if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) { |
locationAssistant.setText(""); |
this.user=user; |
topPanel.getSignLabel().setText(user+ " (deconnexion)"); |
inventoryItemList.setUser(user); |
dateList.setUser(user); |
stationList.setUser(user); |
entryPanel.setUser(user); |
locationList.setUser(user); |
this.onInit(); |
} |
else { |
locationAssistant.setText(loc); |
} |
/** |
* Action sur logoff |
* @param user |
*/ |
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); |
this.onInit(); |
} |
/** |
* Action posterieure à l'affichage des observations : mise a jour affichage des localites |
* Action sur selection d'une station : affichage de la liste des taxons correspondants |
*/ |
public void onStationSelected(String station) { |
public void onInventoryItemUpdate(String loc) { |
inventoryItemList.setStation(station); |
inventoryItemList.updateCount(); |
locationList.setLocation(loc); |
locationList.updateCount(); |
} |
/** |
* Action posterieure à l'affichage des localites : mise a jour affichage des dates |
* Action sur selection d'une date : affichage de la liste des taxons correspondants |
*/ |
public void onLocationUpdate(String loc) { |
public void onDateSelected(String date) { |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
dateList.setLocation(loc); |
dateList.updateCount(); |
} |
/** |
* Action prealable à l'ajout d'une observation : controle presence champs requis et lancement mise a jour |
* |
252,7 → 296,18 |
} |
/** |
* Declaration StationList |
* @param locationList |
*/ |
public void registerStationList(StationList stationList) { |
this.stationList=stationList; |
} |
/** |
* Declaration Cel |
* @param cel |
325,7 → 380,18 |
this.searchPanel=searchPanel; |
} |
public void registerTopPanel(TopPanel topPanel) { |
this.topPanel=topPanel; |
} |
public void registerLoginDialog(LoginDialog loginDialog) { |
this.loginDialog=loginDialog; |
} |
/** |
* Declaration commentaire |
* @param commentaire |
353,9 → 419,10 |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONString jsonString; |
if ((jsonString = jsonValue.isString()) != null) { |
user = jsonString.stringValue(); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
user = ((JSONString) jsonArray.get(0)).stringValue(); |
connected = ((JSONBoolean) jsonArray.get(1)).booleanValue(); |
} |
cel.initAsync(); |
} |
399,6 → 466,12 |
public void setUser(String user) { |
this.user=user; |
} |
public InventoryItemList getInventoryItemList() { |
return inventoryItemList; |
} |
429,5 → 502,15 |
} |
public void setConnected(boolean connected) { |
this.connected=connected; |
} |
public boolean getConnected() { |
return this.connected; |
} |
} |
/trunk/src/org/tela_botanica/client/LocationList.java |
---|
145,7 → 145,6 |
private String location = "all"; |
private NavBar navBar=null; |
235,9 → 234,11 |
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"); |
} |
268,7 → 269,8 |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location , |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" , |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
276,7 → 278,6 |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
mediator.onLocationUpdate(location); |
update(); |
} |
} |
321,7 → 322,8 |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" + |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + |
+ startIndex + "/" + VISIBLE_LOCATION_COUNT, |
new ResponseTextHandler() { |
479,4 → 481,8 |
navBar.status.setText(text); |
} |
public void setUser(String user) { |
this.user = user; |
} |
} |
/trunk/src/org/tela_botanica/client/InventoryItemList.java |
---|
30,6 → 30,7 |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.Image; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
158,6 → 159,7 |
private String location = "all"; |
private String date = "all"; |
private String search = "all"; |
private String station = "all"; |
private boolean add=false; |
213,7 → 215,7 |
if (table.getWidget(row, 0)!=null) { |
selectRow(row); |
// Numero d'ordre |
mediator.onInventoryItemSelected(table.getText(row, 4)); |
mediator.onInventoryItemSelected(table.getText(row, 5)); |
} |
} |
425,6 → 427,7 |
location="000null"; |
} |
add=true; |
mediator.onInventoryUpdated(location); |
updateCount(); |
} |
}); |
454,8 → 457,8 |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" +ordre + "/", "identifiant=" |
+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user + "/" +ordre + "/", |
"&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ complementLocation + "&commentaire="+ comment, |
464,12 → 467,58 |
public void onCompletion(String str) { |
add=false; |
mediator.onInventoryUpdated(location); |
update(); |
} |
}); |
} |
/** |
* Transmission de releve à Tela |
* |
*/ |
public void transmitElement() { |
setStatusDisabled(); |
Vector parseChecked = new Vector(); |
// TODO : optimiser |
// Lifo ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
// Numero ordre |
parseChecked.add(table.getText(i, 5)); |
} |
} |
} |
StringBuffer ids=new StringBuffer(); |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
if (ids.length()>0) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user |
+ "/" + ids.toString(), "transmission=1", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
update(); |
} |
}); |
} |
setStatusEnabled(); |
} |
/** |
* Suppression d'un element lde l'inventaire, a partir de son numero d'ordre |
* |
478,7 → 527,6 |
public void deleteElement() { |
setStatusDisabled(); |
boolean checked = false; |
Vector parseChecked = new Vector(); |
// TODO : optimiser |
486,9 → 534,8 |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
checked = true; |
// Numero ordre |
parseChecked.add(table.getText(i, 4)); |
parseChecked.add(table.getText(i, 5)); |
count--; |
} |
} |
498,19 → 545,21 |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
if (ids.length()>0) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + ids.toString(), "action=DELETE", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
mediator.onInventoryUpdated("all"); |
updateCount(); |
} |
}); |
} |
if (!checked) { |
setStatusEnabled(); |
} |
} |
/** |
* Selection de l'ensemble des elements affichés |
550,7 → 599,7 |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00"; |
} |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate + "/" + search, |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate + "/" + search + "/" + station, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
566,7 → 615,7 |
*/ |
if (location.compareTo("")==0) |
location="000null"; |
mediator.onInventoryItemUpdate(location); |
// mediator.onInventoryItemUpdate(location); |
gotoEnd(); // Derniere page |
update(); |
} |
606,7 → 655,7 |
} |
else { |
if (location.compareTo("000null")==0) { |
com="Communes non précisées"; |
com="Communes non renseignées"; |
} |
else { |
com="Commune de "+location; |
617,11 → 666,11 |
String dat; |
if (date.compareTo("all")==0) { |
dat=", toute période"; |
dat=", toutes périodes"; |
} |
else { |
if (date.compareTo("00/00/0000")==0) { |
dat=", période non précisé"; |
dat=", périodes non renseignées"; |
} |
else { |
dat=", le "+ date; |
628,9 → 677,25 |
} |
} |
header.setHTML(0, 0, com + dat ); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + |
String stat; |
if (station.compareTo("all")==0) { |
stat=", toutes stations"; |
} |
else { |
if (station.compareTo("000null")==0) { |
stat=", stations non renseignées"; |
} |
else { |
stat=", station "+ station; |
} |
} |
header.setHTML(0, 0, com + dat + stat ); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/" |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
new ResponseTextHandler() { |
646,6 → 711,8 |
StringBuffer right=new StringBuffer(); |
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
665,8 → 732,20 |
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Nom saisi |
// Observation transmise |
String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue(); |
if (atransmit.compareTo("1")==0) { |
table.setWidget(row,1,new Image("tela.gif")); |
} |
else { |
table.setWidget(row,1,new HTML(" ")); |
} |
left.append("<b>"+((JSONString) jsonArrayNested .get(0)).stringValue()+"</b>"); |
// Nom retenu |
737,7 → 816,7 |
// Localisation - Lieu dit |
if (alieudit.compareTo("null")!=0) { |
if (alieudit.compareTo("000null")!=0) { |
center.append(", "+alieudit); |
} |
749,9 → 828,6 |
} |
String adate=((JSONString) jsonArrayNested .get(8)).stringValue(); |
// Date |
763,29 → 839,29 |
} |
table.setHTML(row, 2, subLeft(" "+left,40)); |
table.setHTML(row, 3, subLeft(" "+center,120)); |
table.setHTML(row, 4, subLeft(" "+right,25)); |
table.setHTML(row, 1, subLeft(" "+left,40)); |
table.setHTML(row, 2, subLeft(" "+center,120)); |
table.setHTML(row, 3, subLeft(" "+right,25)); |
table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow"); |
table.getCellFormatter().setWordWrap(row,1,false); |
table.getCellFormatter().setWidth(row,1,"10%"); |
table.getCellFormatter().setWidth(row,0,"2%"); |
table.getCellFormatter().setWidth(row,1,"2%"); |
table.getCellFormatter().setWordWrap(row,2,false); |
table.getCellFormatter().setWidth(row,2,"10%"); |
table.getCellFormatter().setWordWrap(row,3,false); |
table.getCellFormatter().setWidth(row,3,"7%"); |
table.getCellFormatter().setWordWrap(row,4,false); |
table.getCellFormatter().setWidth(row,4,"7%"); |
String aordre=((JSONString) jsonArrayNested.get(7)).stringValue(); |
// Numero d'ordre (caché) |
table.setText(row, 4, aordre); |
table.setText(row, 5, aordre); |
if (add){ |
if (i ==(arraySize -1)) { |
selectRow(row); |
799,7 → 875,7 |
} |
} |
table.getCellFormatter().setVisible(row, 4, false); |
table.getCellFormatter().setVisible(row, 5, false); |
} |
815,7 → 891,8 |
table.setHTML(j,2," "); |
table.setHTML(j,3," "); |
table.setHTML(j,4," "); |
table.getCellFormatter().setVisible(j, 4, false); |
table.setHTML(j,5," "); |
table.getCellFormatter().setVisible(j, 5, false); |
table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow"); |
} |
935,8 → 1012,19 |
} |
public void setUser(String user) { |
this.user = user; |
} |
public void setStation(String station) { |
this.station = station; |
} |
} |
/trunk/src/org/tela_botanica/client/DateList.java |
---|
237,10 → 237,10 |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String loc=table.getText(row,cell); |
date=loc; |
if (loc.compareTo(VALUE_UNKNOWN)!=0) { |
mediator.onDateSelected(table.getText(row,cell)); |
String adate=table.getText(row,cell); |
if (adate.compareTo(VALUE_UNKNOWN)!=0) { |
date=adate; |
mediator.onDateSelected(adate); |
} |
else { |
date="00/00/0000"; |
273,6 → 273,7 |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location + "/"+ station, |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location, |
new ResponseTextHandler() { |
325,6 → 326,7 |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location + "/" + station + "/" |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location + "/" |
+ startIndex + "/" + VISIBLE_DATE_COUNT, |
485,4 → 487,16 |
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/LeftPanel.java |
---|
27,22 → 27,24 |
private LocationList locationList = null; |
private DateList dateList = null; |
private StationList stationList = null; |
public LeftPanel(Mediator mediator) { |
dateList = new DateList(mediator); |
locationList = new LocationList(mediator); |
stationList = new StationList(mediator); |
dateList.setStyleName("dateList"); |
locationList.setStyleName("locationList"); |
locationList.setStyleName("stationList"); |
StackPanel outer = new StackPanel(); |
outer.add(locationList,"Communes"); |
outer.add(dateList,"Dates"); |
// Create the groups within the stack panel. |
outer.add(locationList, "<b>Localités</b>", true); |
outer.add(stationList,"<b>Stations</b>",true); |
outer.add(dateList, "<b>Dates</b>", true); |
/trunk/src/org/tela_botanica/client/StationList.java |
---|
New file |
0,0 → 1,487 |
/* |
* Copyright 2006 Google Inc. |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
* use this file except in compliance with the License. You may obtain a copy of |
* the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
* License for the specific language governing permissions and limitations under |
* the License. |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.DockPanel; |
import com.google.gwt.user.client.ui.FlexTable; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Widget; |
/** |
* A tree displaying a set of email folders. |
*/ |
public class StationList extends Composite { |
// Barre de navigation |
private class NavBar extends Composite implements ClickListener { |
public final DockPanel bar = new DockPanel(); |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
status.setWordWrap(false); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(status); |
buttons.setCellHorizontalAlignment(status, |
HasHorizontalAlignment.ALIGN_RIGHT); |
buttons.setCellVerticalAlignment(status, |
HasVerticalAlignment.ALIGN_MIDDLE); |
buttons.setCellWidth(status, "100%"); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_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(); |
} |
} |
private static final int VISIBLE_STATION_COUNT = 10; |
private static final String VALUE_UNKNOWN = "Inconnues"; |
private Grid header = new Grid(1, 2); |
private Grid selector = new Grid(1, 2); |
private FlexTable table = new FlexTable(); |
private VerticalPanel outer = new VerticalPanel(); |
private VerticalPanel inner = new VerticalPanel(); |
private int startIndex = 0; |
private String user; |
private String serviceBaseUrl = null; |
private String location = "all"; |
private String station = "all"; |
private NavBar navBar=null; |
private int count = 65000; |
// Tous selectionné |
private int selectedRow = -1; |
private Mediator mediator = null; |
public StationList(Mediator med) { |
mediator=med; |
mediator.registerStationList(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
navBar = new NavBar(); |
// Mise en forme du header |
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("station-ListHeader"); |
header.setWidget(0, 1,navBar); |
selector.setCellSpacing(0); |
selector.setCellPadding(0); |
selector.setWidth("100%"); |
selector.setHTML(0, 0, "Toutes"); |
selector.getCellFormatter().setWidth(0, 0, "100%"); |
// Hook up events. |
selector.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "station-SelectedRow"); |
mediator.onStationSelected("all"); |
station="all"; |
} |
}); |
selector.setStyleName("station-ListElement"); |
// Mise en forme du contenu |
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
table.setStyleName("station-ListElement"); |
outer.add(header); |
inner.add(selector); // Toutes station |
inner.add(table); |
inner.setStyleName("station-List"); |
inner.setWidth("100%"); |
outer.setWidth("100%"); |
outer.add(inner); |
// Hook up events. |
table.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String astation=table.getText(row,cell); |
if (astation.compareTo(VALUE_UNKNOWN)!=0) { |
station=astation; |
mediator.onStationSelected(astation); |
} |
else { |
station="000null"; |
mediator.onStationSelected("000null"); |
} |
} |
}); |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "station-SelectedRow"); |
initWidget(outer); |
} |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
* |
*/ |
public void updateCount() { |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + 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 + "/" + 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=((JSONString)jsonArrayNested.get(0)).stringValue(); |
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); |
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_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); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_STATION_COUNT) + " sur " + count ); |
} else { // Derniere page |
setStatusText((startIndex + 1) + " - " + count + " sur " + count ); |
} |
} else { // Premiere page |
if (count > VISIBLE_STATION_COUNT) { // Des pages derrieres |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_STATION_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 setStation(String station) { |
this.station = station; |
} |
} |
/trunk/src/org/tela_botanica/client/EntryPanel.java |
---|
18,11 → 18,14 |
import java.util.Date; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNull; |
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.Window; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ChangeListener; |
import com.google.gwt.user.client.ui.CheckBox; |
83,7 → 86,7 |
VerticalPanel outer = new VerticalPanel(); |
// outer.add(new HTML("<b>Nouvelle observation:</b>")); |
outer.add(new HTML("<b>Saisir un relevé :</b>")); |
101,6 → 104,8 |
locationAssistant = new LocationAssistant(mediator); |
// Saisie Nom |
HTML labelNameAssistant = new HTML("Espèce: "); |
286,14 → 291,51 |
outer.add(inner); |
outer.setCellWidth(inner, "100%"); |
outer.setSpacing(20); |
outer.setSpacing(10); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); |
outer.add(buttonPanel); |
// Initialisation si provenance d'un lien |
if (History.getToken().length()>0) { |
final String anum=History.getToken(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/Name/" + anum, |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
String aname = ((JSONString) jsonArray.get(0)).stringValue(); |
// Nom |
if (aname.compareTo("null")!=0) { |
nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue()); |
// Numero nomenclatural |
nameAssistant.setValue(anum); |
} |
} |
} |
}); |
} |
initWidget(outer); |
373,7 → 415,7 |
String astation=((JSONString) jsonArray .get(9)).stringValue(); |
// Station |
if (astation.compareTo("null")!=0) { |
if (astation.compareTo("000null")!=0) { |
complementLocation.setText(astation); |
} |
else { |
399,5 → 441,8 |
} |
public void setUser(String user) { |
this.user = user; |
} |
} |