Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 13 Rev 20
Line 4... Line 4...
4
 
4
 
Line 5... Line 5...
5
import java.util.Iterator;
5
import java.util.Iterator;
6
 
6
 
-
 
7
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.modeles.ListeReferentielCommune;
-
 
9
import org.tela_botanica.client.modeles.ListeReferentielNom;
8
import org.tela_botanica.client.modeles.ListeReferentielCommune;
10
import org.tela_botanica.client.modeles.ReferentielCommune;
Line 9... Line -...
9
import org.tela_botanica.client.modeles.ReferentielCommune;
-
 
10
import org.tela_botanica.client.observation.ObservationMediateur;
11
import org.tela_botanica.client.modeles.ReferentielNom;
11
 
12
import org.tela_botanica.client.observation.ObservationMediateur;
12
 
13
 
13
import com.google.gwt.user.client.Window;
14
 
14
import com.gwtext.client.core.EventCallback;
15
import com.gwtext.client.core.EventCallback;
Line 21... Line 22...
21
import com.gwtext.client.data.RecordDef;
22
import com.gwtext.client.data.RecordDef;
22
import com.gwtext.client.data.Store;
23
import com.gwtext.client.data.Store;
23
import com.gwtext.client.data.StringFieldDef;
24
import com.gwtext.client.data.StringFieldDef;
24
import com.gwtext.client.widgets.Button;
25
import com.gwtext.client.widgets.Button;
25
import com.gwtext.client.widgets.Panel;
26
import com.gwtext.client.widgets.Panel;
-
 
27
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
26
import com.gwtext.client.widgets.form.ComboBox;
28
import com.gwtext.client.widgets.form.ComboBox;
27
import com.gwtext.client.widgets.form.DateField;
29
import com.gwtext.client.widgets.form.DateField;
28
import com.gwtext.client.widgets.form.FormPanel;
30
import com.gwtext.client.widgets.form.FormPanel;
29
import com.gwtext.client.widgets.form.TextField;
31
import com.gwtext.client.widgets.form.TextField;
30
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
32
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
Line 45... Line 47...
45
	 * Le médiateur associé à la vue
47
	 * Le médiateur associé à la vue
46
	 */
48
	 */
47
	private ObservationMediateur	observationMediateur		= null;
49
	private ObservationMediateur	observationMediateur		= null;
Line 48... Line -...
48
	
-
 
-
 
50
	
49
	
51
	
50
	private TextField nameAssistant = null;
52
 
51
	private DateField date = null;
53
	private DateField date = null;
52
	private TextField lieudit = null;
54
	private TextField lieudit = null;
53
	private TextField station = null;
55
	private TextField station = null;
54
	private TextField milieu = null;
56
	private TextField milieu = null;
-
 
57
	private TextField comment = null;
55
	private TextField comment = null;
58
	private ComboBox  commune = null;
-
 
59
	private ComboBox  espece = null;
-
 
60
 
-
 
61
	private Button boutonOK = new Button("Ok");
56
	private ComboBox  commune = null;
62
	private Button boutonAnnuler = new Button("Annuler");
-
 
63
 
Line 57... Line -...
57
	
-
 
58
	private boolean selectionCommune=false;
-
 
59
	
-
 
60
	  public static final int KEY_ALT = 18;
-
 
61
	  public static final int KEY_BACKSPACE = 8;
-
 
62
	  public static final int KEY_CTRL = 17;
-
 
63
	  public static final int KEY_DELETE = 46;
-
 
64
	  public static final int KEY_DOWN = 40;
-
 
65
	  public static final int KEY_END = 35;
-
 
66
	  public static final int KEY_ENTER = 13;
-
 
67
	  public static final int KEY_ESCAPE = 27;
-
 
68
	  public static final int KEY_HOME = 36;
-
 
69
	  public static final int KEY_LEFT = 37;
-
 
70
	  public static final int KEY_PAGEDOWN = 34;
-
 
71
	  public static final int KEY_PAGEUP = 33;
-
 
72
	  public static final int KEY_RIGHT = 39;
-
 
Line 73... Line 64...
73
	  public static final int KEY_SHIFT = 16;
64
	private boolean selectionCommune=false;
-
 
65
	private boolean selectionEspece=false;
-
 
66
	
-
 
67
	
-
 
68
	private final int KEY_ALT = 18;
74
	  public static final int KEY_TAB = 9;
69
	private final int KEY_BACKSPACE = 8;
-
 
70
	private final int KEY_CTRL = 17;
-
 
71
	private final int KEY_DELETE = 46;
-
 
72
	private final int KEY_DOWN = 40;
-
 
73
	private final int KEY_END = 35;
-
 
74
	private final int KEY_ENTER = 13;
-
 
75
	private final int KEY_ESCAPE = 27;
-
 
76
	private final int KEY_HOME = 36;
-
 
77
	private final int KEY_LEFT = 37;
75
	  public static final int KEY_UP = 38;
78
	private final int KEY_PAGEDOWN = 34;
76
	
79
	private final int KEY_PAGEUP = 33;
-
 
80
	private final int KEY_RIGHT = 39;
Line 77... Line -...
77
	/**
-
 
Line 78... Line 81...
78
	 * Store combobox communes
81
	private final int KEY_SHIFT = 16;
79
	 */
82
	private final int KEY_TAB = 9;
80
	private Store			store				= null;
83
	private final int KEY_UP = 38;
Line 144... Line 147...
144
		
147
		
Line 145... Line 148...
145
		store = new Store(rd);
148
		store = new Store(rd);
Line -... Line 149...
-
 
149
		
146
		
150
		//store.load();*/
Line 147... Line -...
147
		//store.load();*/
-
 
148
		
-
 
Line 149... Line 151...
149
		commune=new ComboBox("Commune","commune",275 );  
151
		
Line 150... Line 152...
150
		
152
 
151
	
153
		commune=new ComboBox("Commune","commune",275 );  
152
		//commune.setStore(store);
154
		
153
		
155
		
154
		final String resultTpl = "<div class=\"search-item\">{commune}</div>";  
-
 
155
 
-
 
156
		
-
 
157
		commune.setTpl(resultTpl);
-
 
158
		commune.setMode(ComboBox.REMOTE);
156
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
159
		// commune.setPageSize(10); // Ne fonctionne pas 
157
 
Line 160... Line 158...
160
		commune.setItemSelector("div.search-item");
158
		
Line 161... Line -...
161
		
-
 
162
		
-
 
163
		//commune.setDisplayField("title");
-
 
164
		
-
 
165
		commune.setTypeAhead(true);  
-
 
166
		commune.setLoadingText("Recherche...");  
-
 
167
		  
-
 
168
		commune.setHideTrigger(true);
-
 
169
		
-
 
170
		
-
 
171
		/*
-
 
172
		final String resultTpl = "<div class=\"search-item\"><h3><span>{lastPost:date(\"M j, Y\")}"  
-
 
173
			                                 +  "<br/>by {author}</span>{title}</h3>{excerpt}</div>";  
-
 
174
		
-
 
175
		commune.setTpl(resultTpl);
-
 
176
		*/
-
 
177
		
-
 
178
		//commune.setMode(ComboBox.REMOTE);
-
 
179
		
-
 
180
		/*
-
 
181
		commune.setTitle("ExtJS Forums");  
-
 
182
		commune.setHideLabel(true);  
-
 
183
		commune.setItemSelector("div.search-item");
-
 
184
		
-
 
185
		  */
-
 
186
   
-
 
187
		
-
 
188
	    
-
 
189
		
-
 
190
        commune.addListener(new ComboBoxListenerAdapter() {  
-
 
191
             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
192
                 commune.setValue(record.getAsString("commune"));
-
 
193
                 selectionCommune=true;
-
 
194
             }  
-
 
195
         });  
-
 
196
         
-
 
197
        
-
 
198
//      Selection parmi la liste déroulante
-
 
199
	    
-
 
200
        
-
 
201
		ListenerConfig listenerConfig=new ListenerConfig();
-
 
202
		listenerConfig.setDelay(10);
-
 
203
		listenerConfig.setStopPropagation(false);
-
 
204
		listenerConfig.setStopEvent(false);
-
 
205
		
-
 
206
 
-
 
207
	
-
 
208
	    commune.addKeyPressListener(new EventCallback()	{
-
 
209
	    	
-
 
210
	    	    public void execute(EventObject e) {
-
 
211
	    	    	
-
 
212
	    	    		  
-
 
213
	    	    		  switch(e.getKey()) {
-
 
214
	    	    	      	    		  
-
 
215
	    	    		  
-
 
216
	    	    		  case KEY_ALT:
-
 
217
	    	    	      case KEY_CTRL:
-
 
218
	    	    	      case KEY_DOWN:
-
 
219
	    	    	      case KEY_END:
-
 
220
	    	    	      
-
 
221
	    	    	      case KEY_ESCAPE:
-
 
222
	    	    	      case KEY_HOME:
-
 
223
	    	    	      case KEY_LEFT:
-
 
224
	    	    	      case KEY_PAGEDOWN:
-
 
225
	    	    	      case KEY_PAGEUP:
-
 
226
	    	    	      case KEY_RIGHT:
-
 
227
	    	    	      case KEY_SHIFT:
-
 
228
	    	    	      case KEY_TAB:
-
 
229
	    	    	      case KEY_UP:
-
 
230
	    	    	    	
-
 
231
	    	    	        break;
-
 
232
	    	    	      
-
 
233
	    	    	      case KEY_ENTER:
-
 
234
	    	    	    	  
-
 
235
	    	    	    	 if (selectionCommune) {
-
 
236
	    	    	    		 selectionCommune=false;
-
 
237
	    	    	    	 }
-
 
238
	    	    	    	 else {
-
 
239
	    	    	    		// lancer mise a jour 	    	    	    		 
-
 
240
	    	    	    	 }
-
 
241
	    	    	    	
-
 
242
	    	    	    	
-
 
243
	    	    	    	  break;
-
 
244
	    	    	       
-
 
245
	    	    	      default:
-
 
246
	    	    	    	  
-
 
247
	    	    	    	  obtenirListeReferentielCommune();
-
 
248
	    	    	    	  	    	    	        
-
 
249
	    	    	        break;
-
 
250
	    	    	    }
-
 
251
 
159
		commune.setTpl(resultTplCommune);
Line 252... Line 160...
252
	    	    	 
160
		commune.setMode(ComboBox.REMOTE);
Line 269... Line 177...
269
	    station.setAllowBlank(true);  
177
	    station.setAllowBlank(true);  
270
	    panneauPremierColonne.add(station);  
178
	    panneauPremierColonne.add(station);  
Line 271... Line 179...
271
	    
179
	    
272
	    date = new DateField("Date", "date", 100);  
180
	    date = new DateField("Date", "date", 100);  
273
	    date.setAllowBlank(true);
181
	    date.setAllowBlank(true);
274
	    date.setFormat("d/m/yyyy") ;
182
	    date.setFormat("d/m/Y") ;
-
 
183
	    panneauPremierColonne.add(date);  
275
	    panneauPremierColonne.add(date);  
184
 
276
	
185
	 	
277
		nameAssistant = new TextField("Espèce", "espece", 275);  
-
 
278
		nameAssistant.setAllowBlank(false);  
-
 
-
 
186
		espece=new ComboBox("Espèce","nom",275 );  
Line -... Line 187...
-
 
187
		
-
 
188
		
-
 
189
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";  
-
 
190
 
-
 
191
		
-
 
192
		espece.setTpl(resultTplEspece);
-
 
193
		espece.setMode(ComboBox.REMOTE);
-
 
194
		// commune.setPageSize(10); // Ne fonctionne pas 
-
 
195
		espece.setItemSelector("div.search-item-espece");
-
 
196
		espece.setTypeAhead(true);  
-
 
197
		espece.setLoadingText("Recherche...");  
-
 
198
		  
-
 
199
		espece.setHideTrigger(true);
-
 
200
		
-
 
201
 
-
 
202
 
279
		panneauPremierColonne.add(nameAssistant);  
203
	    panneauPremierColonne.add(espece);  
280
		
204
	    
281
	    comment = new TextField("Notes", "comment", 275);  
205
	    comment = new TextField("Notes", "comment", 275);  
Line 297... Line 221...
297
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
221
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
298
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
222
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
Line 299... Line 223...
299
		
223
		
Line 300... Line -...
300
		panneauFormulaire.add(panneauIntermediaire);
-
 
-
 
224
		panneauFormulaire.add(panneauIntermediaire);
301
		
225
		
Line 302... Line -...
302
		Button boutonOK = new Button("Ok");  
-
 
-
 
226
		
303
		panneauFormulaire.addButton(boutonOK);
227
		panneauFormulaire.addButton(boutonOK);
Line 304... Line 228...
304
		    
228
		    
Line 305... Line 229...
305
		Button boutonAnnuler = new Button("Annuler");  
229
		  
Line 306... Line -...
306
		panneauFormulaire.addButton(boutonAnnuler);
-
 
Line 307... Line 230...
307
		    
230
		panneauFormulaire.addButton(boutonAnnuler);
308
	
231
		    
Line 309... Line 232...
309
		this.add(panneauFormulaire) ;
232
	
Line 310... Line 233...
310
		
233
		this.add(panneauFormulaire) ;
311
		
234
		
-
 
235
		
-
 
236
		this.setAutoHeight(true);
-
 
237
	
-
 
238
	
-
 
239
		// on ajoute les listeners
-
 
240
		ajouterListeners() ;
-
 
241
		
-
 
242
		
-
 
243
 
-
 
244
	}
-
 
245
	
-
 
246
	private void ajouterListeners()
-
 
247
	{
-
 
248
		
-
 
249
		
-
 
250
		// Listener completion communne 
-
 
251
		
-
 
252
		   commune.addListener(new ComboBoxListenerAdapter() {  
-
 
253
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
254
	                 commune.setValue(record.getAsString("commune"));
-
 
255
	                 selectionCommune=true;
-
 
256
	             }  
-
 
257
	         });  
-
 
258
	         
-
 
259
	        
-
 
260
			ListenerConfig listenerConfigCommune=new ListenerConfig();
-
 
261
			listenerConfigCommune.setDelay(10);
-
 
262
			listenerConfigCommune.setStopPropagation(false);
-
 
263
			listenerConfigCommune.setStopEvent(false);
-
 
264
			
-
 
265
 
-
 
266
		
-
 
267
		    commune.addKeyPressListener(new EventCallback()	{
-
 
268
		    	
-
 
269
		    	    public void execute(EventObject e) {
-
 
270
		    	    	
-
 
271
		    	    		  
-
 
272
		    	    		  switch(e.getKey()) {
-
 
273
		    	    	      	    		  
-
 
274
		    	    		  
-
 
275
		    	    		  case KEY_ALT:
-
 
276
		    	    	      case KEY_CTRL:
-
 
277
		    	    	      case KEY_DOWN:
-
 
278
		    	    	      case KEY_END:
-
 
279
		    	    	      case KEY_ESCAPE:
-
 
280
		    	    	      case KEY_HOME:
-
 
281
		    	    	      case KEY_LEFT:
-
 
282
		    	    	      case KEY_PAGEDOWN:
-
 
283
		    	    	      case KEY_PAGEUP:
-
 
284
		    	    	      case KEY_RIGHT:
-
 
285
		    	    	      case KEY_SHIFT:
-
 
286
		    	    	      case KEY_TAB:
-
 
287
		    	    	      case KEY_UP:
-
 
288
		    	    	    	
-
 
289
		    	    	        break;
-
 
290
		    	    	      
-
 
291
		    	    	      case KEY_ENTER:
-
 
292
		    	    	    	  
-
 
293
		    	    	    	 if (selectionCommune) {
-
 
294
		    	    	    		 selectionCommune=false;
-
 
295
		    	    	    	 }
-
 
296
		    	    	    	 else {
-
 
297
		    	    	    		// lancer mise a jour 	    	    	    		 
-
 
298
		    	    	    	 }
-
 
299
		    	    	    	
-
 
300
		    	    	    	
-
 
301
		    	    	    	  break;
-
 
302
		    	    	       
-
 
303
		    	    	      default:
-
 
304
		    	    	    	  
-
 
305
		    	    	    	  obtenirListeReferentielCommune();
-
 
306
		    	    	    	  	    	    	        
-
 
307
		    	    	        break;
-
 
308
		    	    	    }
-
 
309
 
-
 
310
		    	    	 
-
 
311
		    	    	
-
 
312
		     		}
-
 
313
		    	 
-
 
314
		    		},    listenerConfigCommune
-
 
315
		    	
-
 
316
			);
-
 
317
		    
-
 
318
			// Listener completion espece 
-
 
319
 
-
 
320
			
-
 
321
			espece.addListener(new ComboBoxListenerAdapter() {  
-
 
322
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
323
	            	 espece.setValue(record.getAsString("nom"));
-
 
324
	                 selectionEspece=true;
-
 
325
	             }  
-
 
326
	         });  
-
 
327
	         
-
 
328
 
-
 
329
			ListenerConfig listenerConfigEspece=new ListenerConfig();
-
 
330
			listenerConfigEspece.setDelay(10);
-
 
331
			listenerConfigEspece.setStopPropagation(false);
-
 
332
			listenerConfigEspece.setStopEvent(false);			
-
 
333
 
-
 
334
		
-
 
335
			espece.addKeyPressListener(new EventCallback()	{
-
 
336
		    	
-
 
337
		    	    public void execute(EventObject e) {
-
 
338
		    	    	
-
 
339
		    	    		  
-
 
340
		    	    		  switch(e.getKey()) {
-
 
341
		    	    	      	    		  
-
 
342
		    	    		  
-
 
343
		    	    		  case KEY_ALT:
-
 
344
		    	    	      case KEY_CTRL:
-
 
345
		    	    	      case KEY_DOWN:
-
 
346
		    	    	      case KEY_END:
-
 
347
		    	    	      case KEY_ESCAPE:
-
 
348
		    	    	      case KEY_HOME:
-
 
349
		    	    	      case KEY_LEFT:
-
 
350
		    	    	      case KEY_PAGEDOWN:
-
 
351
		    	    	      case KEY_PAGEUP:
-
 
352
		    	    	      case KEY_RIGHT:
-
 
353
		    	    	      case KEY_SHIFT:
-
 
354
		    	    	      case KEY_TAB:
-
 
355
		    	    	      case KEY_UP:
-
 
356
		    	    	    	
-
 
357
		    	    	        break;
-
 
358
		    	    	      
-
 
359
		    	    	      case KEY_ENTER:
-
 
360
		    	    	    	  
-
 
361
		    	    	    	 if (selectionEspece) {
-
 
362
		    	    	    		 selectionEspece=false;
-
 
363
		    	    	    	 }
-
 
364
		    	    	    	 else {
-
 
365
		    	    	    		// lancer mise a jour 	    	    	    		 
-
 
366
		    	    	    	 }
-
 
367
		    	    	    	
-
 
368
		    	    	    	
-
 
369
		    	    	    	  break;
-
 
370
		    	    	       
-
 
371
		    	    	      default:
-
 
372
		    	    	    	  
-
 
373
		    	    	    	  obtenirListeReferentielNom();
-
 
374
		    	    	    	  	    	    	        
-
 
375
		    	    	        break;
-
 
376
		    	    	    }
-
 
377
 
-
 
378
		    	    	 
-
 
379
		    	    	
-
 
380
		     		}
-
 
381
		    	 
-
 
382
		    		},    listenerConfigEspece
312
		this.setAutoHeight(true);
383
		    	
313
	
384
			);
Line 314... Line 385...
314
		
385
		    
Line 390... Line 461...
390
					RecordDef rd = new RecordDef(defTab);
461
					RecordDef rd = new RecordDef(defTab);
Line 391... Line 462...
391
					
462
					
392
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
463
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
Line 393... Line 464...
393
					final ArrayReader reader = new ArrayReader(rd);		
464
					final ArrayReader reader = new ArrayReader(rd);		
394
					
465
					
Line 395... Line 466...
395
					store=new Store(dataProxy,reader);
466
					Store store=new Store(dataProxy,reader);
Line 396... Line 467...
396
					store.load() ;
467
					store.load() ;
-
 
468
		
-
 
469
					commune.setStore(store);
-
 
470
				
-
 
471
					
-
 
472
							
-
 
473
			}
-
 
474
			
-
 
475
//			 si l'on a reçu une liste de nom
-
 
476
			
-
 
477
			if(nouvelleDonnees instanceof ListeReferentielNom)
-
 
478
			{
-
 
479
				
-
 
480
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
-
 
481
					Object[][] nomData = new Object[data.size()][2];
-
 
482
					int i = 0 ;
-
 
483
				
-
 
484
					// on la parse et on récupère les informations quiç nous interessent
-
 
485
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
-
 
486
					{
-
 
487
						
-
 
488
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
-
 
489
						
-
 
490
						nomData[i][0]= ref.getNom();
-
 
491
						nomData[i][1]= ref.getNumeroNom();
-
 
492
						
-
 
493
																	
-
 
494
						i++ ;
-
 
495
					}
-
 
496
					
-
 
497
					   //	  creation du store
-
 
498
					FieldDef defNom = new StringFieldDef("nom");
-
 
499
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
-
 
500
					
-
 
501
					
-
 
502
					FieldDef[] defTab = { defNom, defNumeroNom};
-
 
503
					
-
 
504
					RecordDef rd = new RecordDef(defTab);
-
 
505
					
-
 
506
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
-
 
507
					final ArrayReader reader = new ArrayReader(rd);		
-
 
508
					
-
 
509
					Store store=new Store(dataProxy,reader);
-
 
510
					store.load() ;
-
 
511
		
-
 
512
					espece.setStore(store);
397
		
513
				
Line 398... Line 514...
398
					commune.setStore(store);
514
					
-
 
515
							
-
 
516
			}
-
 
517
			
399
				
518
 
-
 
519
	}
-
 
520
	
-
 
521
 
-
 
522
	public void obtenirListeReferentielCommune() {
-
 
523
	 String com=commune.getText().replaceAll(" ","/");
-
 
524
	 com=com.replaceAll("%","");
-
 
525
		  
-
 
526
	 observationMediateur.obtenirListeReferentielCommune(this,com);
-
 
527
	 
-
 
528
	}
Line 400... Line 529...
400
					
529
	
-
 
530
 
-
 
531
	public void obtenirListeReferentielNom() {
Line 401... Line 532...
401
							
532