Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 14 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 22
Line -... Line 1...
-
 
1
/**
-
 
2
 David Delon david.delon@clapas.net 2007
-
 
3
 
-
 
4
 Ce logiciel est régi par la licence CeCILL soumise au droit français et
-
 
5
 respectant les principes de diffusion des logiciels libres. Vous pouvez
-
 
6
 utiliser, modifier et/ou redistribuer ce programme sous les conditions
-
 
7
 de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA 
-
 
8
 sur le site "http://www.cecill.info".
-
 
9
 En contrepartie de l'accessibilité au code source et des droits de copie,
-
 
10
 de modification et de redistribution accordés par cette licence, il n'est
-
 
11
 offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons,
-
 
12
 seule une responsabilité restreinte pèse sur l'auteur du programme,  le
-
 
13
 titulaire des droits patrimoniaux et les concédants successifs.
-
 
14
 
-
 
15
 A cet égard  l'attention de l'utilisateur est attirée sur les risques
-
 
16
 associés au chargement,  à l'utilisation,  à la modification et/ou au
-
 
17
 développement et à la reproduction du logiciel par l'utilisateur étant 
-
 
18
 donné sa spécificité de logiciel libre, qui peut le rendre complexe à 
-
 
19
 manipuler et qui le réserve donc à des développeurs et des professionnels
-
 
20
 avertis possédant  des  connaissances  informatiques approfondies.  Les
-
 
21
 utilisateurs sont donc invités à charger  et  tester  l'adéquation  du
-
 
22
 logiciel à leurs besoins dans des conditions permettant d'assurer la
-
 
23
 sécurité de leurs systèmes et ou de leurs données et, plus généralement, 
-
 
24
 à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. 
-
 
25
                                                                                                      
-
 
26
 Le fait que vous puissiez accéder à cet en-tête signifie que vous avez 
-
 
27
 pris connaissance de la licence CeCILL, et que vous en avez accepté les
-
 
28
 termes.
-
 
29
 
-
 
30
 */
-
 
31
 
1
/*
32
/*
-
 
33
 * EntryPanel.java  (Composite de Panel)
-
 
34
 * 
2
 * Copyright 2006 Google Inc.
35
 * Cas d'utilisation :
-
 
36
 * Saisie assistee (completion nom et completion commune) de releves. 
-
 
37
 * L'identification n'est pas obligatoire
3
 * 
38
 *
-
 
39
 * 1 : L'utilisateur saisit a minima un nom de plante 
-
 
40
 * 		1: Le nom de plante provient d'une application externe : il est deduit du nuremo nomenclatural transmis en historique
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
41
 * 2 : Le programme assiste la saisie de nom de plante ou de localite par interrogation du systeme distant
5
 * use this file except in compliance with the License. You may obtain a copy of
42
 * 3 : L'utilisateur choisi le type de mise (ajout ou modification)
6
 * the License at
43
 * 3 : L'utilisateur valide sa saisie
-
 
44
 * 4 : Le programme transmet au systeme distant la nouvelle saisie pour l'identifiant en cours
-
 
45
 * 5 : Le programme transmet au systeme local un evenement annoncant une nouvelle saisie
7
 * 
46
 * 
8
 * http://www.apache.org/licenses/LICENSE-2.0
-
 
9
 * 
47
 * 
10
 * Unless required by applicable law or agreed to in writing, software
48
 * Affichage detail d'un observation
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-
 
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-
 
13
 * License for the specific language governing permissions and limitations under
49
 * 1 : Le programme affiche les donnees d'inventaire pour l'identifiant enregistre et pour le numero d'ordre transmis
14
 * the License.
50
 *
15
 */
51
 */
-
 
52
 
-
 
53
 
16
package org.tela_botanica.client;
54
package org.tela_botanica.client;
Line 17... Line 55...
17
 
55
 
Line 18... Line 56...
18
import java.util.Date;
56
import java.util.Date;
19
 
-
 
20
import com.google.gwt.json.client.JSONArray;
57
 
21
import com.google.gwt.json.client.JSONNull;
58
import com.google.gwt.json.client.JSONArray;
22
import com.google.gwt.json.client.JSONParser;
59
import com.google.gwt.json.client.JSONParser;
23
import com.google.gwt.json.client.JSONString;
60
import com.google.gwt.json.client.JSONString;
24
import com.google.gwt.json.client.JSONValue;
61
import com.google.gwt.json.client.JSONValue;
25
import com.google.gwt.user.client.HTTPRequest;
62
import com.google.gwt.user.client.HTTPRequest;
26
import com.google.gwt.user.client.History;
-
 
27
import com.google.gwt.user.client.ResponseTextHandler;
63
import com.google.gwt.user.client.History;
28
import com.google.gwt.user.client.Window;
64
import com.google.gwt.user.client.ResponseTextHandler;
29
import com.google.gwt.user.client.ui.Button;
65
import com.google.gwt.user.client.ui.Button;
30
import com.google.gwt.user.client.ui.ChangeListener;
66
import com.google.gwt.user.client.ui.ChangeListener;
31
import com.google.gwt.user.client.ui.CheckBox;
67
import com.google.gwt.user.client.ui.CheckBox;
Line 38... Line 74...
38
import com.google.gwt.user.client.ui.PopupPanel;
74
import com.google.gwt.user.client.ui.PopupPanel;
39
import com.google.gwt.user.client.ui.TextBox;
75
import com.google.gwt.user.client.ui.TextBox;
40
import com.google.gwt.user.client.ui.VerticalPanel;
76
import com.google.gwt.user.client.ui.VerticalPanel;
41
import com.google.gwt.user.client.ui.Widget;
77
import com.google.gwt.user.client.ui.Widget;
Line 42... Line -...
42
 
-
 
43
/**
-
 
44
 * Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
-
 
Line 45... Line 78...
45
 */
78
 
Line 46... Line 79...
46
 
79
 
47
public class EntryPanel extends Composite   {
80
public class EntryPanel extends Composite   {
48
	
81
	
49
  private NameAssistant nameAssistant = null;
82
  private NameAssistant nameAssistant = null;
50
  private LocationAssistant locationAssistant = null;
83
  private LocationAssistant locationAssistant = null;
51
  TextBox date = new TextBox();
84
  private TextBox date = new TextBox();
52
  TextBox complementLocation = new TextBox();
85
  private TextBox complementLocation = new TextBox();
53
  TextBox comment = new TextBox();
86
  private TextBox comment = new TextBox();
Line 54... Line -...
54
  Button dateSelector = new Button("...");
-
 
Line 55... Line 87...
55
  boolean visible=false;
87
  private Button dateSelector = new Button("...");
56
  Mediator mediator=null;
88
  boolean visible=false;
Line 57... Line 89...
57
 
89
  private Mediator mediator=null;
58
  private String serviceBaseUrl = null;
-
 
59
  
90
 
Line 60... Line 91...
60
  private String user= null;
91
  
Line 61... Line 92...
61
  private String ordre =null;
92
  private String user= null;
62
  
-
 
63
  final CalendarWidget calendar = new CalendarWidget();
-
 
-
 
93
  private String ordre =null;
Line 64... Line 94...
64
  
94
  
Line 65... Line 95...
65
  private PopupPanel choicesPopup = new PopupPanel(true);
95
  private CalendarWidget calendar = null; // Lazy instantiation
66
 
96
  private PopupPanel choicesPopup = null; // Lazy instantiation
67
  public EntryPanel(final Mediator med) {
97
 
Line 68... Line -...
68
	 
-
 
69
	  
-
 
70
   mediator=med;
-
 
71
 
-
 
72
   
-
 
73
   
98
  public EntryPanel(final Mediator med) {
Line 74... Line 99...
74
   mediator.registerEntryPanel(this);
99
	 
Line 75... Line -...
75
   
-
 
76
   mediator.registerDate(date);
100
	  
Line 77... Line 101...
77
   mediator.registerComment(comment);
101
   mediator=med;
78
   mediator.registerComplementLocation(complementLocation);
102
   user=mediator.getUser();
79
   
103
 
Line 102... Line 126...
102
 
126
 
103
	nameAssistant = new NameAssistant(mediator);
127
	nameAssistant = new NameAssistant(mediator);
Line 104... Line -...
104
	locationAssistant = new LocationAssistant(mediator);
-
 
105
	
-
 
106
 
128
	locationAssistant = new LocationAssistant(mediator);
Line 107... Line -...
107
	
-
 
108
	
129
 
109
	// Saisie Nom
130
	
Line 110... Line 131...
110
	
131
	// Saisie Nom
Line 111... Line 132...
111
     HTML labelNameAssistant = new HTML("Espèce: ");
132
	
Line 112... Line -...
112
     inner.setWidget(0,0,labelNameAssistant);
-
 
113
     inner.setWidget(0,1,nameAssistant);
133
     inner.setHTML(0,0,"Espèce: ");
114
    
134
     inner.setWidget(0,1,nameAssistant);
Line 115... Line 135...
115
     nameAssistant.setWidth("100%");
135
    
Line 116... Line 136...
116
 
136
     nameAssistant.setWidth("100%");
Line 117... Line -...
117
	 // Saisie lieu
-
 
Line 118... Line 137...
118
	 
137
 
Line 119... Line 138...
119
     HTML labelLocationAssistant= new HTML("Commune: ");
138
	 // Saisie lieu
Line 134... Line 153...
134
    		  visible=false; 
153
    		  visible=false; 
135
    		  choicesPopup.hide();
154
    		  choicesPopup.hide();
136
    	   }
155
    	   }
137
    	   else {
156
    	   else {
138
    		visible=true; 
157
    		visible=true; 
139
    	    choicesPopup.show();
158
    		if (calendar==null) {  // Lazy instantiation
140
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
159
    		  calendar = new CalendarWidget();
141
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
160
    		  choicesPopup = new PopupPanel(true);
142
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
161
    		  choicesPopup.add(calendar);
143
    	   }
-
 
144
       }
-
 
145
     
-
 
146
     });
-
 
147
     
-
 
148
     calendar.addChangeListener(new ChangeListener() {
162
    		  calendar.addChangeListener(new ChangeListener() {
Line 149... Line 163...
149
 
163
 
Line 150... Line 164...
150
     public void onChange(Widget sender) {
164
    			     public void onChange(Widget sender) {
151
    	 
165
    			    	 
152
       Date dateSelected=calendar.getDate();
-
 
153
       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
166
    			       Date dateSelected=calendar.getDate();
154
       
167
    			       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
155
       visible=false; 
168
    			       visible=false; 
156
       choicesPopup.hide();
169
    			       choicesPopup.hide();
Line -... Line 170...
-
 
170
    			     }
-
 
171
    			     });
157
     }
172
    		  
-
 
173
    	   	}
-
 
174
 
-
 
175
    	    choicesPopup.show();
-
 
176
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
-
 
177
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
-
 
178
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
-
 
179
    	   }
-
 
180
       }
-
 
181
     
158
     });
182
     });
Line 159... Line 183...
159
     
183
     
160
    HTML labelDate= new HTML("Date: ");
184
         
161
    inner.setWidget(2,0,labelDate);
185
    inner.setHTML(2,0,"Date: ");
162
    
186
    
Line 163... Line -...
163
    HorizontalPanel datePanel = new HorizontalPanel();
-
 
164
    datePanel.add(date);
-
 
-
 
187
    HorizontalPanel datePanel = new HorizontalPanel();
Line 165... Line 188...
165
    datePanel.add(dateSelector);
188
    datePanel.add(date);
Line 166... Line 189...
166
    inner.setWidget(2,1,datePanel);
189
    datePanel.add(dateSelector);
167
    
-
 
168
 
-
 
169
    
190
    inner.setWidget(2,1,datePanel);
170
    
191
    
171
    date.addKeyboardListener( new KeyboardListener() {
192
    // Saisie date   
172
 
193
   
173
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
194
    date.addKeyboardListener( new KeyboardListener() {
174
    			  
-
 
175
    			  
-
 
176
    			  if(arg1 == KEY_ENTER)
-
 
177
    			    {
-
 
178
    			     mediator.onAddInventoryItem(); 
195
 
Line 179... Line 196...
179
    			     date.setText("");
196
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
180
    			    }
197
    			  if(arg1 == KEY_ENTER)
Line 181... Line 198...
181
 
198
    			    {
182
    		  }
199
    			     mediator.onAddInventoryItem(); 
Line 183... Line 200...
183
    		  
200
    			     date.setText("");
Line 184... Line -...
184
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) {
-
 
185
    		  }
201
    			    }
186
 
202
    		  }
Line 187... Line 203...
187
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) {
203
    		  
Line 188... Line 204...
188
    		  }
204
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
Line 189... Line 205...
189
    		  
205
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
190
    		  }
-
 
191
    );
-
 
192
    
206
    		  
193
  
207
    		  }
194
 
208
    );
195
	 // Saisie Complement lieu 
209
    
196
	 
210
  
Line 197... Line 211...
197
    HTML labelComplementLocation= new HTML("Station: ");
211
 
Line 198... Line 212...
198
    inner.setWidget(1,2,labelComplementLocation);
212
	 // Saisie Complement de lieu  (station)
199
    inner.setWidget(1,3,complementLocation);
-
 
Line 200... Line 213...
200
 
213
	 
201
    complementLocation.setWidth("100%");
-
 
Line 202... Line 214...
202
 
214
    inner.setHTML(1,2,"Station: ");
203
    
215
    inner.setWidget(1,3,complementLocation);
Line 204... Line 216...
204
    complementLocation.addKeyboardListener( new KeyboardListener() {
216
 
Line 205... Line -...
205
 
-
 
206
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
217
    complementLocation.setWidth("100%");
207
			  
218
 
Line 208... Line 219...
208
			  
219
    
Line 209... Line 220...
209
			  if(arg1 == KEY_ENTER)
220
    complementLocation.addKeyboardListener( new KeyboardListener() {
Line 210... Line 221...
210
			    {
221
 
211
			     mediator.onAddInventoryItem(); 
-
 
212
			     complementLocation.setText("");
-
 
213
			    }
222
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
214
 
223
			  if(arg1 == KEY_ENTER)
215
		  }
224
			    {
216
		  
225
			     mediator.onAddInventoryItem(); 
217
		  public void onKeyUp(Widget arg0, char arg1, int arg2) {
226
			     complementLocation.setText("");
Line 218... Line 227...
218
		  }
227
			    }
Line 219... Line 228...
219
 
228
 
220
		  public void onKeyPress(Widget arg0, char arg1, int arg2) {
-
 
221
		  }
-
 
222
		  
229
		  }
223
		  }
-
 
Line 224... Line 230...
224
    );
230
		  
225
 
231
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
Line 226... Line 232...
226
    
232
 
227
	 // Saisie Commentaire
-
 
-
 
233
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
Line 228... Line 234...
228
	 
234
		  
Line 229... Line 235...
229
    HTML labelComment= new HTML("Notes: ");
235
		  }
Line 230... Line 236...
230
    inner.setWidget(2,2,labelComment);
236
    );
-
 
237
 
231
    inner.setWidget(2,3,comment);
238
    
232
 
239
	 // Saisie Commentaire
233
    comment.setWidth("100%");
-
 
234
 
-
 
235
   
-
 
236
    comment.addKeyboardListener( new KeyboardListener() {
-
 
237
 
-
 
238
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
239
			  
-
 
240
			  
-
 
241
			  if(arg1 == KEY_ENTER)
240
	 
242
			    {
-
 
243
			     mediator.onAddInventoryItem(); 
-
 
244
			     comment.setText("");
241
    inner.setHTML(2,2,"Notes: ");
-
 
242
    inner.setWidget(2,3,comment);
-
 
243
 
245
			    }
244
    comment.setWidth("100%");
246
 
245
 
247
		  }
246
   
Line -... Line 247...
-
 
247
    comment.addKeyboardListener( new KeyboardListener() {
248
		  
248
 
-
 
249
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
249
		  public void onKeyUp(Widget arg0, char arg1, int arg2) {
250
			  if(arg1 == KEY_ENTER)
Line 250... Line 251...
250
		  }
251
			    {
Line 251... Line 252...
251
 
252
			     mediator.onAddInventoryItem(); 
252
		  public void onKeyPress(Widget arg0, char arg1, int arg2) {
253
			     comment.setText("");
253
		  }
254
			    }
Line 254... Line 255...
254
		  
255
 
255
		  }
256
		  }
Line 256... Line 257...
256
  );
257
		  
Line 257... Line 258...
257
 
258
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
Line 258... Line 259...
258
   
259
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
Line 259... Line 260...
259
    Button addButton = new Button("Ajout");
260
		  
260
    Button updateButton = new Button("Modification");
261
		  }
Line 261... Line 262...
261
 
262
  );
Line 262... Line 263...
262
    addButton.addClickListener(
263
 
Line 367... Line 368...
367
	 * 
368
	 * 
368
	 */
369
	 */
Line 369... Line 370...
369
 
370
 
Line 370... Line 371...
370
	public void update() {
371
	public void update() {
Line 371... Line 372...
371
 
372
 
Line 372... Line 373...
372
		HTTPRequest.asyncGet(serviceBaseUrl + "/Inventory/" + user + "/" + ordre, 
373
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre, 
Line 433... Line 434...
433
							}
434
							}
Line 434... Line 435...
434
							
435
							
Line 435... Line -...
435
				}
-
 
436
 
436
				}
437
				
437
 
Line 438... Line 438...
438
				
438
				
Line 439... Line 439...
439
			}
439
			}
440
		});
440
		});
441
 
441
 
Line 442... Line 442...
442
	}
442
	}
-
 
443
 
-
 
444
	public void setUser(String user) {
-
 
445
		this.user = user;
-
 
446
	}
-
 
447