Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 21 → Rev 22

/trunk/src/org/tela_botanica/client/EntryPanel.java
1,24 → 1,61
/**
David Delon david.delon@clapas.net 2007
Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".
En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.
 
A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/
 
/*
* Copyright 2006 Google Inc.
* EntryPanel.java (Composite de Panel)
*
* 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
* Cas d'utilisation :
* Saisie assistee (completion nom et completion commune) de releves.
* L'identification n'est pas obligatoire
*
* 1 : L'utilisateur saisit a minima un nom de plante
* 1: Le nom de plante provient d'une application externe : il est deduit du nuremo nomenclatural transmis en historique
* 2 : Le programme assiste la saisie de nom de plante ou de localite par interrogation du systeme distant
* 3 : L'utilisateur choisi le type de mise (ajout ou modification)
* 3 : L'utilisateur valide sa saisie
* 4 : Le programme transmet au systeme distant la nouvelle saisie pour l'identifiant en cours
* 5 : Le programme transmet au systeme local un evenement annoncant une nouvelle saisie
*
* 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.
* Affichage detail d'un observation
* 1 : Le programme affiche les donnees d'inventaire pour l'identifiant enregistre et pour le numero d'ordre transmis
*
*/
 
 
package org.tela_botanica.client;
 
import java.util.Date;
 
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONNull;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
25,7 → 62,6
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;
40,37 → 76,31
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 {
private NameAssistant nameAssistant = null;
private LocationAssistant locationAssistant = null;
TextBox date = new TextBox();
TextBox complementLocation = new TextBox();
TextBox comment = new TextBox();
Button dateSelector = new Button("...");
private TextBox date = new TextBox();
private TextBox complementLocation = new TextBox();
private TextBox comment = new TextBox();
private Button dateSelector = new Button("...");
boolean visible=false;
Mediator mediator=null;
private Mediator mediator=null;
 
private String serviceBaseUrl = null;
private String user= null;
private String ordre =null;
final CalendarWidget calendar = new CalendarWidget();
private PopupPanel choicesPopup = new PopupPanel(true);
private CalendarWidget calendar = null; // Lazy instantiation
private PopupPanel choicesPopup = null; // Lazy instantiation
 
public EntryPanel(final Mediator med) {
mediator=med;
user=mediator.getUser();
 
mediator.registerEntryPanel(this);
mediator.registerDate(date);
77,19 → 107,13
mediator.registerComment(comment);
mediator.registerComplementLocation(complementLocation);
user=mediator.getUser();
serviceBaseUrl = mediator.getServiceBaseUrl();
 
VerticalPanel outer = new VerticalPanel();
 
outer.add(new HTML("<b>Saisir&nbsp;un&nbsp;relev&eacute;&nbsp;:</b>"));
outer.add(new HTML("<b>Saisir&nbsp;un&nbsp;relev&eacute;&nbsp;:</b>"));
 
Grid inner = new Grid(3,4);
 
for (int i=0; i<3;i++) {
102,14 → 126,11
 
nameAssistant = new NameAssistant(mediator);
locationAssistant = new LocationAssistant(mediator);
 
// Saisie Nom
HTML labelNameAssistant = new HTML("Esp&egrave;ce:&nbsp;");
inner.setWidget(0,0,labelNameAssistant);
inner.setHTML(0,0,"Esp&egrave;ce:&nbsp;");
inner.setWidget(0,1,nameAssistant);
nameAssistant.setWidth("100%");
116,8 → 137,7
 
// Saisie lieu
HTML labelLocationAssistant= new HTML("Commune:&nbsp;");
inner.setWidget(1,0,labelLocationAssistant);
inner.setHTML(1,0,"Commune:&nbsp;");
inner.setWidget(1,1,locationAssistant);
 
locationAssistant.setWidth("100%");
124,7 → 144,6
// Saisie Date
choicesPopup.add(calendar);
dateSelector.addClickListener(new ClickListener () {
136,6 → 155,23
}
else {
visible=true;
if (calendar==null) { // Lazy instantiation
calendar = new CalendarWidget();
choicesPopup = new PopupPanel(true);
choicesPopup.add(calendar);
calendar.addChangeListener(new ChangeListener() {
 
public void onChange(Widget sender) {
Date dateSelected=calendar.getDate();
date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
visible=false;
choicesPopup.hide();
}
});
}
 
choicesPopup.show();
choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
dateSelector.getAbsoluteTop() - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
145,20 → 181,8
});
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:&nbsp;");
inner.setWidget(2,0,labelDate);
inner.setHTML(2,0,"Date:&nbsp;");
HorizontalPanel datePanel = new HorizontalPanel();
datePanel.add(date);
165,27 → 189,20
datePanel.add(dateSelector);
inner.setWidget(2,1,datePanel);
 
// Saisie date
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) {
}
public void onKeyUp(Widget arg0, char arg1, int arg2) { }
public void onKeyPress(Widget arg0, char arg1, int arg2) { }
}
);
192,10 → 209,9
 
// Saisie Complement lieu
// Saisie Complement de lieu (station)
HTML labelComplementLocation= new HTML("Station:&nbsp;");
inner.setWidget(1,2,labelComplementLocation);
inner.setHTML(1,2,"Station:&nbsp;");
inner.setWidget(1,3,complementLocation);
 
complementLocation.setWidth("100%");
204,8 → 220,6
complementLocation.addKeyboardListener( new KeyboardListener() {
 
public void onKeyDown(Widget arg0, char arg1, int arg2) {
if(arg1 == KEY_ENTER)
{
mediator.onAddInventoryItem();
214,11 → 228,9
 
}
public void onKeyUp(Widget arg0, char arg1, int arg2) {
}
public void onKeyUp(Widget arg0, char arg1, int arg2) { }
 
public void onKeyPress(Widget arg0, char arg1, int arg2) {
}
public void onKeyPress(Widget arg0, char arg1, int arg2) { }
}
);
226,8 → 238,7
// Saisie Commentaire
HTML labelComment= new HTML("Notes:&nbsp;");
inner.setWidget(2,2,labelComment);
inner.setHTML(2,2,"Notes:&nbsp;");
inner.setWidget(2,3,comment);
 
comment.setWidth("100%");
236,8 → 247,6
comment.addKeyboardListener( new KeyboardListener() {
 
public void onKeyDown(Widget arg0, char arg1, int arg2) {
if(arg1 == KEY_ENTER)
{
mediator.onAddInventoryItem();
246,55 → 255,47
 
}
public void onKeyUp(Widget arg0, char arg1, int arg2) {
}
 
public void onKeyPress(Widget arg0, char arg1, int arg2) {
}
public void onKeyUp(Widget arg0, char arg1, int arg2) { }
public void onKeyPress(Widget arg0, char arg1, int arg2) { }
}
);
 
Button addButton = new Button("Ajout");
Button updateButton = new Button("Modification");
Button validButton = new Button("Valider");
 
addButton.addClickListener(
validButton.addClickListener(
new ClickListener() {
public void onClick(Widget w) {
if (ordre==null) {
mediator.onAddInventoryItem();
}
}
);
HorizontalPanel buttonPanel = new HorizontalPanel();
updateButton.addClickListener(
new ClickListener() {
public void onClick(Widget w) {
}
else {
mediator.onModifyInventoryItem(ordre);
ordre=null;
}
}
}
);
buttonPanel.add(addButton);
buttonPanel.add(updateButton);
HorizontalPanel actionPanel= new HorizontalPanel();
actionPanel.add(validButton);
 
inner.setWidth("100%");
inner.setWidth("100%");
 
outer.add(inner);
outer.setCellWidth(inner, "100%");
outer.setSpacing(10);
outer.add(inner);
outer.setCellWidth(inner, "100%");
outer.setSpacing(10);
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
outer.add(buttonPanel);
outer.add(actionPanel);
 
 
// Initialisation si provenance d'un lien
303,7 → 304,7
 
final String anum=History.getToken();
 
HTTPRequest.asyncGet(serviceBaseUrl + "/Name/" + anum,
HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Name/" + anum,
new ResponseTextHandler() {
 
public void onCompletion(String strcomplete) {
369,7 → 370,7
 
public void update() {
 
HTTPRequest.asyncGet(serviceBaseUrl + "/Inventory/" + user + "/" + ordre,
HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre,
 
new ResponseTextHandler() {
 
435,7 → 436,6
}
 
}
});
 
446,3 → 446,8
}
 
}
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
*
*/