/trunk/src/org/tela_botanica/client/InventoryItemList.java |
---|
63,10 → 63,13 |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
97,8 → 100,27 |
VerticalPanel actions = new VerticalPanel(); |
HorizontalPanel actionButton = new HorizontalPanel(); |
HTML addButton = new HTML("Nouvelle observation"); |
addButton.setStyleName("html_button"); |
addButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget w) { |
openEntryPanel(); |
} |
} |
); |
actionButton.add(addButton); |
HTML delButton=new HTML("Suppression"); |
delButton.setStyleName("html_button"); |
delButton.addClickListener( |
120,13 → 142,63 |
actions.add(actionButton); |
HorizontalPanel selections = new HorizontalPanel(); |
selections.setSpacing(3); |
selections.add(new HTML("Sélection : ")); |
Label allLabel = new Label("Tous"); |
Label separatorLabel = new Label(","); |
Label noneLabel = new Label("Aucun"); |
allLabel.setStyleName("selection_label"); |
noneLabel.setStyleName("selection_label"); |
selections.add(allLabel); |
allLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
selectAll(); |
} |
} |
); |
selections.add(separatorLabel); |
selections.add(noneLabel); |
noneLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
deselectAll(); |
} |
} |
); |
actionButton.add(selections); |
bar.add(actions, DockPanel.WEST); |
} |
private void openEntryPanel() { |
mediator.onEntryClick(); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
178,21 → 250,8 |
private Mediator mediator = null; |
// Optimization |
int sizeChecked=0; |
int itemDeleted=0; |
// Données alimentant la saisie : texte et valeur localité, texte et valeur communes |
private String nameText=null; |
private String nameValue=null; |
private String locationText=null; |
private String locationValue=null; |
// |
private String location = "all"; |
private String date = "all"; |
public InventoryItemList(Mediator med) { |
215,15 → 274,15 |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("taxon-ListHeader"); |
header.setStyleName("inventoryItem-ListHeader"); |
header.setText(0, 0, ""); |
header.setText(0, 1, "Nom saisi"); |
header.setText(0, 2, "Nom retenu"); |
header.setHTML(0, 3, "Code<br>Nomenclatural"); |
header.setHTML(0, 4, "Code<br>Taxonomique"); |
header.setHTML(0, 1, "Plante observée"); |
header.setHTML(0, 2, "Référence retenue"); |
header.setHTML(0, 3, "Référence<br>Nomenclaturale"); |
header.setHTML(0, 4, "Référence<br>Taxonomique"); |
header.setText(0, 5, "Famille"); |
header.setText(0, 6, "Localisation"); |
header.setText(0, 6, "Commune"); |
header.getCellFormatter().setWidth(0, 0, "2%"); |
header.getCellFormatter().setWidth(0, 1, "31%"); |
244,59 → 303,27 |
navBar.setWidth("100%"); |
table.setStyleName("taxon-List"); |
table.setStyleName("inventoryItem-List"); |
panel.add(navBar); |
panel.add(header); |
panel.add(table); |
HorizontalPanel selections = new HorizontalPanel(); |
selections.setSpacing(3); |
//updateCount(); |
// update() |
selections.add(new HTML("Sélection : ")); |
initWidget(panel); |
Label allLabel = new Label("Tous"); |
Label separatorLabel = new Label(","); |
Label noneLabel = new Label("Aucun"); |
allLabel.setStyleName("selection_label"); |
noneLabel.setStyleName("selection_label"); |
selections.add(allLabel); |
allLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
selectAll(); |
} |
} |
); |
selections.add(separatorLabel); |
selections.add(noneLabel); |
noneLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
deselectAll(); |
} |
} |
); |
panel.add(selections); |
updateCount(); |
// update() |
initWidget(panel); |
} |
/** |
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance |
* la recherche d'informations complémentaires (famille, numero |
307,24 → 334,19 |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, |
String str, String value) { |
// Le nom de plante est requis |
if (mediator.getNameAssistant().getText().compareTo("")==0) { |
return; |
mediator.onAddInventoryItem(); |
} |
nameText=(mediator.getNameAssistant()).getText(); |
nameValue=(mediator.getNameAssistant()).getValue(); |
locationText=(mediator.getLocationAssistant()).getText(); |
locationValue=(mediator.getLocationAssistant()).getValue(); |
public void addelement() { |
// Suppresion indication departementale (on pourrait faire mieux !!) |
int pos=locationText.indexOf(" (" ); |
if (pos>=0) { |
locationText=locationText.substring(0,pos); |
} |
if (mediator.inventoryItemIsValid()) { |
final InventoryItem inventoryItem=mediator.getInventoryItem(); |
setStatusDisabled(); |
// On met a jour rapidement l'affichage puis on lance la requete .... |
341,9 → 363,9 |
// Recherche complement d'information |
if (nameValue !=null) { |
if (inventoryItem.getNomenclaturalNumber() !=null) { |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + nameValue, |
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(), |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
354,7 → 376,7 |
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, |
// Famille |
addElement(nameText, nameValue, |
addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(), |
((JSONString) jsonArray.get(0)) |
.stringValue(), |
((JSONString) jsonArray.get(1)) |
363,7 → 385,7 |
.stringValue(), |
((JSONString) jsonArray.get(3)) |
.stringValue(), |
locationText,locationValue); |
inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment()); |
} |
} |
371,11 → 393,14 |
} |
// Saisie libre |
else { |
addElement(nameText, " ", " ", " ", " ", " ",locationText,locationValue); |
addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment()); |
} |
} |
else { |
return; |
} |
} |
/** |
* Ajoute un element à l'inventaire |
394,8 → 419,8 |
* famille |
*/ |
public 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) { |
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 complementLocation, String comment) { |
// Calcul du nouveau numéro d'ordre |
403,12 → 428,16 |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant=" |
+ user + "&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, |
+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ complementLocation + "&commentaire="+ comment, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
location=loc; |
if (location.compareTo("")==0) { |
location="000null"; |
} |
updateCount(); |
} |
}); |
425,8 → 454,10 |
boolean checked = false; |
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()) { |
checked = true; |
// Numero ordre |
434,23 → 465,21 |
count--; |
} |
} |
sizeChecked=parseChecked.size(); |
itemDeleted=0; |
} |
StringBuffer ids=new StringBuffer(); |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
itemDeleted++; |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + (String) it.next(), "action=DELETE", |
+ "/" + ids.toString(), "action=DELETE", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
// Optimisation : on ne lance la suppression qu'a la fin |
if (itemDeleted==sizeChecked) { |
updateCount(); |
} |
} |
}); |
} |
if (!checked) { |
setStatusEnabled(); |
} |
463,7 → 492,9 |
public void selectAll() { |
// TODO : optimiser ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) |
((CheckBox) table.getWidget(i, 0)).setChecked(true); |
} |
} |
470,7 → 501,9 |
public void deselectAll() { |
// TODO : optimiser ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) |
((CheckBox) table.getWidget(i, 0)).setChecked(false); |
} |
} |
485,7 → 518,12 |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location, |
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 + "/" + location + "/" + adate , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
522,7 → 560,12 |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" |
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 + "/" + location +"/" + adate + "/"+ |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
new ResponseTextHandler() { |
533,6 → 576,7 |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
int row=0; |
int i=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
545,55 → 589,104 |
else { |
row = i; |
} |
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Nom saisi |
table.setText(row, 1, ((JSONString) jsonArrayNested |
.get(0)).stringValue()); |
// Nom retenu |
table.setText(row, 2, ((JSONString) jsonArrayNested |
.get(2)).stringValue()); |
String aname=((JSONString) jsonArrayNested .get(2)).stringValue(); |
if (aname.compareTo("null")==0) { |
table.setText(row, 2, ""); |
} |
else { |
table.setText(row, 2, aname); |
} |
// Num nomenclatural |
table.setText(row, 3, ((JSONString) jsonArrayNested |
.get(1)).stringValue()); |
String ann=((JSONString) jsonArrayNested .get(3)).stringValue(); |
if (ann.compareTo("0")==0) { |
table.setText(row, 3, ""); |
} |
else { |
table.setText(row, 3, ann); |
} |
// Num Taxonomique |
table.setText(row, 4, ((JSONString) jsonArrayNested |
.get(4)).stringValue()); |
String ant=((JSONString) jsonArrayNested .get(4)).stringValue(); |
if (ant.compareTo("0")==0) { |
table.setText(row, 4, ""); |
} |
else { |
table.setText(row, 4, ann); |
} |
// Famille |
table.setText(row, 5, ((JSONString) jsonArrayNested |
.get(5)).stringValue()); |
String afamily=((JSONString) jsonArrayNested .get(5)).stringValue(); |
if (afamily.compareTo("null")==0) { |
table.setText(row, 5, ""); |
} |
else { |
table.setText(row, 5, afamily); |
} |
table.getFlexCellFormatter().setWidth(row, 0, "2%"); |
table.getFlexCellFormatter() |
.setWidth(row, 1, "31%"); |
table.getFlexCellFormatter() |
.setWidth(row, 2, "31%"); |
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter().setWidth(row, 5, "9%"); |
// TODO : Bool ici non ? |
// Affichage contenu commune si tout demandé. |
String aloc=((JSONString) jsonArrayNested .get(6)).stringValue(); |
if (location.compareTo("all")==0) { |
// Localisation - Lieu |
String aloc=((JSONString) jsonArrayNested .get(6)).stringValue(); |
if (aloc.compareTo("000null")==00) { |
if (aloc.compareTo("000null")==0) { |
table.setText(row, 6, "Inconnu"); |
} |
else { |
table.setText(row, 6, ((JSONString) jsonArrayNested .get(6)).stringValue()); |
table.setText(row, 6, aloc ); |
} |
header.getCellFormatter().setVisible(0, 6,true); |
table.getFlexCellFormatter().setWidth(row, 1, "31%"); |
table.getFlexCellFormatter().setWidth(row, 2, "31%"); |
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter().setWidth(row, 5, "9%"); |
table.getFlexCellFormatter().setWidth(row, 6, "9%"); |
} |
else { |
header.getCellFormatter().setVisible(0, 6,false); |
table.getCellFormatter().setVisible(row, 6,false); |
table.getFlexCellFormatter().setWidth(row, 1, "36%"); |
table.getFlexCellFormatter().setWidth(row, 2, "36%"); |
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter().setWidth(row, 5, "8%"); |
} |
table.getFlexCellFormatter().setWidth(row, 6, "9%"); |
// Numero d'ordre (caché) |
table.setText(row, 7, ((JSONString) jsonArrayNested |
606,6 → 699,8 |
} |
} |
// Suppression fin ancien affichage |
if (i<table.getRowCount()-1) { |
for (int j = table.getRowCount() - 1; j > i-1; j--) { |
709,7 → 804,13 |
public void setDate(String date) { |
this.date = date; |
} |
} |
/trunk/src/org/tela_botanica/client/DateList.java |
---|
New file |
0,0 → 1,505 |
/* |
* 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 DateList extends Composite { |
// Barre de navigation |
private class NavBar extends Composite implements ClickListener { |
public final DockPanel bar = new DockPanel(); |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
status.setWordWrap(false); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(status); |
buttons.setCellHorizontalAlignment(status, |
HasHorizontalAlignment.ALIGN_RIGHT); |
buttons.setCellVerticalAlignment(status, |
HasVerticalAlignment.ALIGN_MIDDLE); |
buttons.setCellWidth(status, "100%"); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
} |
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_DATE_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_DATE_COUNT; |
} else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_DATE_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} else { |
if (sender == gotoEnd) { |
gotoEnd(); |
} else { |
if (sender == gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
} |
private static final int VISIBLE_DATE_COUNT = 10; |
private static final String VALUE_UNKNOWN = "Inconnues"; |
private Grid header = new Grid(1, 1); |
private Grid selector = new Grid(1, 1); |
private FlexTable table = new FlexTable(); |
private VerticalPanel outer = new VerticalPanel(); |
private VerticalPanel inner = new VerticalPanel(); |
private int startIndex = 0; |
private String user; |
private String serviceBaseUrl = null; |
private String location = "all"; |
private String date = "all"; |
private NavBar navBar=null; |
private int count = 65000; |
// Tous selectionné |
private int selectedRow = -1; |
private Mediator mediator = null; |
public DateList(Mediator med) { |
mediator=med; |
mediator.registerDateList(this); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
navBar = new NavBar(); |
// Mise en forme du header |
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
header.setStyleName("date-ListHeader"); |
String com; |
if (location.compareTo("all")==0) { |
com="toutes communes"; |
} |
else { |
com=location; |
} |
header.setHTML(0, 0, "Dates observations "+com); // yeah ! |
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"); |
// Mise en forme barre navigation |
outer.add(navBar); |
navBar.setWidth("100%"); |
outer.add(header); |
inner.add(selector); // Toutes localités |
inner.add(table); |
inner.setStyleName("date-List"); |
inner.setWidth("100%"); |
outer.setWidth("100%"); |
outer.add(inner); |
// Hook up events. |
table.addTableListener(new TableListener () { |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String loc=table.getText(row,cell); |
date=loc; |
if (loc.compareTo(VALUE_UNKNOWN)!=0) { |
mediator.onDateSelected(table.getText(row,cell)); |
} |
else { |
mediator.onDateSelected("00/00/0000"); |
} |
} |
}); |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "date-SelectedRow"); |
//updateCount(); |
// update() |
initWidget(outer); |
} |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
* |
*/ |
public void updateCount() { |
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + 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 + "/" + location + "/" |
+ startIndex + "/" + VISIBLE_DATE_COUNT, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
String com; |
if (location.compareTo("all")==0) { |
com="toutes communes"; |
} |
else { |
com=location; |
} |
header.setHTML(0, 0, "Dates observations "+com); // yeah ! |
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) { |
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()-1) { |
for (int j = table.getRowCount() - 1; j > i-1; 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); |
} |
} |
/trunk/src/org/tela_botanica/client/LeftPanel.java |
---|
27,16 → 27,23 |
public class LeftPanel extends Composite { |
private LocationList locationList = null; |
private DateList dateList = null; |
public LeftPanel(Mediator mediator) { |
HorizontalPanel inner = new HorizontalPanel(); |
dateList = new DateList(mediator); |
locationList = new LocationList(mediator); |
dateList.setStyleName("dateList"); |
locationList.setStyleName("locationList"); |
VerticalPanel outer = new VerticalPanel(); |
outer.add(inner); |
outer.add(locationList); |
outer.add(dateList); |
outer.setCellHeight(inner,"100%"); |
initWidget(outer); |
/trunk/src/org/tela_botanica/client/InventoryItem.java |
---|
New file |
0,0 → 1,73 |
package org.tela_botanica.client; |
public class InventoryItem { |
private String name=null; |
private String nomenclaturalNumber=null; |
private String location=null; |
private String location_id=null; |
private String date=null; |
private String complementlocation=null; |
private String comment=null; |
public InventoryItem(String name,String nomenclaturalNumber, String location, String location_id, String date, String complementlocation, String comment) { |
this.name=name; |
this.nomenclaturalNumber=nomenclaturalNumber; |
// Suppresion indication departementale (on pourrait faire mieux !!) |
int pos=location.indexOf(" (" ); |
if (pos>=0) { |
this.location=location.substring(0,pos); |
} |
else { |
this.location=location; |
} |
this.location_id=location_id; |
this.date=date; |
this.complementlocation=complementlocation; |
this.comment=comment; |
} |
public String getLocation() { |
return location; |
} |
public String getLocation_id() { |
return location_id; |
} |
public String getName() { |
return name; |
} |
public String getNomenclaturalNumber() { |
return nomenclaturalNumber; |
} |
public String getComment() { |
return comment; |
} |
public String getComplementlocation() { |
return complementlocation; |
} |
public String getDate() { |
return date; |
} |
} |
/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBox.java |
---|
120,9 → 120,6 |
} |
/** |
* Not used at all |
*/ |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
/trunk/src/org/tela_botanica/client/CalendarWidget.java |
---|
New file |
0,0 → 1,262 |
package org.tela_botanica.client; |
import java.util.Date; |
import com.google.gwt.user.client.DOM; |
import com.google.gwt.user.client.Element; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ChangeListener; |
import com.google.gwt.user.client.ui.ChangeListenerCollection; |
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.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HasAlignment; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.SourcesChangeEvents; |
import com.google.gwt.user.client.ui.Widget; |
public class CalendarWidget extends Composite |
implements ClickListener, SourcesChangeEvents { |
private class NavBar extends Composite implements ClickListener { |
public final DockPanel bar = new DockPanel(); |
public final Button prevMonth = new Button("<", this); |
public final Button prevYear = new Button("<<", this); |
public final Button nextYear = new Button(">>", this); |
public final Button nextMonth = new Button(">", this); |
public final HTML title = new HTML(); |
private final CalendarWidget calendar; |
public NavBar(CalendarWidget calendar) { |
this.calendar = calendar; |
setWidget(bar); |
bar.setStyleName("navbar"); |
title.setStyleName("header"); |
HorizontalPanel prevButtons = new HorizontalPanel(); |
prevButtons.add(prevYear); |
prevButtons.add(prevMonth); |
HorizontalPanel nextButtons = new HorizontalPanel(); |
nextButtons.add(nextMonth); |
nextButtons.add(nextYear); |
bar.add(prevButtons, DockPanel.WEST); |
bar.setCellHorizontalAlignment(prevButtons, DockPanel.ALIGN_LEFT); |
bar.add(nextButtons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(nextButtons, DockPanel.ALIGN_RIGHT); |
bar.add(title, DockPanel.CENTER); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
bar.setCellHorizontalAlignment(title, HasAlignment.ALIGN_CENTER); |
bar.setCellVerticalAlignment(title, HasAlignment.ALIGN_MIDDLE); |
bar.setCellWidth(title, "100%"); |
} |
public void onClick(Widget sender) { |
if (sender == prevMonth) { |
calendar.prevMonth(); |
} else if (sender == prevYear) { |
calendar.prevYear(); |
} else if (sender == nextYear) { |
calendar.nextYear(); |
} else if (sender == nextMonth) { |
calendar.nextMonth(); |
} |
} |
} |
private static class CellHTML extends HTML { |
private int day; |
public CellHTML(String text, int day) { |
super(text); |
this.day = day; |
} |
public int getDay() { |
return day; |
} |
} |
private final NavBar navbar = new NavBar(this); |
private final DockPanel outer = new DockPanel(); |
private final Grid grid = new Grid(6, 7) { |
public boolean clearCell(int row, int column) { |
boolean retValue = super.clearCell(row, column); |
Element td = getCellFormatter().getElement(row, column); |
DOM.setInnerHTML(td, ""); |
return retValue; |
} |
}; |
private Date date = new Date(); |
private ChangeListenerCollection changeListeners; |
private String[] days = new String[] { "Dimanche", "Lundi", "Mardi", |
"Mercredi", "Jeudi", "Vendredi", "Samedi" }; |
private String[] months = new String[] { "Janvier", "Fevrier", "Mars", |
"Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", |
"Novembre", "Decembre" }; |
public CalendarWidget() { |
setWidget(outer); |
grid.setStyleName("table"); |
grid.setCellSpacing(0); |
outer.add(navbar, DockPanel.NORTH); |
outer.add(grid, DockPanel.CENTER); |
drawCalendar(); |
setStyleName("CalendarWidget"); |
} |
private void drawCalendar() { |
int year = getYear(); |
int month = getMonth(); |
int day = getDay(); |
setHeaderText(year, month); |
grid.getRowFormatter().setStyleName(0, "weekheader"); |
for (int i = 0; i < days.length; i++) { |
grid.getCellFormatter().setStyleName(0, i, "days"); |
grid.setText(0, i, days[i].substring(0, 3)); |
} |
Date now = new Date(); |
int sameDay = now.getDate(); |
int today = (now.getMonth() == month && now.getYear()+1900 == year) ? sameDay : 0; |
int firstDay = new Date(year - 1900, month, 1).getDay(); |
int numOfDays = getDaysInMonth(year, month); |
int j = 0; |
for (int i = 1; i < 6; i++) { |
for (int k = 0; k < 7; k++, j++) { |
int displayNum = (j - firstDay + 1); |
if (j < firstDay || displayNum > numOfDays) { |
grid.getCellFormatter().setStyleName(i, k, "empty"); |
grid.setHTML(i, k, " "); |
} else { |
HTML html = new CellHTML( |
"<span>" + String.valueOf(displayNum) + "</span>", |
displayNum); |
html.addClickListener(this); |
grid.getCellFormatter().setStyleName(i, k, "cell"); |
if (displayNum == today) { |
grid.getCellFormatter().addStyleName(i, k, "today"); |
} else if (displayNum == sameDay) { |
grid.getCellFormatter().addStyleName(i, k, "day"); |
} |
grid.setWidget(i, k, html); |
} |
} |
} |
} |
protected void setHeaderText(int year, int month) { |
navbar.title.setText(months[month] + ", " + year); |
} |
private int getDaysInMonth(int year, int month) { |
switch (month) { |
case 1: |
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) |
return 29; // leap year |
else |
return 28; |
case 3: |
return 30; |
case 5: |
return 30; |
case 8: |
return 30; |
case 10: |
return 30; |
default: |
return 31; |
} |
} |
public void prevMonth() { |
int month = getMonth() - 1; |
if (month < 0) { |
setDate(getYear() - 1, 11, getDay()); |
} else { |
setMonth(month); |
} |
drawCalendar(); |
} |
public void nextMonth() { |
int month = getMonth() + 1; |
if (month > 11) { |
setDate(getYear() + 1, 0, getDay()); |
} else { |
setMonth(month); |
} |
drawCalendar(); |
} |
public void prevYear() { |
setYear(getYear() - 1); |
drawCalendar(); |
} |
public void nextYear() { |
setYear(getYear() + 1); |
drawCalendar(); |
} |
private void setDate(int year, int month, int day) { |
date = new Date(year - 1900, month, day); |
} |
private void setYear(int year) { |
date.setYear(year - 1900); |
} |
private void setMonth(int month) { |
date.setMonth(month); |
} |
public int getYear() { |
return 1900 + date.getYear(); |
} |
public int getMonth() { |
return date.getMonth(); |
} |
public int getDay() { |
return date.getDate(); |
} |
public Date getDate() { |
return date; |
} |
public void onClick(Widget sender) { |
CellHTML cell = (CellHTML)sender; |
setDate(getYear(), getMonth(), cell.getDay()); |
drawCalendar(); |
if (changeListeners != null) { |
changeListeners.fireChange(this); |
} |
} |
public void addChangeListener(ChangeListener listener) { |
if (changeListeners == null) |
changeListeners = new ChangeListenerCollection(); |
changeListeners.add(listener); |
} |
public void removeChangeListener(ChangeListener listener) { |
if (changeListeners != null) |
changeListeners.remove(listener); |
} |
} |
/trunk/src/org/tela_botanica/client/EntryPanel.java |
---|
New file |
0,0 → 1,301 |
/* |
* 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 java.util.Date; |
import com.google.gwt.user.client.DOM; |
import com.google.gwt.user.client.Element; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ChangeListener; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.KeyboardListener; |
import com.google.gwt.user.client.ui.PopupPanel; |
import com.google.gwt.user.client.ui.RootPanel; |
import com.google.gwt.user.client.ui.TextBox; |
import com.google.gwt.user.client.ui.UIObject; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Widget; |
/** |
* Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget() |
*/ |
public class EntryPanel extends Composite implements ClickListener { |
private NameAssistant nameAssistant = null; |
private LocationAssistant locationAssistant = null; |
TextBox date = new TextBox(); |
TextBox complementLocation = new TextBox(); |
TextBox comment = new TextBox(); |
Button dateSelector = new Button("..."); |
boolean visible=false; |
Mediator mediator=null; |
final CalendarWidget calendar = new CalendarWidget(); |
private PopupPanel choicesPopup = new PopupPanel(true); |
public EntryPanel(final Mediator med) { |
mediator=med; |
mediator.registerEntryPanel(this); |
mediator.registerDate(date); |
mediator.registerComment(comment); |
mediator.registerComplementLocation(complementLocation); |
VerticalPanel outer = new VerticalPanel(); |
outer.add(new HTML("<b>Nouvelle observation:</b>")); |
Grid inner = new Grid(3,4); |
for (int i=0; i<3;i++) { |
inner.getCellFormatter().setWidth(i, 0, "3%"); |
inner.getCellFormatter().setWidth(i, 1, "47%"); |
inner.getCellFormatter().setWidth(i, 2, "3%"); |
inner.getCellFormatter().setWidth(i, 3, "47%"); |
} |
nameAssistant = new NameAssistant(mediator); |
locationAssistant = new LocationAssistant(mediator); |
// Saisie Nom |
HTML labelNameAssistant = new HTML("Espèce: "); |
inner.setWidget(0,0,labelNameAssistant); |
inner.setWidget(0,1,nameAssistant); |
nameAssistant.setWidth("100%"); |
// Saisie lieu |
HTML labelLocationAssistant= new HTML("Commune: "); |
inner.setWidget(1,0,labelLocationAssistant); |
inner.setWidget(1,1,locationAssistant); |
locationAssistant.setWidth("100%"); |
// Saisie Date |
choicesPopup.add(calendar); |
dateSelector.addClickListener(new ClickListener () { |
public void onClick(Widget w) { |
if (visible) { |
visible=false; |
choicesPopup.hide(); |
} |
else { |
visible=true; |
choicesPopup.show(); |
choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(), |
dateSelector.getAbsoluteTop() + dateSelector.getOffsetHeight()); |
choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px"); |
} |
} |
}); |
calendar.addChangeListener(new ChangeListener() { |
public void onChange(Widget sender) { |
Date dateSelected=calendar.getDate(); |
date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900)); |
visible=false; |
choicesPopup.hide(); |
} |
}); |
HTML labelDate= new HTML("Date: "); |
inner.setWidget(2,0,labelDate); |
HorizontalPanel datePanel = new HorizontalPanel(); |
datePanel.add(date); |
datePanel.add(dateSelector); |
inner.setWidget(2,1,datePanel); |
date.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
mediator.onAddInventoryItem(); |
date.setText(""); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
} |
public void onKeyPress(Widget arg0, char arg1, int arg2) { |
} |
} |
); |
// Saisie Complement lieu |
HTML labelComplementLocation= new HTML("Station: "); |
inner.setWidget(1,2,labelComplementLocation); |
inner.setWidget(1,3,complementLocation); |
complementLocation.setWidth("100%"); |
complementLocation.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
mediator.onAddInventoryItem(); |
complementLocation.setText(""); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
} |
public void onKeyPress(Widget arg0, char arg1, int arg2) { |
} |
} |
); |
// Saisie Commentaire |
HTML labelComment= new HTML("Notes: "); |
inner.setWidget(2,2,labelComment); |
inner.setWidget(2,3,comment); |
comment.setWidth("100%"); |
comment.addKeyboardListener( new KeyboardListener() { |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
mediator.onAddInventoryItem(); |
comment.setText(""); |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
} |
public void onKeyPress(Widget arg0, char arg1, int arg2) { |
} |
} |
); |
inner.setWidth("100%"); |
outer.add(inner); |
outer.setCellWidth(inner, "100%"); |
Button close = new Button("Cacher"); |
close.addClickListener(this); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); |
outer.add(close); |
initWidget(outer); |
setPixelSize(1000,200); |
} |
public void onClick(Widget sender) { |
hide(); |
} |
public void show() { |
DOM.setStyleAttribute(getElement(), "backgroundColor", "white"); |
this.setOpacity(this,85); |
RootPanel.get().remove(this); |
RootPanel.get().add(this,200,200); |
} |
public void hide() { |
this.setOpacity(RootPanel.get(),100); |
RootPanel.get().remove(this); |
} |
private void setOpacity(UIObject e, int percentage) { |
if ( percentage > 100 ) percentage = 100; |
if ( percentage < 0 ) percentage = 0; |
String opac; |
if ( percentage == 100 ) opac = "1"; |
else if ( percentage == 0 ) opac = "0"; |
else if ( percentage < 10 ) opac = ".0" + percentage; |
else opac = "." + percentage; |
Element h = e.getElement(); |
DOM.setStyleAttribute(h, "filter", "alpha(opacity=" + percentage + ")"); |
DOM.setStyleAttribute(h, "opacity", opac); |
} |
} |
/trunk/src/org/tela_botanica/client/TopPanel.java |
---|
16,7 → 16,6 |
package org.tela_botanica.client; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.DockPanel; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.VerticalPanel; |
27,61 → 26,20 |
public class TopPanel extends Composite { |
private NameAssistant nameAssistant = null; |
private LocationAssistant locationAssistant = null; |
public TopPanel(final Mediator mediator) { |
public TopPanel(final Mediator med) { |
VerticalPanel outer = new VerticalPanel(); |
VerticalPanel inner = new VerticalPanel(); |
nameAssistant = new NameAssistant(mediator); |
locationAssistant = new LocationAssistant(mediator); |
DockPanel namePanel = new DockPanel(); |
DockPanel locationPanel = new DockPanel(); |
HTML labelNameAssistant = new HTML("Nom: "); |
namePanel.add(labelNameAssistant,DockPanel.WEST); |
namePanel.add (nameAssistant,DockPanel.CENTER); |
nameAssistant.setWidth("100%"); |
namePanel.setCellWidth(labelNameAssistant,"7%"); |
namePanel.setCellWidth(nameAssistant,"93%"); |
namePanel.setWidth("50%"); |
HTML labelLocationAssistant= new HTML("Lieu: "); |
locationPanel.add(labelLocationAssistant,DockPanel.WEST); |
locationPanel.add (locationAssistant,DockPanel.CENTER); |
locationAssistant.setWidth("100%"); |
locationPanel.setCellWidth(locationAssistant,"7%"); |
locationPanel.setCellWidth(locationAssistant,"93%"); |
locationPanel.setWidth("50%"); |
inner.add(namePanel); |
inner.add(locationPanel); |
inner.setCellWidth(namePanel,"50%"); |
inner.setCellWidth(locationPanel,"50%"); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); |
outer.add(new HTML("<b>Carnet en ligne</b>")); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); |
outer.add(inner); |
inner.setWidth("100%"); |
initWidget(outer); |
} |
/trunk/src/org/tela_botanica/client/CenterPanel.java |
---|
20,6 → 20,8 |
inventoryItemList = new InventoryItemList(mediator); |
inventoryItemList.setStyleName("inventoryItemList"); |
VerticalPanel outer = new VerticalPanel(); |
outer.add(inventoryItemList); |
/trunk/src/org/tela_botanica/client/Cel.java |
---|
16,6 → 16,7 |
private TopPanel topPanel = null; |
private CenterPanel centerPanel = null; |
private LeftPanel leftPanel = null; |
private EntryPanel entryPanel = null; |
private Mediator mediator = null; |
37,16 → 38,19 |
centerPanel = new CenterPanel(mediator); |
topPanel = new TopPanel(mediator); |
leftPanel = new LeftPanel(mediator); |
entryPanel = new EntryPanel(mediator); |
// Information haut de page (nom application, connexion ... etc). |
// A regler |
topPanel.setWidth("100%"); |
entryPanel.setStyleName("item-Input"); |
// DockPanel permet d'arranger plusieurs panneaux au coins cardinaux, le panneau central remplissant |
// l'espace laissé. |
55,6 → 59,7 |
outer.add(topPanel, DockPanel.NORTH); |
outer.add(centerPanel, DockPanel.CENTER); |
outer.add(leftPanel, DockPanel.WEST); |
// outer.add(bottomPanel, DockPanel.SOUTH); |
centerPanel.setWidth("100%"); |
// LeftPanel : |
68,12 → 73,18 |
// Window.enableScrolling(false); |
Window.setMargin("0px"); |
mediator.onInit(); |
entryPanel.show(); |
RootPanel.get().add(outer); |
} |
} |
/trunk/src/org/tela_botanica/client/Mediator.java |
---|
10,6 → 10,7 |
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.TextBox; |
public class Mediator { |
18,9 → 19,19 |
private String user = null; |
private InventoryItemList inventoryItemList = null; |
private LocationList locationList = null; |
private DateList dateList = null; |
private NameAssistant nameAssistant=null; |
private LocationAssistant locationAssistant=null; |
private InventoryItem inventoryItem=null; |
private EntryPanel entryPanel=null; |
private TextBox date = null; |
private TextBox complementLocation = null; |
private TextBox comment = null; |
private Cel cel = null; |
39,16 → 50,36 |
} |
/** |
* Action initialisation |
*/ |
public void onInit() { |
this.onLocationSelected("all"); |
} |
public void onEntryClick() { |
this.entryPanel.show(); |
} |
/** |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
* |
*/ |
public void onLocationSelected(String loc) { |
inventoryItemList.setLocation(loc); |
inventoryItemList.setDate("all"); |
inventoryItemList.updateCount(); |
if (entryPanel!=null) { |
if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) { |
locationAssistant.setText(""); |
} |
58,11 → 89,39 |
} |
} |
/** |
* Action sur ajout d'un taxon : affichage du lieu corresondant |
* Action sur selection d'une date : affichage de la liste des taxons correspondants |
*/ |
public void onDateSelected(String date) { |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
/* |
if (entryPanel!=null) { |
if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) { |
locationAssistant.setText(""); |
} |
else { |
locationAssistant.setText(loc); |
} |
} |
*/ |
} |
/** |
* Action posterieure à l'affichage des observations : mise a jour affichage des localites |
*/ |
public void onInventoryItemUpdate(String loc) { |
locationList.setLocation(loc); |
70,7 → 129,61 |
} |
/** |
* Action posterieure à l'affichage des localites : mise a jour affichage des dates |
*/ |
public void onLocationUpdate(String loc) { |
dateList.setLocation(loc); |
dateList.updateCount(); |
} |
/** |
* Action prealable à l'ajout d'une observation : controle presence champs requis et lancement mise a jour |
* |
*/ |
public void onAddInventoryItem() { |
// TODO : singleton ? |
registerInventoryItem(new InventoryItem(nameAssistant.getText(),nameAssistant.getValue(),locationAssistant.getText(),locationAssistant.getValue(),date.getText(),complementLocation.getText(),comment.getText())); |
inventoryItemList.addelement(); |
} |
public boolean inventoryItemIsValid() { |
// TODO : controle date |
if (inventoryItem.getName().compareTo("")==0) { |
return false; |
} |
else { |
return true; |
} |
} |
/** |
* Declaration InventoryItem |
* @param cel |
*/ |
public void registerInventoryItem(InventoryItem inventoryItem) { |
this.inventoryItem=inventoryItem; |
} |
/** |
* Declaration InventoryItemList |
* @param inventoryItemList |
*/ |
91,7 → 204,21 |
this.locationList=locationList; |
} |
/** |
* Declaration DateList |
* @param locationList |
*/ |
public void registerDateList(DateList dateList) { |
this.dateList=dateList; |
} |
/** |
* Declaration Cel |
* @param cel |
*/ |
123,7 → 250,49 |
} |
/** |
* Declaration date |
* @param date |
*/ |
public void registerDate(TextBox date) { |
this.date=date; |
} |
/** |
* Declaration complementLocation |
* @param complementLocation |
*/ |
public void registerComplementLocation(TextBox complementLocation) { |
this.complementLocation=complementLocation; |
} |
public void registerEntryPanel(EntryPanel entryPanel) { |
this.entryPanel=entryPanel; |
} |
/** |
* Declaration commentaire |
* @param commentaire |
*/ |
public void registerComment(TextBox comment) { |
this.comment=comment; |
} |
/** |
* Recherche distante et asynchrone de l'utilisateur connecté, en retour lancement methode initialisation |
* de l'appellant Cel. (initAsync) |
* |
191,6 → 360,11 |
return locationList; |
} |
public DateList getDateList() { |
return dateList; |
} |
public NameAssistant getNameAssistant() { |
return nameAssistant; |
} |
199,6 → 373,14 |
return locationAssistant; |
} |
public InventoryItem getInventoryItem() { |
return inventoryItem; |
} |
public EntryPanel getEntryPanel() { |
return entryPanel; |
} |
} |
/trunk/src/org/tela_botanica/client/LocationList.java |
---|
125,7 → 125,7 |
private static final int VISIBLE_LOCATION_COUNT = 15; |
private static final int VISIBLE_LOCATION_COUNT = 10; |
private static final String VALUE_UNKNOWN = "Inconnues"; |
private Grid header = new Grid(1, 1); |
177,7 → 177,7 |
header.setStyleName("location-ListHeader"); |
header.setHTML(0, 0, "Localités "); // yeah ! |
header.setHTML(0, 0, "Relevés par commune "); // yeah ! |
header.getCellFormatter().setWidth(0, 0, "100%"); |
250,10 → 250,10 |
styleRow(selectedRow, false); |
selector.getRowFormatter().addStyleName(0, "location-SelectedRow"); |
mediator.onLocationSelected("all"); |
// mediator.onLocationSelected("all"); |
updateCount(); |
//updateCount(); |
// update() |
initWidget(outer); |
279,6 → 279,7 |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
mediator.onLocationUpdate(location); |
update(); |
} |
} |
/trunk/src/org/tela_botanica/public/Cel.css |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |