Subversion Repositories eFlore/Applications.cel

Rev

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