Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 26 Rev 27
Line 53... Line 53...
53
public class EntryPanel extends Composite   {
53
public class EntryPanel extends Composite   {
Line 54... Line 54...
54
	
54
	
55
  private NameAssistant nameAssistant = null;
55
  private NameAssistant nameAssistant = null;
56
  private LocationAssistant locationAssistant = null;
56
  private LocationAssistant locationAssistant = null;
57
  private TextBox date = new TextBox();
57
  private TextBox date = new TextBox();
-
 
58
  private TextBox lieudit = new TextBox();
58
  private TextBox complementLocation = new TextBox();
59
  private TextBox milieu = new TextBox();
59
  private TextBox comment = new TextBox();
60
  private TextBox comment = new TextBox();
-
 
61
  private Button dateSelector = new Button("...");
-
 
62
  private Button validButton = new Button("Ajouter");
60
  private Button dateSelector = new Button("...");
63
 
61
  boolean visible=false;
64
  boolean visible=false;
Line 62... Line 65...
62
  private Mediator mediator=null;
65
  private Mediator mediator=null;
Line 70... Line 73...
70
  
73
  
Line 71... Line 74...
71
 
74
 
-
 
75
  public EntryPanel(final Mediator med) {
-
 
76
	 
-
 
77
	  
-
 
78
  Grid observation = new Grid(4,4);
-
 
79
  
-
 
80
  
-
 
81
  // Formatage affichage 
-
 
82
  
-
 
83
  for (int i=0; i<4;i++) {
-
 
84
	observation.getCellFormatter().setWidth(i, 0, "3%");
-
 
85
	observation.getCellFormatter().setWidth(i, 1, "47%");
Line 72... Line -...
72
  public EntryPanel(final Mediator med) {
-
 
73
	 
-
 
74
	  
86
	observation.getCellFormatter().setWidth(i, 2, "3%");
75
	  Grid inner = new Grid(3,4);
87
	observation.getCellFormatter().setWidth(i, 3, "47%");
Line 76... Line -...
76
 
-
 
Line -... Line 88...
-
 
88
  }  
-
 
89
  
-
 
90
 
77
	  
91
   mediator=med;
78
	  
92
   user=mediator.getUser();
-
 
93
 
79
   mediator=med;
94
   
Line 80... Line 95...
80
   user=mediator.getUser();
95
   // Declaration des elements du dialogue de saisie aupres du mediator
81
 
96
   
-
 
97
   mediator.registerEntryPanel(this);
Line -... Line 98...
-
 
98
   mediator.registerDate(date);
82
   mediator.registerEntryPanel(this);
99
   mediator.registerComment(comment);
Line 83... Line 100...
83
   
100
   mediator.registerMilieu(milieu);
Line 84... Line 101...
84
   mediator.registerDate(date);
101
   mediator.registerLieudit(lieudit);
-
 
102
   
85
   mediator.registerComment(comment);
103
 
86
   mediator.registerComplementLocation(complementLocation);
104
   VerticalPanel outer = new VerticalPanel();
-
 
105
 
87
   
106
// Name assistant et location assistant : widget auto-completion sur nom scientifique ou commune 
88
 
-
 
89
   VerticalPanel outer = new VerticalPanel();
-
 
Line -... Line 107...
-
 
107
 
90
   
108
	nameAssistant = new NameAssistant(mediator);
-
 
109
	locationAssistant = new LocationAssistant(mediator);
-
 
110
 
-
 
111
	
-
 
112
 
Line 91... Line -...
91
 
-
 
92
   outer.add(new HTML("<b>Saisir&nbsp;un&nbsp;relev&eacute;&nbsp;:</b>"));
-
 
Line 93... Line 113...
93
 
113
	 // Saisie Commune
94
   
-
 
95
 
-
 
96
   for (int i=0; i<3;i++) {
-
 
97
	inner.getCellFormatter().setWidth(i, 0, "3%");
114
	 
98
	inner.getCellFormatter().setWidth(i, 1, "47%");
-
 
99
	inner.getCellFormatter().setWidth(i, 2, "3%");
-
 
Line -... Line 115...
-
 
115
     observation.setHTML(2,0,"Commune:&nbsp;");
-
 
116
     observation.setWidget(2,1,locationAssistant);
-
 
117
     
100
	inner.getCellFormatter().setWidth(i, 3, "47%");
118
     locationAssistant.setWidth("100%");
-
 
119
 
-
 
120
 
-
 
121
	 // Saisie lieu-dit
101
   }  
122
	 
102
 
123
     observation.setHTML(2,2,"Lieu-dit:&nbsp;");
-
 
124
     observation.setWidget(2,3,lieudit);
103
 
125
     
-
 
126
     lieudit.setWidth("100%");
-
 
127
 
-
 
128
 
Line 104... Line -...
104
   
-
 
105
 
129
     
-
 
130
     lieudit.addKeyboardListener( new KeyboardListener() {
106
	nameAssistant = new NameAssistant(mediator);
131
 
Line -... Line 132...
-
 
132
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
133
 			  if(arg1 == KEY_ENTER)
-
 
134
 			    {
-
 
135
 				 onValidateTextBox(lieudit);
-
 
136
 			    }
-
 
137
 
-
 
138
 		  }
-
 
139
 		  
-
 
140
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
-
 
141
 
-
 
142
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
-
 
143
 		  
-
 
144
 		  }
-
 
145
     );
-
 
146
 
-
 
147
 
-
 
148
     
-
 
149
	 // Saisie (milieu)
-
 
150
	 
-
 
151
     observation.setHTML(3,0,"Milieu:&nbsp;");
-
 
152
     observation.setWidget(3,1,milieu);
-
 
153
 
-
 
154
     milieu.setWidth("100%");
-
 
155
 
-
 
156
     
-
 
157
     // Validation par entree sur cette zone de texte
-
 
158
     
-
 
159
     milieu.addKeyboardListener( new KeyboardListener() {
-
 
160
 
Line 107... Line 161...
107
	locationAssistant = new LocationAssistant(mediator);
161
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
Line 108... Line 162...
108
 
162
 			  if(arg1 == KEY_ENTER)
Line 157... Line 211...
157
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
211
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
158
    	   }
212
    	   }
159
       }
213
       }
Line 160... Line 214...
160
     
214
     
-
 
215
     });
Line -... Line 216...
-
 
216
 
161
     });
217
     
-
 
218
 	// Saisie Espece 
-
 
219
 	
-
 
220
   observation.setHTML(0,0,"Esp&egrave;ce:&nbsp;");
-
 
221
   observation.setWidget(0,1,nameAssistant);
-
 
222
  
162
     
223
   nameAssistant.setWidth("100%");
Line 163... Line 224...
163
         
224
 
164
    inner.setHTML(2,0,"Date:&nbsp;");
225
   observation.setHTML(0,2,"Date:&nbsp;");
165
    
226
    
166
    HorizontalPanel datePanel = new HorizontalPanel();
227
    HorizontalPanel datePanel = new HorizontalPanel();
Line 167... Line 228...
167
    datePanel.add(date);
228
    datePanel.add(date);
-
 
229
    datePanel.add(dateSelector);
-
 
230
    observation.setWidget(0,3,datePanel);
Line 168... Line 231...
168
    datePanel.add(dateSelector);
231
    
Line 169... Line 232...
169
    inner.setWidget(2,1,datePanel);
232
    // Saisie date   
170
    
233
    // Validation par entree sur cette zone de texte
171
    // Saisie date   
234
 
172
   
-
 
173
    date.addKeyboardListener( new KeyboardListener() {
-
 
174
 
235
   
175
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
176
    			  if(arg1 == KEY_ENTER)
-
 
177
    			    {
-
 
178
    				 if (ordre==null) {
-
 
179
       				     mediator.onAddInventoryItem(); 
-
 
180
       				     date.setText("");
236
    date.addKeyboardListener( new KeyboardListener() {
181
    				 }
237
 
Line 182... Line 238...
182
       				 else {
238
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
183
       				     mediator.onModifyInventoryItem(ordre); 
239
    			  if(arg1 == KEY_ENTER)
Line 192... Line 248...
192
    		  }
248
    		  }
193
    );
249
    );
Line 194... Line -...
194
    
-
 
195
  
-
 
196
 
-
 
197
	 // Saisie Complement de lieu  (station)
-
 
198
	 
-
 
199
    inner.setHTML(1,2,"Station:&nbsp;");
-
 
200
    inner.setWidget(1,3,complementLocation);
-
 
201
 
-
 
202
    complementLocation.setWidth("100%");
-
 
203
 
-
 
204
    
-
 
205
    complementLocation.addKeyboardListener( new KeyboardListener() {
-
 
206
 
-
 
207
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
208
			  if(arg1 == KEY_ENTER)
-
 
209
			    {
-
 
210
				  	if (ordre==null) {
-
 
211
   				     mediator.onAddInventoryItem(); 
-
 
212
   				     complementLocation.setText("");
-
 
213
   				  	}
-
 
214
   				  	else {
-
 
215
   				     mediator.onModifyInventoryItem(ordre); 
-
 
216
   				     ordre=null;
-
 
217
   				 }
-
 
218
			    }
-
 
219
 
-
 
220
		  }
-
 
221
		  
-
 
222
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
-
 
223
 
-
 
224
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
-
 
225
		  
-
 
Line 226... Line 250...
226
		  }
250
    
Line 227... Line 251...
227
    );
251
  
228
 
252
 
Line 229... Line 253...
229
    
253
    
Line 230... Line 254...
230
	 // Saisie Commentaire
254
	 // Saisie Commentaire
-
 
255
	 
-
 
256
    observation.setHTML(1,0,"Notes:&nbsp;");
231
	 
257
    observation.setWidget(1,1,comment);
Line 232... Line 258...
232
    inner.setHTML(2,2,"Notes:&nbsp;");
258
 
233
    inner.setWidget(2,3,comment);
259
    comment.setWidth("100%");
234
 
260
 
235
    comment.setWidth("100%");
-
 
236
 
-
 
237
   
261
 
238
    comment.addKeyboardListener( new KeyboardListener() {
-
 
239
 
-
 
240
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
241
			  if(arg1 == KEY_ENTER)
-
 
242
			    {
-
 
243
				  	if (ordre==null) {
262
    // Validation par entree sur cette zone de texte
Line 244... Line 263...
244
   				     mediator.onAddInventoryItem(); 
263
 
Line 245... Line 264...
245
   				     comment.setText("");
264
    comment.addKeyboardListener( new KeyboardListener() {
246
   				  	}
265
 
Line 247... Line 266...
247
   				  	else {
266
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
248
   				     mediator.onModifyInventoryItem(ordre); 
267
			  if(arg1 == KEY_ENTER)
Line 249... Line -...
249
   				     ordre=null;
-
 
250
   				  	}
-
 
251
			    }
-
 
Line -... Line 268...
-
 
268
			    {
-
 
269
    				  onValidateTextBox(comment);
-
 
270
			    }
252
 
271
 
Line 253... Line 272...
253
		  }
272
		  }
Line 254... Line 273...
254
		  
273
		  
-
 
274
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
255
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
275
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
256
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
276
		  
257
		  
277
		  }
258
		  }
278
  );
259
  );
279
    
Line 283... Line 303...
283
    HorizontalPanel actionPanel= new HorizontalPanel();
303
    HorizontalPanel actionPanel= new HorizontalPanel();
Line 284... Line 304...
284
   
304
   
Line 285... Line 305...
285
    actionPanel.add(validButton);
305
    actionPanel.add(validButton);
Line 286... Line 306...
286
    
306
    
287
 
307
 
288
	inner.setWidth("100%");
308
	observation.setWidth("100%");
Line 289... Line 309...
289
 
309
 
290
	outer.add(inner);
310
	outer.add(observation);
Line 309... Line 329...
309
						JSONValue jsonValue = JSONParser.parse(strcomplete);
329
						JSONValue jsonValue = JSONParser.parse(strcomplete);
310
						JSONArray jsonArray;
330
						JSONArray jsonArray;
Line 311... Line 331...
311
 
331
 
Line 312... Line 332...
312
						if ((jsonArray = jsonValue.isArray()) != null) {
332
						if ((jsonArray = jsonValue.isArray()) != null) {
Line 313... Line 333...
313
		
333
		
314
								String aname = ((JSONString) jsonArray.get(0)).stringValue();
-
 
315
								
334
								String aname = Util.toCelString(((JSONString) jsonArray.get(0)).toString());
316
								// Nom  
335
								
317
							
-
 
318
								if (aname.compareTo("null")!=0) {
336
								// Nom  
319
									nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue());
-
 
320
							
337
								if (aname.compareTo("null")!=0) {
321
									// Numero nomenclatural 
-
 
322
							
338
									nameAssistant.setText(aname);
Line 323... Line 339...
323
									nameAssistant.setValue(anum);
339
									// Numero nomenclatural 
324
									
340
									nameAssistant.setValue(anum);
Line 337... Line 353...
337
   
353
   
Line 338... Line 354...
338
    
354
    
339
  }
355
  }
340
 
356
 
341
	/*
357
	/*
Line 342... Line 358...
342
	 * Numero d'ordre du relev� affich�
358
	 * Numero d'ordre du releve affiche + mise à jour bouton
343
	 * 
359
	 * 
-
 
360
	 */
-
 
361
	
-
 
362
	public void setOrdre(String ordre) {
-
 
363
		this.ordre = ordre;
-
 
364
		if (ordre==null) {
-
 
365
			this.validButton.setText("Ajouter");
344
	 */
366
		}
Line 345... Line 367...
345
	
367
		else {
346
	public void setOrdre(String ordre) {
368
			this.validButton.setText("Modifier");
347
		this.ordre = ordre;
369
		}
348
	}
370
	}
Line 349... Line 371...
349
 
371
 
350
 
372
 
351
	/*
373
	/*
Line -... Line 374...
-
 
374
	 * Numero d'ordre du releve affiche
-
 
375
	 * 
-
 
376
	 */
-
 
377
	
-
 
378
	public String getOrdre() {
-
 
379
		return this.ordre;
-
 
380
	}
-
 
381
 
-
 
382
 
-
 
383
    // Validation par entree sur cette zone de texte
-
 
384
    
-
 
385
    private void onValidateTextBox(TextBox textbox) {
-
 
386
   	
-
 
387
		  	if (ordre==null) {
-
 
388
			  // Numero ordre vide : ajout d'une observation
-
 
389
			     mediator.onAddInventoryItem(); 
-
 
390
			     textbox.setText("");
Line 352... Line 391...
352
	 * Numero d'ordre du relev� affich�
391
			  	}
353
	 * 
392
			  	else {
354
	 */
393
			     mediator.onModifyInventoryItem(ordre); 
355
	
394
			     ordre=null;
Line 356... Line 395...
356
	public String getOrdre() {
395
			 }
Line 375... Line 414...
375
				JSONValue jsonValue = JSONParser.parse(str);
414
				JSONValue jsonValue = JSONParser.parse(str);
376
				JSONArray jsonArray;
415
				JSONArray jsonArray;
Line 377... Line 416...
377
				
416
				
-
 
417
				
378
				
418
				if ((jsonArray = jsonValue.isArray()) != null) {
379
				if ((jsonArray = jsonValue.isArray()) != null) {
419
					
-
 
420
							// Nom saisi
Line 380... Line 421...
380
							// Nom saisi
421
							nameAssistant.setText(Util.toCelString(((JSONString) jsonArray.get(0)).toString()));
Line 381... Line 422...
381
							nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue());
422
							
Line 391... Line 432...
391
							else {
432
							else {
392
								nameAssistant.setValue(null);
433
								nameAssistant.setValue(null);
393
							}
434
							}
Line 394... Line 435...
394
							
435
							
395
							// Commune
436
							// Commune
Line 396... Line 437...
396
							String aloc=((JSONString) jsonArray .get(6)).stringValue();
437
							String aloc=Util.toCelString(((JSONString) jsonArray .get(6)).toString());
397
							
438
							
398
							if (aloc.compareTo("000null")!=0) {
439
							if (aloc.compareTo("000null")!=0) {
399
								locationAssistant.setText(aloc);
440
								locationAssistant.setText(aloc);
Line 411... Line 452...
411
							else {
452
							else {
412
								date.setText(""); 
453
								date.setText(""); 
413
							}
454
							}
Line 414... Line 455...
414
 
455
 
Line 415... Line 456...
415
 
456
 
416
							String astation=((JSONString) jsonArray .get(9)).stringValue();
457
							String astation=Util.toCelString(((JSONString) jsonArray .get(9)).toString());
417
							
458
							
418
//							Station 
459
//							Station 
419
							if (astation.compareTo("000null")!=0) {
460
							if (astation.compareTo("000null")!=0) {
420
								complementLocation.setText(astation); 
461
								milieu.setText(astation); 
421
							}
462
							}
Line 422... Line 463...
422
							else {
463
							else {
423
								complementLocation.setText(""); 
464
								milieu.setText(""); 
424
							}
465
							}
425
							
466
							
426
 
467
 
427
							String acomment=((JSONString) jsonArray .get(10)).stringValue();
468
							String acomment=Util.toCelString(((JSONString) jsonArray .get(10)).toString());
Line 448... Line 489...
448
 
489
 
Line 449... Line 490...
449
}
490
}
450
 
491
 
-
 
492
/* +--Fin du code ---------------------------------------------------------------------------------------+
-
 
493
* $Log$
-
 
494
* Revision 1.7  2007-09-17 19:25:34  ddelon
451
/* +--Fin du code ---------------------------------------------------------------------------------------+
495
* Documentation
452
* $Log$
496
*
453
* Revision 1.6  2007-06-06 13:29:30  ddelon
497
* Revision 1.6  2007-06-06 13:29:30  ddelon
454
* v0.09
498
* v0.09
455
*
499
*