Subversion Repositories eFlore/Applications.cel

Rev

Rev 110 | Rev 120 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12 david 1
package org.tela_botanica.client.vues;
2
 
3
 
4
 
13 david 5
import java.util.Iterator;
6
 
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.modeles.ListeReferentielCommune;
20 david 9
import org.tela_botanica.client.modeles.ListeReferentielNom;
39 david 10
import org.tela_botanica.client.modeles.Observation;
13 david 11
import org.tela_botanica.client.modeles.ReferentielCommune;
20 david 12
import org.tela_botanica.client.modeles.ReferentielNom;
12 david 13
import org.tela_botanica.client.observation.ObservationMediateur;
71 jpm 14
import com.google.gwt.user.client.Window;
13 david 15
import com.gwtext.client.core.EventCallback;
16
import com.gwtext.client.core.EventObject;
17
import com.gwtext.client.core.ListenerConfig;
12 david 18
import com.gwtext.client.core.Position;
71 jpm 19
import com.gwtext.client.core.Template;
13 david 20
import com.gwtext.client.data.ArrayReader;
21
import com.gwtext.client.data.FieldDef;
22
import com.gwtext.client.data.MemoryProxy;
23
import com.gwtext.client.data.RecordDef;
71 jpm 24
import com.gwtext.client.data.SimpleStore;
13 david 25
import com.gwtext.client.data.Store;
26
import com.gwtext.client.data.StringFieldDef;
12 david 27
import com.gwtext.client.widgets.Button;
28
import com.gwtext.client.widgets.Panel;
71 jpm 29
import com.gwtext.client.widgets.Toolbar;
20 david 30
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
13 david 31
import com.gwtext.client.widgets.form.ComboBox;
12 david 32
import com.gwtext.client.widgets.form.DateField;
33
import com.gwtext.client.widgets.form.FormPanel;
74 david 34
import com.gwtext.client.widgets.form.Hidden;
110 aurelien 35
import com.gwtext.client.widgets.form.TextArea;
12 david 36
import com.gwtext.client.widgets.form.TextField;
13 david 37
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
12 david 38
import com.gwtext.client.widgets.layout.ColumnLayout;
39
import com.gwtext.client.widgets.layout.ColumnLayoutData;
40
import com.gwtext.client.widgets.layout.FormLayout;
13 david 41
import com.gwtext.client.data.Record;
12 david 42
 
43
/**
44
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
45
 * @author aurelien
46
 *
47
 */
13 david 48
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
12 david 49
 
50
 
51
	/**
52
	 * Le médiateur associé à la vue
53
	 */
54
	private ObservationMediateur	observationMediateur		= null;
55
 
56
 
20 david 57
 
13 david 58
	private DateField date = null;
12 david 59
	private TextField lieudit = null;
60
	private TextField station = null;
61
	private TextField milieu = null;
62
	private TextField comment = null;
13 david 63
	private ComboBox  commune = null;
39 david 64
	private String departement = null;
20 david 65
	private ComboBox  espece = null;
39 david 66
	private String numeroNom = null;
74 david 67
	private String numeroOrdre = null;
110 aurelien 68
	private TextArea motsCles = null;
20 david 69
 
118 david 70
<<<<<<< .mine
71
	// Pour remise a zero partielle lors d'une validation
72
 
73
	private  enum Champs {
74
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT
75
	};
76
 
77
 
78
 
79
=======
110 aurelien 80
	private String formatDate = null ;
81
 
118 david 82
>>>>>>> .r117
71 jpm 83
	private Button boutonOK = new Button("Créer");
77 jpm 84
	private Button boutonAnnuler = new Button("Réinitialiser");
20 david 85
 
13 david 86
	private boolean selectionCommune=false;
20 david 87
	private boolean selectionEspece=false;
12 david 88
 
71 jpm 89
	private boolean modification = false ;
90
	private Toolbar bt = null ;
13 david 91
 
20 david 92
	private final int KEY_ALT = 18;
93
	private final int KEY_BACKSPACE = 8;
94
	private final int KEY_CTRL = 17;
95
	private final int KEY_DELETE = 46;
96
	private final int KEY_DOWN = 40;
97
	private final int KEY_END = 35;
98
	private final int KEY_ENTER = 13;
99
	private final int KEY_ESCAPE = 27;
100
	private final int KEY_HOME = 36;
101
	private final int KEY_LEFT = 37;
102
	private final int KEY_PAGEDOWN = 34;
103
	private final int KEY_PAGEUP = 33;
104
	private final int KEY_RIGHT = 39;
105
	private final int KEY_SHIFT = 16;
106
	private final int KEY_TAB = 9;
107
	private final int KEY_UP = 38;
13 david 108
 
71 jpm 109
	/**
110
	 * Combobox permettant de selectionner le mode
111
	 * modification ou bien création
112
	 */
113
	private ComboBox selecteurMode = new ComboBox();
13 david 114
 
71 jpm 115
	Store storeMode = null ;
13 david 116
 
12 david 117
	/**
118
	 * Booleen d'instanciation
119
	 */
120
	boolean estInstancie = false ;
121
 
122
	/**
123
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
124
	 */
71 jpm 125
	@SuppressWarnings("unused")
12 david 126
	private FormulaireSaisieObservationVue()
127
	{
128
		super() ;
129
	}
130
 
131
	/**
132
	 * Constructeur avec argument
133
	 * @param im
134
	 */
135
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
136
	{
137
 
138
 
139
		// on associe le médiateur
140
		observationMediateur = obs ;
141
 
142
 
53 david 143
		setHeader(true);
12 david 144
 
145
		FormPanel panneauFormulaire = new FormPanel(Position.RIGHT);
146
		panneauFormulaire.setBorder(false);
147
 
148
		// Panneau intermediaire qui contient deux colonnes de formulaire
149
 
150
		Panel panneauIntermediaire = new Panel();
151
		panneauIntermediaire.setLayout(new ColumnLayout());
152
		panneauIntermediaire.setBorder(false);
153
 
154
		//create first panel and add fields to it
155
		Panel panneauPremierColonne = new Panel();
156
		panneauPremierColonne.setLayout(new FormLayout());
157
		panneauPremierColonne.setBorder(false);
158
 
159
		//create second panel and add fields to it
160
	    Panel panneauSecondeColonne = new Panel();
161
		panneauSecondeColonne.setLayout(new FormLayout());
162
		panneauSecondeColonne.setBorder(false);
42 jpm 163
 
164
		this.setPaddings(5) ;
12 david 165
 
20 david 166
 
49 david 167
 
13 david 168
		commune=new ComboBox("Commune","commune",275 );
169
 
170
 
20 david 171
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";
13 david 172
 
173
 
20 david 174
		commune.setTpl(resultTplCommune);
13 david 175
		commune.setMode(ComboBox.REMOTE);
176
		// commune.setPageSize(10); // Ne fonctionne pas
20 david 177
		commune.setItemSelector("div.search-item-commune");
13 david 178
		commune.setTypeAhead(true);
179
		commune.setLoadingText("Recherche...");
180
 
181
		commune.setHideTrigger(true);
182
 
183
 
20 david 184
 
13 david 185
 
186
 
187
	    panneauPremierColonne.add(commune);
188
 
189
 
190
 
12 david 191
	    station = new TextField("Station", "station", 275);
192
	    station.setAllowBlank(true);
193
	    panneauPremierColonne.add(station);
194
 
195
	    date = new DateField("Date", "date", 100);
196
	    date.setAllowBlank(true);
110 aurelien 197
	    formatDate = "d/m/Y";
198
	    date.setFormat(formatDate) ;
12 david 199
	    panneauPremierColonne.add(date);
20 david 200
 
201
 
202
		espece=new ComboBox("Espèce","nom",275 );
12 david 203
 
20 david 204
 
205
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";
206
 
207
 
208
		espece.setTpl(resultTplEspece);
209
		espece.setMode(ComboBox.REMOTE);
210
		// commune.setPageSize(10); // Ne fonctionne pas
211
		espece.setItemSelector("div.search-item-espece");
212
		espece.setTypeAhead(true);
213
		espece.setLoadingText("Recherche...");
214
 
215
		espece.setHideTrigger(true);
216
 
217
 
218
 
219
	    panneauPremierColonne.add(espece);
220
 
12 david 221
	    comment = new TextField("Notes", "comment", 275);
222
	    comment.setAllowBlank(true);
223
	    panneauPremierColonne.add(comment);
224
 
225
 
226
	    lieudit = new TextField("Lieu-dit", "lieudit", 275);
227
	    lieudit.setAllowBlank(true);
228
	    panneauSecondeColonne.add(lieudit);
229
 
230
 
231
	    milieu = new TextField("Milieu", "milieu", 275);
232
	    milieu.setAllowBlank(true);
110 aurelien 233
	    panneauSecondeColonne.add(milieu);
12 david 234
 
110 aurelien 235
	    motsCles = new TextArea("Mots clés","motscles") ;
236
	    motsCles.setAllowBlank(true);
237
	    motsCles.setWidth(275);
238
	    panneauSecondeColonne.add(motsCles);
239
 
12 david 240
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
241
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
242
 
243
		panneauFormulaire.add(panneauIntermediaire);
244
 
71 jpm 245
		Object[][] mode = {{"création",false} , {"modification", true} };
246
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
247
				mode);
248
		storeMode.load();
249
		selecteurMode.setStore(storeMode);
250
		selecteurMode.setDisplayField("nom_mode") ;
251
		selecteurMode.setLabel("mode ") ;
252
		selecteurMode.setForceSelection(true) ;
253
		selecteurMode.setValue("création") ;
254
		selecteurMode.setEditable(false) ;
97 jpm 255
		selecteurMode.setCls("x-selec-crea") ;
71 jpm 256
 
257
		bt = new Toolbar() ;
258
		bt.addSpacer() ;
259
		bt.addText("Mode de saisie ") ;
260
		bt.addField(selecteurMode) ;
261
 
74 david 262
 
263
 
264
 
12 david 265
		panneauFormulaire.addButton(boutonOK);
266
 
267
		panneauFormulaire.addButton(boutonAnnuler);
71 jpm 268
 
269
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
270
 
271
			public void onSelect(ComboBox comboBox, Record record, int index) {
272
 
273
				// et on met la valeur à jour dans la combobox
274
				comboBox.setValue(record.getAsString("nom_mode"));
275
				setModification(record.getAsString("mode")) ;
276
			}
277
 
278
		});
12 david 279
 
280
		this.add(panneauFormulaire) ;
80 jpm 281
		this.setTopToolbar(bt) ;
12 david 282
 
283
 
284
		this.setAutoHeight(true);
285
 
286
 
287
		// on ajoute les listeners
288
		ajouterListeners() ;
289
 
290
 
291
 
292
	}
293
 
294
	private void ajouterListeners()
94 jpm 295
	{
20 david 296
		// Listener completion communne
297
 
298
		   commune.addListener(new ComboBoxListenerAdapter() {
299
	             public void onSelect(ComboBox comboBox, Record record, int index) {
300
	                 commune.setValue(record.getAsString("commune"));
39 david 301
	                 departement=record.getAsString("departement");
20 david 302
	                 selectionCommune=true;
303
	             }
304
	         });
305
 
306
 
307
			ListenerConfig listenerConfigCommune=new ListenerConfig();
308
			listenerConfigCommune.setDelay(10);
309
			listenerConfigCommune.setStopPropagation(false);
310
			listenerConfigCommune.setStopEvent(false);
311
 
312
 
313
 
314
		    commune.addKeyPressListener(new EventCallback()	{
315
 
316
		    	    public void execute(EventObject e) {
317
 
318
 
319
		    	    		  switch(e.getKey()) {
320
 
321
 
322
		    	    		  case KEY_ALT:
323
		    	    	      case KEY_CTRL:
324
		    	    	      case KEY_DOWN:
325
		    	    	      case KEY_END:
326
		    	    	      case KEY_ESCAPE:
327
		    	    	      case KEY_HOME:
328
		    	    	      case KEY_LEFT:
329
		    	    	      case KEY_PAGEDOWN:
330
		    	    	      case KEY_PAGEUP:
331
		    	    	      case KEY_RIGHT:
332
		    	    	      case KEY_SHIFT:
333
		    	    	      case KEY_TAB:
334
		    	    	      case KEY_UP:
335
 
336
		    	    	        break;
337
 
338
		    	    	      case KEY_ENTER:
339
 
340
		    	    	    	 if (selectionCommune) {
341
		    	    	    		 selectionCommune=false;
342
		    	    	    	 }
343
		    	    	    	 else {
118 david 344
 
345
 
346
		    	    	    		validerSaisie(Champs.COMMUNE);
20 david 347
		    	    	    		// lancer mise a jour
348
		    	    	    	 }
349
 
350
 
351
		    	    	    	  break;
352
 
353
		    	    	      default:
354
 
83 david 355
		    	    	    	  departement="";
20 david 356
		    	    	    	  obtenirListeReferentielCommune();
357
 
358
		    	    	        break;
359
		    	    	    }
360
 
361
 
362
 
363
		     		}
364
 
365
		    		},    listenerConfigCommune
366
 
367
			);
368
 
369
			// Listener completion espece
370
 
371
 
372
			espece.addListener(new ComboBoxListenerAdapter() {
373
	             public void onSelect(ComboBox comboBox, Record record, int index) {
374
	            	 espece.setValue(record.getAsString("nom"));
39 david 375
	            	 numeroNom=record.getAsString("numeroNom");
20 david 376
	                 selectionEspece=true;
377
	             }
378
	         });
379
 
380
 
381
			ListenerConfig listenerConfigEspece=new ListenerConfig();
382
			listenerConfigEspece.setDelay(10);
383
			listenerConfigEspece.setStopPropagation(false);
384
			listenerConfigEspece.setStopEvent(false);
385
 
386
 
387
			espece.addKeyPressListener(new EventCallback()	{
388
 
389
		    	    public void execute(EventObject e) {
390
 
391
 
392
		    	    		  switch(e.getKey()) {
393
 
394
 
395
		    	    		  case KEY_ALT:
396
		    	    	      case KEY_CTRL:
397
		    	    	      case KEY_DOWN:
398
		    	    	      case KEY_END:
399
		    	    	      case KEY_ESCAPE:
400
		    	    	      case KEY_HOME:
401
		    	    	      case KEY_LEFT:
402
		    	    	      case KEY_PAGEDOWN:
403
		    	    	      case KEY_PAGEUP:
404
		    	    	      case KEY_RIGHT:
405
		    	    	      case KEY_SHIFT:
406
		    	    	      case KEY_TAB:
407
		    	    	      case KEY_UP:
408
 
409
		    	    	        break;
410
 
411
		    	    	      case KEY_ENTER:
412
 
413
		    	    	    	 if (selectionEspece) {
414
		    	    	    		 selectionEspece=false;
415
		    	    	    	 }
416
		    	    	    	 else {
417
		    	    	    		// lancer mise a jour
418
		    	    	    	 }
419
 
420
 
421
		    	    	    	  break;
422
 
423
		    	    	      default:
424
 
83 david 425
		    	    	    	  numeroNom="";
20 david 426
		    	    	    	  obtenirListeReferentielNom();
427
 
428
		    	    	        break;
429
		    	    	    }
430
 
431
 
432
 
433
		     		}
434
 
435
		    		},    listenerConfigEspece
436
 
437
			);
438
 
439
 
440
 
441
 
442
		boutonOK.addListener(new ButtonListenerAdapter() {
39 david 443
 
20 david 444
			public void onClick(Button button, EventObject e) {
118 david 445
 
446
				if(modification) {
71 jpm 447
					modifierObservation() ;
448
				}
118 david 449
				else {
71 jpm 450
					ajouterObservation();
451
				}
39 david 452
 
71 jpm 453
 
20 david 454
			}
455
 
456
		});
77 jpm 457
 
458
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
12 david 459
 
460
			public void onClick(Button button, EventObject e) {
461
 
77 jpm 462
				if(modification)
463
				{
464
					supprimerObservation() ;
465
				}
466
				else
467
				{
104 jpm 468
					raz();
77 jpm 469
				}
12 david 470
 
77 jpm 471
 
472
			}
473
 
12 david 474
		});
475
 
476
 
477
	}
478
 
479
	/**
118 david 480
	 * Validation de la saisie
481
	 */
482
 
483
	private void validerSaisie(Champs champs) {
484
 
485
		if(modification) {
486
			modifierObservation() ;
487
 
488
		}
489
		else {
490
			ajouterObservation();
491
			raz(champs);
492
		}
493
	}
494
 
495
	/**
12 david 496
	 * Desactive visuellement ce panneau
497
	 */
498
	public void desactiverPanneau()
499
	{
500
		this.setDisabled(true) ;
501
	}
502
 
503
	/**
504
	 * Active visuellement ce panneau
505
	 */
506
	public void activerPanneau()
507
	{
508
		this.setDisabled(false) ;
509
	}
13 david 510
 
511
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
512
 
49 david 513
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
13 david 514
			if(nouvelleDonnees instanceof ListeReferentielCommune)
515
			{
516
 
517
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
518
					Object[][] communeData = new Object[data.size()][2];
519
					int i = 0 ;
520
 
521
					// on la parse et on récupère les informations quiç nous interessent
522
					for (Iterator it = data.keySet().iterator(); it.hasNext();)
523
					{
524
 
525
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
526
 
527
						communeData[i][0]= ref.getCommune();
528
						communeData[i][1]= ref.getDepartement();
529
 
530
 
531
						i++ ;
532
					}
533
 
534
					   //	  creation du store
535
					FieldDef defCommune = new StringFieldDef("commune");
536
					FieldDef defDepartement = new StringFieldDef("departement");
537
 
538
 
539
					FieldDef[] defTab = { defCommune, defDepartement};
540
 
541
					RecordDef rd = new RecordDef(defTab);
542
 
543
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
544
					final ArrayReader reader = new ArrayReader(rd);
545
 
20 david 546
					Store store=new Store(dataProxy,reader);
13 david 547
					store.load() ;
548
 
41 jpm 549
					commune.setStore(store);
13 david 550
 
551
			}
20 david 552
 
94 jpm 553
			//			 si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
20 david 554
 
555
			if(nouvelleDonnees instanceof ListeReferentielNom)
556
			{
557
 
558
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
559
					Object[][] nomData = new Object[data.size()][2];
560
					int i = 0 ;
561
 
562
					// on la parse et on récupère les informations quiç nous interessent
563
					for (Iterator it = data.keySet().iterator(); it.hasNext();)
564
					{
565
 
566
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
567
 
568
						nomData[i][0]= ref.getNom();
569
						nomData[i][1]= ref.getNumeroNom();
570
 
571
 
572
						i++ ;
573
					}
574
 
575
					   //	  creation du store
576
					FieldDef defNom = new StringFieldDef("nom");
577
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
578
 
579
 
580
					FieldDef[] defTab = { defNom, defNumeroNom};
581
 
582
					RecordDef rd = new RecordDef(defTab);
583
 
584
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
585
					final ArrayReader reader = new ArrayReader(rd);
586
 
587
					Store store=new Store(dataProxy,reader);
588
					store.load() ;
589
 
590
					espece.setStore(store);
591
 
592
 
593
 
594
			}
595
 
82 david 596
			// On recoit une observation dont on veut afficher le detail
597
 
71 jpm 598
			if(nouvelleDonnees instanceof Observation)
599
			{
600
				Observation obs = (Observation)nouvelleDonnees ;
601
				afficherDetailsObservation(obs) ;
602
			}
77 jpm 603
 
82 david 604
			// Sur Mise à jour ou suppression d'une suppression ?
605
 
77 jpm 606
			if(nouvelleDonnees instanceof String)
607
			{
608
				String str = (String)nouvelleDonnees ;
107 aurelien 609
				observationMediateur.obtenirNombreObservation() ;
77 jpm 610
			}
20 david 611
 
13 david 612
	}
12 david 613
 
614
 
13 david 615
	public void obtenirListeReferentielCommune() {
94 jpm 616
 
20 david 617
	 String com=commune.getText().replaceAll(" ","/");
618
	 com=com.replaceAll("%","");
619
 
620
	 observationMediateur.obtenirListeReferentielCommune(this,com);
13 david 621
 
622
	}
20 david 623
 
624
 
625
	public void obtenirListeReferentielNom() {
626
 
627
	  String esp=espece.getText().replaceAll(" ","/");
628
	  esp=esp.replaceAll("%","");
629
 
630
	  observationMediateur.obtenirListeReferentielNom(this,esp);
631
 
632
	}
633
 
634
 
39 david 635
	public void ajouterObservation() {
636
 
110 aurelien 637
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue(),motsCles.getValueAsString());
46 david 638
		observationMediateur.ajouterObservation(obs);
39 david 639
	}
12 david 640
 
71 jpm 641
	private void modifierObservation() {
642
 
110 aurelien 643
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText(),motsCles.getValueAsString());
79 david 644
		obs.setNumeroOrdre(numeroOrdre);
645
		observationMediateur.modifierObservation(obs);
74 david 646
 
71 jpm 647
	}
77 jpm 648
 
649
	private void supprimerObservation() {
650
 
651
			observationMediateur.supprimerObservation(this, numeroOrdre);
652
	}
12 david 653
 
71 jpm 654
 
655
	public void afficherDetailsObservation(Observation obs)
656
	{
104 jpm 657
		raz() ;
71 jpm 658
 
659
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
660
			String[] dateEtHeure = obs.getDate().split(" ", 2);
110 aurelien 661
			if(verifierFormatDate(dateEtHeure[0])) {
662
				date.setValue(dateEtHeure[0]) ;
663
			}
664
			else
665
			{
666
				date.setRawValue("");
667
			}
71 jpm 668
		}
669
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
670
			lieudit.setValue(obs.getLieudit()) ;
671
		}
672
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
673
			station.setValue(obs.getStation()) ;
674
		}
675
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
676
			milieu.setValue(obs.getMilieu()) ;
677
		}
678
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
679
			comment.setValue(obs.getCommentaire()) ;
680
		}
681
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
682
			commune.setValue(obs.getLocalite()) ;
683
		}
684
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
685
			departement = obs.getIdentifiantLocalite();
686
		}
687
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
688
			espece.setValue(obs.getNomSaisi()) ;
689
		}
690
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
691
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
692
		}
83 david 693
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
74 david 694
			numeroOrdre = obs.getNumeroOrdre() ;
695
		}
110 aurelien 696
		if(!obs.getMotsCles().equals("null") && !obs.getMotsCles().equals("000null")) {
697
			motsCles.setValue(obs.getMotsCles());
698
		}
74 david 699
 
71 jpm 700
	}
701
 
118 david 702
 
104 jpm 703
	public void raz()
71 jpm 704
	{
118 david 705
		raz(Champs.TOUT);
706
 
707
	}
708
	public void raz(Champs champs)
709
	{
710
		switch (champs) {
711
 
712
 
713
			case DATE:
714
				date.reset() ;
715
				break;
716
 
717
			case LIEUDIT:
718
				lieudit.reset() ;
719
				break;
720
 
721
			case STATION:
722
				station.reset() ;
723
				break;
724
 
725
			case MILIEU:
726
				milieu.reset() ;
727
				break;
728
 
71 jpm 729
 
118 david 730
<<<<<<< .mine
731
			case COMMENT:
732
				comment.reset() ;
733
				break;
734
 
735
 
736
			case COMMUNE:
737
				milieu.reset() ;
738
				departement ="";
739
				break;
740
 
741
			case ESPECE:
742
				espece.reset();
743
				numeroNom = "" ;
744
				numeroOrdre = "";
745
				break;
746
 
747
			case TOUT:
748
				date.reset() ;
749
				lieudit.reset() ;
750
				station.reset() ;
751
				milieu.reset() ;
752
				comment.reset() ;
753
				milieu.reset() ;
754
				departement ="";
755
				espece.reset();
756
				numeroNom = "" ;
757
				numeroOrdre = "";
758
				break;
759
 
760
		}
761
 
762
=======
71 jpm 763
		date.reset() ;
764
		lieudit.reset() ;
765
		station.reset() ;
766
		milieu.reset();
767
		comment.reset();
768
		commune.reset();
110 aurelien 769
		motsCles.reset();
71 jpm 770
		departement = "";
771
		espece.reset();
772
		numeroNom = "" ;
74 david 773
		numeroOrdre = "";
118 david 774
>>>>>>> .r117
71 jpm 775
 
776
	}
777
 
778
	private void setModification(String mode)
779
	{
780
		if(mode.equals("true")) {
781
 
782
			boutonOK.setText("Modifier") ;
783
			setTitle("Modification") ;
77 jpm 784
			boutonAnnuler.setText("Supprimer") ;
71 jpm 785
			modification = true ;
97 jpm 786
			selecteurMode.removeClass("x-selec-crea") ;
787
			selecteurMode.setCls("x-selec-modif") ;
94 jpm 788
 
71 jpm 789
		}
790
		else
791
		{
792
 
793
			boutonOK.setText("Créer") ;
794
			setTitle("Saisir") ;
77 jpm 795
			boutonAnnuler.setText("Réinitialiser") ;
71 jpm 796
			modification = false ;
97 jpm 797
			selecteurMode.removeClass("x-selec-modif") ;
798
			selecteurMode.setCls("x-selec-crea") ;
94 jpm 799
 
71 jpm 800
		}
801
 
802
	}
803
 
804
 
805
	/**
806
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
807
	 * @return
808
	 */
809
	public boolean getModification()
810
	{
811
		return modification ;
812
	}
110 aurelien 813
 
814
	public boolean verifierFormatDate(String date) {
815
 
816
		String regex = "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" ;
817
		if(date.matches(regex) && !date.equals("0000-00-00")) {
818
			return true ;
819
		}
820
		else {
821
			return false;
822
		}
823
	}
71 jpm 824
 
12 david 825
}