Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 14 | Go to most recent revision | Show entire file | Ignore 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
/*
2
 * Copyright 2006 Google Inc.
33
 * EntryPanel.java  (Composite de Panel)
3
 * 
34
 * 
-
 
35
 * Cas d'utilisation :
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
36
 * Saisie assistee (completion nom et completion commune) de releves. 
-
 
37
 * L'identification n'est pas obligatoire
-
 
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
-
 
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;
-
 
93
  private String ordre =null;
Line 62... Line -...
62
  
-
 
63
  final CalendarWidget calendar = new CalendarWidget();
-
 
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;
-
 
Line 71... Line -...
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 100... Line 124...
100
   }
124
   }
Line 101... Line 125...
101
 
125
 
102
 
126
 
103
	nameAssistant = new NameAssistant(mediator);
-
 
Line 104... Line -...
104
	locationAssistant = new LocationAssistant(mediator);
-
 
105
	
127
	nameAssistant = new NameAssistant(mediator);
Line 106... Line -...
106
 
-
 
107
	
128
	locationAssistant = new LocationAssistant(mediator);
108
	
129
 
Line 109... Line 130...
109
	// Saisie Nom
130
	
Line 110... Line 131...
110
	
131
	// Saisie Nom
Line 111... Line -...
111
     HTML labelNameAssistant = new HTML("Espèce: ");
-
 
112
     inner.setWidget(0,0,labelNameAssistant);
132
	
113
     inner.setWidget(0,1,nameAssistant);
133
     inner.setHTML(0,0,"Espèce: ");
Line 114... Line 134...
114
    
134
     inner.setWidget(0,1,nameAssistant);
Line 115... Line 135...
115
     nameAssistant.setWidth("100%");
135
    
Line 116... Line -...
116
 
-
 
Line 117... Line 136...
117
	 // Saisie lieu
136
     nameAssistant.setWidth("100%");
Line 118... Line 137...
118
	 
137
 
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; 
-
 
158
    		if (calendar==null) {  // Lazy instantiation
-
 
159
    		  calendar = new CalendarWidget();
-
 
160
    		  choicesPopup = new PopupPanel(true);
-
 
161
    		  choicesPopup.add(calendar);
-
 
162
    		  calendar.addChangeListener(new ChangeListener() {
-
 
163
 
-
 
164
    			     public void onChange(Widget sender) {
-
 
165
    			    	 
-
 
166
    			       Date dateSelected=calendar.getDate();
-
 
167
    			       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
-
 
168
    			       visible=false; 
-
 
169
    			       choicesPopup.hide();
-
 
170
    			     }
-
 
171
    			     });
-
 
172
    		  
-
 
173
    	   	}
-
 
174
 
139
    	    choicesPopup.show();
175
    	    choicesPopup.show();
140
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
176
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
141
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
177
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
142
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
178
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
143
    	   }
179
    	   }
144
       }
180
       }
Line 145... Line 181...
145
     
181
     
Line 146... Line -...
146
     });
-
 
147
     
182
     });
148
     calendar.addChangeListener(new ChangeListener() {
-
 
149
 
-
 
150
     public void onChange(Widget sender) {
-
 
151
    	 
-
 
152
       Date dateSelected=calendar.getDate();
-
 
153
       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
-
 
154
       
-
 
155
       visible=false; 
-
 
156
       choicesPopup.hide();
-
 
157
     }
-
 
158
     });
-
 
159
     
183
     
Line 160... Line 184...
160
    HTML labelDate= new HTML("Date: ");
184
         
161
    inner.setWidget(2,0,labelDate);
185
    inner.setHTML(2,0,"Date: ");
162
    
186
    
163
    HorizontalPanel datePanel = new HorizontalPanel();
187
    HorizontalPanel datePanel = new HorizontalPanel();
Line -... Line 188...
-
 
188
    datePanel.add(date);
164
    datePanel.add(date);
189
    datePanel.add(dateSelector);
165
    datePanel.add(dateSelector);
-
 
166
    inner.setWidget(2,1,datePanel);
-
 
167
    
190
    inner.setWidget(2,1,datePanel);
Line 168... Line 191...
168
 
191
    
169
    
-
 
170
    
-
 
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
    			  
195
 
175
    			  
196
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
176
    			  if(arg1 == KEY_ENTER)
-
 
177
    			    {
197
    			  if(arg1 == KEY_ENTER)
Line 178... Line 198...
178
    			     mediator.onAddInventoryItem(); 
198
    			    {
179
    			     date.setText("");
-
 
180
    			    }
-
 
181
 
199
    			     mediator.onAddInventoryItem(); 
182
    		  }
-
 
Line 183... Line 200...
183
    		  
200
    			     date.setText("");
184
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) {
201
    			    }
Line 185... Line 202...
185
    		  }
202
    		  }
Line 186... Line -...
186
 
-
 
187
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) {
203
    		  
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) { }
Line 190... Line 206...
190
    		  }
206
    		  
Line 191... Line 207...
191
    );
207
    		  }
192
    
-
 
193
  
-
 
194
 
208
    );
195
	 // Saisie Complement lieu 
209
    
196
	 
210
  
197
    HTML labelComplementLocation= new HTML("Station: ");
211
 
198
    inner.setWidget(1,2,labelComplementLocation);
212
	 // Saisie Complement de lieu  (station)
Line 199... Line 213...
199
    inner.setWidget(1,3,complementLocation);
213
	 
Line 200... Line 214...
200
 
214
    inner.setHTML(1,2,"Station: ");
201
    complementLocation.setWidth("100%");
-
 
Line 202... Line 215...
202
 
215
    inner.setWidget(1,3,complementLocation);
203
    
-
 
Line 204... Line 216...
204
    complementLocation.addKeyboardListener( new KeyboardListener() {
216
 
205
 
217
    complementLocation.setWidth("100%");
Line 206... Line 218...
206
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
218
 
Line 207... Line -...
207
			  
-
 
208
			  
219
    
209
			  if(arg1 == KEY_ENTER)
220
    complementLocation.addKeyboardListener( new KeyboardListener() {
Line 210... Line 221...
210
			    {
221
 
Line 211... Line 222...
211
			     mediator.onAddInventoryItem(); 
222
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
Line 212... Line 223...
212
			     complementLocation.setText("");
223
			  if(arg1 == KEY_ENTER)
213
			    }
-
 
214
 
-
 
215
		  }
224
			    {
216
		  
225
			     mediator.onAddInventoryItem(); 
217
		  public void onKeyUp(Widget arg0, char arg1, int arg2) {
226
			     complementLocation.setText("");
218
		  }
227
			    }
219
 
228
 
Line 220... Line 229...
220
		  public void onKeyPress(Widget arg0, char arg1, int arg2) {
229
		  }
Line 221... Line 230...
221
		  }
230
		  
222
		  
-
 
223
		  }
-
 
224
    );
231
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
225
 
-
 
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
		  
229
    HTML labelComment= new HTML("Notes: ");
-
 
-
 
235
		  }
Line 230... Line 236...
230
    inner.setWidget(2,2,labelComment);
236
    );
Line 231... Line 237...
231
    inner.setWidget(2,3,comment);
237
 
Line 232... Line 238...
232
 
238
    
-
 
239
	 // Saisie Commentaire
233
    comment.setWidth("100%");
240
	 
234
 
241
    inner.setHTML(2,2,"Notes: ");
235
   
-
 
236
    comment.addKeyboardListener( new KeyboardListener() {
-
 
237
 
-
 
238
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
239
			  
-
 
240
			  
-
 
241
			  if(arg1 == KEY_ENTER)
-
 
242
			    {
-
 
243
			     mediator.onAddInventoryItem(); 
242
    inner.setWidget(2,3,comment);
244
			     comment.setText("");
-
 
245
			    }
-
 
246
 
243
 
-
 
244
    comment.setWidth("100%");
-
 
245
 
247
		  }
246
   
248
		  
247
    comment.addKeyboardListener( new KeyboardListener() {
249
		  public void onKeyUp(Widget arg0, char arg1, int arg2) {
248
 
Line -... Line 249...
-
 
249
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
250
		  }
250
			  if(arg1 == KEY_ENTER)
-
 
251
			    {
251
 
252
			     mediator.onAddInventoryItem(); 
Line 252... Line 253...
252
		  public void onKeyPress(Widget arg0, char arg1, int arg2) {
253
			     comment.setText("");
Line 253... Line 254...
253
		  }
254
			    }
254
		  
255
 
255
		  }
256
		  }
Line 256... Line 257...
256
  );
257
		  
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
		  
Line 260... Line 261...
260
    Button updateButton = new Button("Modification");
261
		  }
Line 261... Line 262...
261
 
262
  );
262
    addButton.addClickListener(
263
 
Line 263... Line 264...
263
    
264
   
Line 264... Line 265...
264
    		new ClickListener() {
265
    Button validButton = new Button("Valider");
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