Subversion Repositories eFlore/Applications.cel

Rev

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

Rev Author Line No. Line
195 david 1
package org.tela_botanica.client.vues.observation;
12 david 2
 
201 david 3
// TODO Detecter redim et supprimer ajuster
12 david 4
 
221 aurelien 5
import java.util.Date;
13 david 6
import java.util.Iterator;
7
 
8
import org.tela_botanica.client.interfaces.Rafraichissable;
216 aurelien 9
import org.tela_botanica.client.modeles.ListeObservation;
13 david 10
import org.tela_botanica.client.modeles.ListeReferentielCommune;
20 david 11
import org.tela_botanica.client.modeles.ListeReferentielNom;
39 david 12
import org.tela_botanica.client.modeles.Observation;
13 david 13
import org.tela_botanica.client.modeles.ReferentielCommune;
20 david 14
import org.tela_botanica.client.modeles.ReferentielNom;
12 david 15
import org.tela_botanica.client.observation.ObservationMediateur;
132 aurelien 16
 
221 aurelien 17
import com.google.gwt.core.client.JavaScriptObject;
216 aurelien 18
import com.google.gwt.user.client.Window;
13 david 19
import com.gwtext.client.core.EventCallback;
20
import com.gwtext.client.core.EventObject;
218 david 21
import com.gwtext.client.core.Ext;
13 david 22
import com.gwtext.client.core.ListenerConfig;
12 david 23
import com.gwtext.client.core.Position;
13 david 24
import com.gwtext.client.data.ArrayReader;
25
import com.gwtext.client.data.FieldDef;
26
import com.gwtext.client.data.MemoryProxy;
27
import com.gwtext.client.data.RecordDef;
71 jpm 28
import com.gwtext.client.data.SimpleStore;
13 david 29
import com.gwtext.client.data.Store;
30
import com.gwtext.client.data.StringFieldDef;
132 aurelien 31
import com.gwtext.client.widgets.BoxComponent;
12 david 32
import com.gwtext.client.widgets.Button;
221 aurelien 33
import com.gwtext.client.widgets.Component;
132 aurelien 34
import com.gwtext.client.widgets.Container;
221 aurelien 35
import com.gwtext.client.widgets.DatePicker;
12 david 36
import com.gwtext.client.widgets.Panel;
71 jpm 37
import com.gwtext.client.widgets.Toolbar;
230 david 38
import com.gwtext.client.widgets.Viewport;
132 aurelien 39
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
20 david 40
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
132 aurelien 41
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
221 aurelien 42
import com.gwtext.client.widgets.event.DatePickerListener;
43
import com.gwtext.client.widgets.event.DatePickerListenerAdapter;
201 david 44
import com.gwtext.client.widgets.event.PanelListenerAdapter;
13 david 45
import com.gwtext.client.widgets.form.ComboBox;
12 david 46
import com.gwtext.client.widgets.form.DateField;
216 aurelien 47
import com.gwtext.client.widgets.form.Field;
12 david 48
import com.gwtext.client.widgets.form.FormPanel;
128 aurelien 49
import com.gwtext.client.widgets.form.TextArea;
12 david 50
import com.gwtext.client.widgets.form.TextField;
13 david 51
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
201 david 52
import com.gwtext.client.widgets.layout.AnchorLayoutData;
12 david 53
import com.gwtext.client.widgets.layout.ColumnLayout;
54
import com.gwtext.client.widgets.layout.ColumnLayoutData;
55
import com.gwtext.client.widgets.layout.FormLayout;
230 david 56
import com.gwtext.client.widgets.layout.RowLayout;
13 david 57
import com.gwtext.client.data.Record;
12 david 58
 
59
/**
60
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
61
 * @author aurelien
62
 *
63
 */
13 david 64
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
12 david 65
 
66
 
67
	/**
68
	 * Le médiateur associé à la vue
69
	 */
70
	private ObservationMediateur	observationMediateur		= null;
71
 
205 aurelien 72
	FormPanel panneauFormulaire = null;
20 david 73
 
13 david 74
	private DateField date = null;
12 david 75
	private TextField lieudit = null;
76
	private TextField station = null;
77
	private TextField milieu = null;
78
	private TextField comment = null;
13 david 79
	private ComboBox  commune = null;
39 david 80
	private String departement = null;
20 david 81
	private ComboBox  espece = null;
39 david 82
	private String numeroNom = null;
74 david 83
	private String numeroOrdre = null;
20 david 84
 
118 david 85
	// Pour remise a zero partielle lors d'une validation
86
 
87
	private  enum Champs {
216 aurelien 88
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT ;
89
 
90
	    public String toString() {
91
 
92
	    	switch(this) {
93
	    	case DATE:
94
	    		return "date";
95
 
96
	    	case COMMUNE:
97
	    		return "commune";
98
 
99
    		case LIEUDIT:
100
    			return "lieu dit";
101
 
102
    		case STATION:
103
    			return "station";
104
 
105
    		case MILIEU:
106
    			return "milieu";
107
 
108
    		case COMMENT:
109
    			return "commentaire";
110
 
111
	    	case ESPECE:
112
	    		return "espèce";
113
 
114
	    	case TOUT:
115
	    		return "date, commune, lieu dit, station, milieu, espèce, commentaire";
116
	    	}
117
			return TOUT.toString();
118
	    }
118 david 119
	};
120
 
121
 
122
 
110 aurelien 123
	private String formatDate = null ;
71 jpm 124
	private Button boutonOK = new Button("Créer");
77 jpm 125
	private Button boutonAnnuler = new Button("Réinitialiser");
20 david 126
 
13 david 127
	private boolean selectionCommune=false;
20 david 128
	private boolean selectionEspece=false;
12 david 129
 
71 jpm 130
	private boolean modification = false ;
131
	private Toolbar bt = null ;
13 david 132
 
216 aurelien 133
	private final String VALEURS_MULTIPLES = "(Valeurs multiples)";
221 aurelien 134
	private final String modeleMessageModif = "commune:lieu-dit:station:milieu:date:espece:commentaire";
216 aurelien 135
	private boolean communeModifiee = false;
221 aurelien 136
	private boolean lieuDitModifie = false;
137
	private boolean stationModifiee = false;
216 aurelien 138
	private boolean milieuModifie = false;
139
	private boolean dateModifiee = false;
140
	private boolean especeModifiee = false;
141
	private boolean commModifie = false;
142
 
143
 
20 david 144
	private final int KEY_ALT = 18;
145
	private final int KEY_BACKSPACE = 8;
146
	private final int KEY_CTRL = 17;
147
	private final int KEY_DELETE = 46;
148
	private final int KEY_DOWN = 40;
149
	private final int KEY_END = 35;
150
	private final int KEY_ENTER = 13;
151
	private final int KEY_ESCAPE = 27;
152
	private final int KEY_HOME = 36;
153
	private final int KEY_LEFT = 37;
154
	private final int KEY_PAGEDOWN = 34;
155
	private final int KEY_PAGEUP = 33;
156
	private final int KEY_RIGHT = 39;
157
	private final int KEY_SHIFT = 16;
158
	private final int KEY_TAB = 9;
159
	private final int KEY_UP = 38;
13 david 160
 
128 aurelien 161
 
71 jpm 162
	/**
163
	 * Combobox permettant de selectionner le mode
164
	 * modification ou bien création
165
	 */
166
	private ComboBox selecteurMode = new ComboBox();
13 david 167
 
71 jpm 168
	Store storeMode = null ;
13 david 169
 
12 david 170
	/**
171
	 * Booleen d'instanciation
172
	 */
173
	boolean estInstancie = false ;
205 aurelien 174
 
175
	private Panel panneauIntermediaire;
176
 
177
	private Panel panneauPremierColonne;
178
 
179
	private Panel panneauSecondeColonne;
216 aurelien 180
 
181
	private boolean masseModification =false ;
12 david 182
 
183
	/**
184
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
185
	 */
71 jpm 186
	@SuppressWarnings("unused")
12 david 187
	private FormulaireSaisieObservationVue()
188
	{
189
		super() ;
190
	}
191
 
192
	/**
193
	 * Constructeur avec argument
194
	 * @param im
195
	 */
196
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
197
	{
198
		// on associe le médiateur
199
		observationMediateur = obs ;
200
 
201 david 201
 
205 aurelien 202
		panneauFormulaire = new FormPanel(Position.RIGHT);
12 david 203
		panneauFormulaire.setBorder(false);
204
 
218 david 205
 
206
 
12 david 207
		// Panneau intermediaire qui contient deux colonnes de formulaire
208
 
205 aurelien 209
		panneauIntermediaire = new Panel();
230 david 210
 
211
		if (Window.getClientWidth()> Window.getClientHeight()) {
212
			panneauIntermediaire.setLayout(new ColumnLayout());
213
		}
214
		else {
215
			panneauIntermediaire.setLayout(new RowLayout());
216
		}
217
 
12 david 218
		panneauIntermediaire.setBorder(false);
218 david 219
 
220
		if (Ext.isIE6()) {
221
			panneauIntermediaire.setWidth(800);
222
		}
223
 
12 david 224
		//create first panel and add fields to it
205 aurelien 225
		panneauPremierColonne = new Panel();
12 david 226
		panneauPremierColonne.setLayout(new FormLayout());
227
		panneauPremierColonne.setBorder(false);
228
 
229
		//create second panel and add fields to it
205 aurelien 230
	    panneauSecondeColonne = new Panel();
12 david 231
		panneauSecondeColonne.setLayout(new FormLayout());
232
		panneauSecondeColonne.setBorder(false);
42 jpm 233
 
234
		this.setPaddings(5) ;
12 david 235
 
195 david 236
		// Accesskey pour debugging
237
 
201 david 238
		commune=new ComboBox("Commune","commune\" accesskey=\"1");
195 david 239
 
20 david 240
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";
241
		commune.setTpl(resultTplCommune);
13 david 242
		commune.setMode(ComboBox.REMOTE);
243
		// commune.setPageSize(10); // Ne fonctionne pas
20 david 244
		commune.setItemSelector("div.search-item-commune");
13 david 245
		commune.setTypeAhead(true);
246
		commune.setLoadingText("Recherche...");
247
 
248
		commune.setHideTrigger(true);
132 aurelien 249
		commune.setTabIndex(1);
13 david 250
 
201 david 251
	    panneauPremierColonne.add(commune, new AnchorLayoutData("95%"));
13 david 252
 
201 david 253
	    station = new TextField("Station", "station");
132 aurelien 254
	    station.setAllowBlank(true);
255
	    station.setTabIndex(3);
201 david 256
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
12 david 257
 
258
	    date = new DateField("Date", "date", 100);
259
	    date.setAllowBlank(true);
110 aurelien 260
	    formatDate = "d/m/Y";
261
	    date.setFormat(formatDate) ;
132 aurelien 262
	    date.setTabIndex(5);
201 david 263
	    panneauPremierColonne.add(date, new AnchorLayoutData("60%"));
20 david 264
 
265
 
201 david 266
		espece=new ComboBox("Espèce","nom");
12 david 267
 
20 david 268
 
269
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";
270
 
271
 
272
		espece.setTpl(resultTplEspece);
273
		espece.setMode(ComboBox.REMOTE);
274
		// commune.setPageSize(10); // Ne fonctionne pas
275
		espece.setItemSelector("div.search-item-espece");
276
		espece.setTypeAhead(true);
277
		espece.setLoadingText("Recherche...");
278
 
279
		espece.setHideTrigger(true);
132 aurelien 280
		espece.setTabIndex(6);
20 david 281
 
201 david 282
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));
20 david 283
 
201 david 284
	    lieudit = new TextField("Lieu-dit", "lieudit");
132 aurelien 285
	    lieudit.setAllowBlank(true);
286
	    lieudit.setTabIndex(2);
201 david 287
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));
12 david 288
 
289
 
201 david 290
	    milieu = new TextField("Milieu", "milieu");
132 aurelien 291
	    milieu.setAllowBlank(true);
292
	    milieu.setTabIndex(4);
201 david 293
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
128 aurelien 294
 
295
	    comment = new TextArea("Notes", "comment");
296
	    comment.setAllowBlank(true);
297
	    comment.setHeight(50);
132 aurelien 298
	    comment.setTabIndex(7);
201 david 299
	    panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") );
12 david 300
 
230 david 301
 
302
 
303
 
304
	    if (Window.getClientWidth()> Window.getClientHeight()) {
305
			panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
306
			panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
307
	    }
308
	    else {
309
			panneauIntermediaire.add(panneauPremierColonne);
310
			panneauIntermediaire.add(panneauSecondeColonne);
311
 
312
	    }
313
 
12 david 314
		panneauFormulaire.add(panneauIntermediaire);
315
 
71 jpm 316
		Object[][] mode = {{"création",false} , {"modification", true} };
317
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
318
				mode);
319
		storeMode.load();
320
		selecteurMode.setStore(storeMode);
321
		selecteurMode.setDisplayField("nom_mode") ;
322
		selecteurMode.setLabel("mode ") ;
323
		selecteurMode.setForceSelection(true) ;
324
		selecteurMode.setValue("création") ;
325
		selecteurMode.setEditable(false) ;
97 jpm 326
		selecteurMode.setCls("x-selec-crea") ;
71 jpm 327
 
328
		bt = new Toolbar() ;
329
		bt.addSpacer() ;
330
		bt.addText("Mode de saisie ") ;
331
		bt.addField(selecteurMode) ;
332
 
132 aurelien 333
		boutonOK.setTabIndex(8);
334
		boutonAnnuler.setTabIndex(9);
74 david 335
 
71 jpm 336
 
218 david 337
		if (Ext.isIE6()) {
338
			panneauPremierColonne.setButtonAlign(Position.RIGHT);
339
			panneauPremierColonne.addButton(boutonOK);
340
			panneauSecondeColonne.setButtonAlign(Position.LEFT);
341
			panneauSecondeColonne.addButton(boutonAnnuler);
342
		}
343
		else {
344
 
345
			panneauFormulaire.addButton(boutonOK);
346
			panneauFormulaire.addButton(boutonAnnuler);
347
		}
348
 
349
 
71 jpm 350
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
351
 
352
			public void onSelect(ComboBox comboBox, Record record, int index) {
353
 
354
				// et on met la valeur à jour dans la combobox
355
				comboBox.setValue(record.getAsString("nom_mode"));
356
				setModification(record.getAsString("mode")) ;
357
			}
358
 
359
		});
12 david 360
 
361
		this.add(panneauFormulaire) ;
80 jpm 362
		this.setTopToolbar(bt) ;
12 david 363
 
120 aurelien 364
		this.setAutoScroll(true);
12 david 365
 
366
 
201 david 367
 
368
		panneauFormulaire.addListener(new PanelListenerAdapter() {
369
	        public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight) {
370
	        	panneauIntermediaire.setWidth(rawWidth);
371
	        	panneauIntermediaire.setHeight(rawHeight);
372
	     }});
373
 
12 david 374
		// on ajoute les listeners
201 david 375
 
376
 
12 david 377
		ajouterListeners() ;
378
 
379
	}
380
 
381
	private void ajouterListeners()
94 jpm 382
	{
20 david 383
		// Listener completion communne
384
 
385
		   commune.addListener(new ComboBoxListenerAdapter() {
386
	             public void onSelect(ComboBox comboBox, Record record, int index) {
387
	                 commune.setValue(record.getAsString("commune"));
39 david 388
	                 departement=record.getAsString("departement");
20 david 389
	                 selectionCommune=true;
390
	             }
391
	         });
392
 
393
 
394
			ListenerConfig listenerConfigCommune=new ListenerConfig();
395
			listenerConfigCommune.setDelay(10);
396
			listenerConfigCommune.setStopPropagation(false);
397
			listenerConfigCommune.setStopEvent(false);
398
 
399
		    commune.addKeyPressListener(new EventCallback()	{
400
 
120 aurelien 401
	    	    public void execute(EventObject e) {
402
 
403
 
404
	    	    		switch(e.getKey()) {
405
 
132 aurelien 406
    	    				case KEY_ALT:
407
	    	    	        case KEY_CTRL:
408
	    	    	        case KEY_DOWN:
409
	    	    	        case KEY_END:
410
	    	    	        case KEY_ESCAPE:
411
	    	    	        case KEY_HOME:
412
	    	    	        case KEY_LEFT:
413
	    	    	        case KEY_PAGEDOWN:
414
	    	    	        case KEY_PAGEUP:
415
	    	    	        case KEY_RIGHT:
416
	    	    	        case KEY_SHIFT:
417
	    	    	        case KEY_TAB:
418
	    	    	        case KEY_UP:
419
 
420
	    	    	        break;
421
 
120 aurelien 422
	    	    	    	case KEY_ENTER:
423
 
20 david 424
		    	    	    	 if (selectionCommune) {
216 aurelien 425
		    	    	    		 communeModifiee= true;
20 david 426
		    	    	    		 selectionCommune=false;
427
		    	    	    	 }
120 aurelien 428
		    	    	    	else {
429
 
118 david 430
		    	    	    		validerSaisie(Champs.COMMUNE);
20 david 431
		    	    	    		// lancer mise a jour
432
		    	    	    	 }
120 aurelien 433
		    	    	    break;
434
 
435
		    	    	    default:
20 david 436
 
83 david 437
		    	    	    	  departement="";
20 david 438
		    	    	    	  obtenirListeReferentielCommune();
216 aurelien 439
		    	    	    	  communeModifiee= true;
20 david 440
 
120 aurelien 441
		    	    	    break;
442
	    	    	    }
443
	     			}
444
	    		},    listenerConfigCommune
20 david 445
			);
446
 
120 aurelien 447
		    date.addKeyPressListener(new EventCallback() {
20 david 448
 
120 aurelien 449
				public void execute(EventObject e) {
450
					// TODO Auto-generated method stub
451
					switch(e.getKey()) {
221 aurelien 452
 
453
						case KEY_ALT:
454
		    	        case KEY_CTRL:
455
		    	        case KEY_DOWN:
456
		    	        case KEY_END:
457
		    	        case KEY_ESCAPE:
458
		    	        case KEY_HOME:
459
		    	        case KEY_LEFT:
460
		    	        case KEY_PAGEDOWN:
461
		    	        case KEY_PAGEUP:
462
		    	        case KEY_RIGHT:
463
		    	        case KEY_SHIFT:
464
		    	        case KEY_TAB:
465
		    	        	if(date.getRawValue().equals(VALEURS_MULTIPLES)) {
466
		    	        		date.clearInvalid();
467
		    	        	}
468
		    	        case KEY_UP:
469
 
470
		    	        break;
120 aurelien 471
 
221 aurelien 472
	  	    	      case KEY_ENTER:
473
	  	    	    		validerSaisie(Champs.DATE);
120 aurelien 474
	  	    	    	  break;
475
 
476
	  	    	      default:
221 aurelien 477
	  					dateModifiee = true;
120 aurelien 478
					}
479
				}
480
		    });
481
 
221 aurelien 482
		    date.addListener(new DatePickerListenerAdapter() {
483
 
484
				public void onSelect(DatePicker dataPicker, Date date) {
485
					dateModifiee = true;
486
				}
487
		    });
488
 
120 aurelien 489
		    station.addKeyPressListener(new EventCallback() {
490
 
491
				public void execute(EventObject e) {
492
					// TODO Auto-generated method stub
493
					switch(e.getKey()) {
494
 
221 aurelien 495
						case KEY_ALT:
496
		    	        case KEY_CTRL:
497
		    	        case KEY_DOWN:
498
		    	        case KEY_END:
499
		    	        case KEY_ESCAPE:
500
		    	        case KEY_HOME:
501
		    	        case KEY_LEFT:
502
		    	        case KEY_PAGEDOWN:
503
		    	        case KEY_PAGEUP:
504
		    	        case KEY_RIGHT:
505
		    	        case KEY_SHIFT:
506
		    	        case KEY_TAB:
507
		    	        case KEY_UP:
508
		    	      break;
509
 
120 aurelien 510
	  	    	      case KEY_ENTER:
511
	  	    	    		validerSaisie(Champs.STATION);
512
	  	    	    	  break;
513
 
514
	  	    	      default:
221 aurelien 515
	  	    	    	  stationModifiee = true;
120 aurelien 516
					}
517
				}
518
		    });
519
 
520
 
20 david 521
 
120 aurelien 522
			// Listener completion espece
20 david 523
			espece.addListener(new ComboBoxListenerAdapter() {
524
	             public void onSelect(ComboBox comboBox, Record record, int index) {
525
	            	 espece.setValue(record.getAsString("nom"));
39 david 526
	            	 numeroNom=record.getAsString("numeroNom");
20 david 527
	                 selectionEspece=true;
128 aurelien 528
	                 observationMediateur.obtenirImageInformationExternes(numeroNom);
20 david 529
	             }
530
	         });
531
 
532
 
533
			ListenerConfig listenerConfigEspece=new ListenerConfig();
534
			listenerConfigEspece.setDelay(10);
535
			listenerConfigEspece.setStopPropagation(false);
536
			listenerConfigEspece.setStopEvent(false);
537
 
538
 
539
			espece.addKeyPressListener(new EventCallback()	{
540
 
541
		    	    public void execute(EventObject e) {
542
 
543
 
544
		    	    		  switch(e.getKey()) {
545
 
546
 
547
		    	    		  case KEY_ALT:
548
		    	    	      case KEY_CTRL:
549
		    	    	      case KEY_DOWN:
550
		    	    	      case KEY_END:
551
		    	    	      case KEY_ESCAPE:
552
		    	    	      case KEY_HOME:
553
		    	    	      case KEY_LEFT:
554
		    	    	      case KEY_PAGEDOWN:
555
		    	    	      case KEY_PAGEUP:
556
		    	    	      case KEY_RIGHT:
557
		    	    	      case KEY_SHIFT:
558
		    	    	      case KEY_TAB:
559
		    	    	      case KEY_UP:
560
 
561
		    	    	        break;
562
 
563
		    	    	      case KEY_ENTER:
564
 
140 aurelien 565
			    	    	    	if(selectionEspece) {
216 aurelien 566
			    	    	    		especeModifiee = true;
567
			    	    	    		selectionEspece=false;
140 aurelien 568
			    	    	    	}
569
			    	    	    	else {
570
			    	    	    		validerSaisie(Champs.ESPECE);
571
			    	    	    	}
20 david 572
 
573
		    	    	    	  break;
574
 
575
		    	    	      default:
576
 
83 david 577
		    	    	    	  numeroNom="";
20 david 578
		    	    	    	  obtenirListeReferentielNom();
216 aurelien 579
		    	    	    	  especeModifiee = true;
20 david 580
 
581
		    	    	        break;
582
		    	    	    }
583
 
584
 
585
 
586
		     		}
587
 
588
		    		},    listenerConfigEspece
589
 
590
			);
591
 
120 aurelien 592
			lieudit.addKeyPressListener(new EventCallback() {
20 david 593
 
120 aurelien 594
				public void execute(EventObject e) {
595
					// TODO Auto-generated method stub
596
					switch(e.getKey()) {
597
 
221 aurelien 598
					case KEY_ALT:
599
	  	    	      case KEY_CTRL:
600
	  	    	      case KEY_DOWN:
601
	  	    	      case KEY_END:
602
	  	    	      case KEY_ESCAPE:
603
	  	    	      case KEY_HOME:
604
	  	    	      case KEY_LEFT:
605
	  	    	      case KEY_PAGEDOWN:
606
	  	    	      case KEY_PAGEUP:
607
	  	    	      case KEY_RIGHT:
608
	  	    	      case KEY_SHIFT:
609
	  	    	      case KEY_TAB:
610
	  	    	      case KEY_UP:
611
 
612
  	    	        break;
613
 
120 aurelien 614
	  	    	      case KEY_ENTER:
615
	  	    	    		validerSaisie(Champs.LIEUDIT);
616
	  	    	    	  break;
617
 
618
	  	    	      default:
221 aurelien 619
	  					lieuDitModifie = true;
120 aurelien 620
					}
621
				}
622
		    });
623
 
624
			milieu.addKeyPressListener(new EventCallback() {
625
 
626
				public void execute(EventObject e) {
627
					// TODO Auto-generated method stub
628
					switch(e.getKey()) {
221 aurelien 629
 
630
						case KEY_ALT:
631
	  	    	      case KEY_CTRL:
632
	  	    	      case KEY_DOWN:
633
	  	    	      case KEY_END:
634
	  	    	      case KEY_ESCAPE:
635
	  	    	      case KEY_HOME:
636
	  	    	      case KEY_LEFT:
637
	  	    	      case KEY_PAGEDOWN:
638
	  	    	      case KEY_PAGEUP:
639
	  	    	      case KEY_RIGHT:
640
	  	    	      case KEY_SHIFT:
641
	  	    	      case KEY_TAB:
642
	  	    	      case KEY_UP:
643
 
644
	  	    	        break;
120 aurelien 645
 
646
	  	    	      case KEY_ENTER:
647
	  	    	    		validerSaisie(Champs.MILIEU);
648
	  	    	    	  break;
649
 
650
	  	    	      default:
221 aurelien 651
	  					milieuModifie = true;
120 aurelien 652
					}
653
				}
654
		    });
655
 
216 aurelien 656
			comment.addKeyPressListener(new EventCallback() {
120 aurelien 657
 
658
				public void execute(EventObject e) {
221 aurelien 659
					switch(e.getKey()) {
660
						case KEY_ALT:
661
			    	      case KEY_CTRL:
662
			    	      case KEY_DOWN:
663
			    	      case KEY_END:
664
			    	      case KEY_ESCAPE:
665
			    	      case KEY_HOME:
666
			    	      case KEY_LEFT:
667
			    	      case KEY_PAGEDOWN:
668
			    	      case KEY_PAGEUP:
669
			    	      case KEY_RIGHT:
670
			    	      case KEY_SHIFT:
671
			    	      case KEY_TAB:
672
			    	      case KEY_UP:
673
 
674
		    	        break;
675
 
676
		    	        default:
677
						commModifie = true;
678
					}
120 aurelien 679
				}
216 aurelien 680
		    });
120 aurelien 681
 
20 david 682
 
683
 
684
		boutonOK.addListener(new ButtonListenerAdapter() {
39 david 685
 
20 david 686
			public void onClick(Button button, EventObject e) {
118 david 687
 
688
				if(modification) {
216 aurelien 689
					if(masseModification) {
690
							modifierObservationEnMasse(null);
691
					} else {
692
						modifierObservation() ;
693
					}
71 jpm 694
				}
118 david 695
				else {
71 jpm 696
					ajouterObservation();
697
				}
39 david 698
 
71 jpm 699
 
20 david 700
			}
701
 
702
		});
77 jpm 703
 
704
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
12 david 705
 
706
			public void onClick(Button button, EventObject e) {
707
 
77 jpm 708
				if(modification)
709
				{
710
					supprimerObservation() ;
711
				}
712
				else
713
				{
104 jpm 714
					raz();
77 jpm 715
				}
12 david 716
 
77 jpm 717
 
718
			}
719
 
12 david 720
		});
132 aurelien 721
 
722
		this.addListener(new ContainerListenerAdapter() {
723
			public void onAfterLayout(Container self) {
724
				commune.focus();
725
			}
726
		});
727
 
12 david 728
	}
729
 
730
	/**
118 david 731
	 * Validation de la saisie
732
	 */
733
 
734
	private void validerSaisie(Champs champs) {
735
 
736
		if(modification) {
216 aurelien 737
			if(masseModification) {
738
					modifierObservationEnMasse(champs);
739
			} else {
740
				modifierObservation();
741
			}
742
 
743
			raz(champs);
118 david 744
		}
745
		else {
746
			ajouterObservation();
747
			raz(champs);
748
		}
749
	}
750
 
751
	/**
12 david 752
	 * Desactive visuellement ce panneau
753
	 */
754
	public void desactiverPanneau()
755
	{
756
		this.setDisabled(true) ;
757
	}
758
 
759
	/**
760
	 * Active visuellement ce panneau
761
	 */
762
	public void activerPanneau()
763
	{
764
		this.setDisabled(false) ;
765
	}
13 david 766
 
767
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
768
 
49 david 769
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
13 david 770
			if(nouvelleDonnees instanceof ListeReferentielCommune)
771
			{
772
 
773
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
774
					Object[][] communeData = new Object[data.size()][2];
775
					int i = 0 ;
776
 
777
					// on la parse et on récupère les informations quiç nous interessent
778
					for (Iterator it = data.keySet().iterator(); it.hasNext();)
779
					{
780
 
781
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
782
 
783
						communeData[i][0]= ref.getCommune();
784
						communeData[i][1]= ref.getDepartement();
785
 
786
 
787
						i++ ;
788
					}
789
 
790
					   //	  creation du store
791
					FieldDef defCommune = new StringFieldDef("commune");
792
					FieldDef defDepartement = new StringFieldDef("departement");
793
 
794
 
795
					FieldDef[] defTab = { defCommune, defDepartement};
796
 
797
					RecordDef rd = new RecordDef(defTab);
798
 
799
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
800
					final ArrayReader reader = new ArrayReader(rd);
801
 
20 david 802
					Store store=new Store(dataProxy,reader);
13 david 803
					store.load() ;
804
 
132 aurelien 805
					commune.setStore(store);
13 david 806
			}
20 david 807
 
94 jpm 808
			//			 si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
20 david 809
 
810
			if(nouvelleDonnees instanceof ListeReferentielNom)
811
			{
812
 
813
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
814
					Object[][] nomData = new Object[data.size()][2];
815
					int i = 0 ;
816
 
817
					// on la parse et on récupère les informations quiç nous interessent
818
					for (Iterator it = data.keySet().iterator(); it.hasNext();)
819
					{
820
 
821
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
822
 
823
						nomData[i][0]= ref.getNom();
824
						nomData[i][1]= ref.getNumeroNom();
825
 
826
 
827
						i++ ;
828
					}
829
 
830
					   //	  creation du store
831
					FieldDef defNom = new StringFieldDef("nom");
832
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
833
 
834
 
835
					FieldDef[] defTab = { defNom, defNumeroNom};
836
 
837
					RecordDef rd = new RecordDef(defTab);
838
 
839
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
840
					final ArrayReader reader = new ArrayReader(rd);
841
 
842
					Store store=new Store(dataProxy,reader);
843
					store.load() ;
844
 
845
					espece.setStore(store);
846
 
847
			}
848
 
82 david 849
			// On recoit une observation dont on veut afficher le detail
850
 
71 jpm 851
			if(nouvelleDonnees instanceof Observation)
852
			{
853
				Observation obs = (Observation)nouvelleDonnees ;
854
				afficherDetailsObservation(obs) ;
855
			}
77 jpm 856
 
216 aurelien 857
			if(nouvelleDonnees instanceof ListeObservation) {
858
				ListeObservation listeObs = (ListeObservation)nouvelleDonnees;
859
				calculerAfficherDifferences(listeObs);
860
			}
861
 
82 david 862
			// Sur Mise à jour ou suppression d'une suppression ?
863
 
77 jpm 864
			if(nouvelleDonnees instanceof String)
865
			{
866
				String str = (String)nouvelleDonnees ;
107 aurelien 867
				observationMediateur.obtenirNombreObservation() ;
77 jpm 868
			}
140 aurelien 869
 
870
			if(nouvelleDonnees instanceof String[]) {
871
				String[] anumNom = (String[])nouvelleDonnees ;
872
				numeroNom = anumNom[1];
873
				espece.setValue(anumNom[0]);
874
				setModification("false");
875
			}
20 david 876
 
13 david 877
	}
878
	public void obtenirListeReferentielCommune() {
94 jpm 879
 
20 david 880
	 String com=commune.getText().replaceAll(" ","/");
881
	 com=com.replaceAll("%","");
882
 
883
	 observationMediateur.obtenirListeReferentielCommune(this,com);
13 david 884
 
885
	}
20 david 886
 
887
 
888
	public void obtenirListeReferentielNom() {
889
 
890
	  String esp=espece.getText().replaceAll(" ","/");
891
	  esp=esp.replaceAll("%","");
892
 
893
	  observationMediateur.obtenirListeReferentielNom(this,esp);
894
 
895
	}
896
 
897
 
39 david 898
	public void ajouterObservation() {
140 aurelien 899
 
900
		if(departement.equals("000null") || departement.equals("")) {
901
			String[] depCom = commune.getText().split(" ");
902
			if(depCom.length > 1) {
903
				String dep = depCom[1].replace('(', ' ');
904
				dep =dep.replace(')', ' ');
905
				dep = dep.trim();
906
				dep = dep.replace('\\',' ');
907
				dep = dep.trim();
908
 
909
				try
910
				{
911
					int nDep = Integer.parseInt(dep);
912
					if(nDep > 0 && nDep < 110) {
913
						departement = dep ;
914
					}
915
				}
916
				catch(NumberFormatException e)
917
				{
918
					departement = "" ;
919
				}
920
			}
921
		}
39 david 922
 
120 aurelien 923
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());
46 david 924
		observationMediateur.ajouterObservation(obs);
39 david 925
	}
12 david 926
 
71 jpm 927
	private void modifierObservation() {
229 aurelien 928
 
929
		if(departement.equals("000null") || departement.equals("")) {
930
			String[] depCom = commune.getText().split(" ");
931
			if(depCom.length > 1) {
932
				String dep = depCom[1].replace('(', ' ');
933
				dep =dep.replace(')', ' ');
934
				dep = dep.trim();
935
				dep = dep.replace('\\',' ');
936
				dep = dep.trim();
937
 
938
				try
939
				{
940
					int nDep = Integer.parseInt(dep);
941
					if(nDep > 0 && nDep < 110) {
942
						departement = dep ;
943
					}
944
				}
945
				catch(NumberFormatException e)
946
				{
947
					departement = "" ;
948
				}
949
			}
950
		}
951
 
120 aurelien 952
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());
79 david 953
		obs.setNumeroOrdre(numeroOrdre);
216 aurelien 954
 
79 david 955
		observationMediateur.modifierObservation(obs);
216 aurelien 956
 
205 aurelien 957
		selecteurMode.setValue("création");
958
		setModification("false");
959
 
71 jpm 960
	}
77 jpm 961
 
216 aurelien 962
	private void modifierObservationEnMasse(Champs champModifie) {
963
		String communeM = null;
964
		String departementM = null;
221 aurelien 965
		String numNomSelM = null;
216 aurelien 966
		String lieuDitM = null;
967
		String stationM = null;
968
		String milieuM = null;
969
		String dateM = null;
970
		String especeM = null;
971
		String commM = null;
972
 
973
		String champs = modeleMessageModif;
974
 
975
		if(communeModifiee) {
976
			communeM = commune.getText();
221 aurelien 977
 
978
			if(departement.equals("000null") || departement.equals("")) {
979
				String[] depCom = commune.getText().split(" ");
980
				if(depCom.length > 1) {
981
					String dep = depCom[1].replace('(', ' ');
982
					dep =dep.replace(')', ' ');
983
					dep = dep.trim();
984
					dep = dep.replace('\\',' ');
985
					dep = dep.trim();
986
 
987
					try
988
					{
989
						int nDep = Integer.parseInt(dep);
990
						if(nDep > 0 && nDep < 110) {
991
							departement = dep ;
992
						}
993
					}
994
					catch(NumberFormatException e)
995
					{
996
						departement = "" ;
997
					}
998
				}
999
			}
1000
 
1001
			departementM = departement;
216 aurelien 1002
		} else {
221 aurelien 1003
			champs = champs.replaceAll("commune", "");
216 aurelien 1004
		}
1005
 
221 aurelien 1006
		if(lieuDitModifie) {
216 aurelien 1007
			lieuDitM = lieudit.getText();
1008
		}else {
221 aurelien 1009
			champs = champs.replaceAll(":lieu-dit", "");
216 aurelien 1010
		}
1011
 
221 aurelien 1012
		if(stationModifiee) {
216 aurelien 1013
			stationM = station.getText();
1014
		}else {
221 aurelien 1015
			champs = champs.replaceAll(":station", "");
216 aurelien 1016
		}
1017
 
1018
		if(milieuModifie) {
1019
			milieuM = milieu.getText();
1020
		}else {
221 aurelien 1021
			champs = champs.replaceAll(":milieu", "");
216 aurelien 1022
		}
1023
 
221 aurelien 1024
		if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
216 aurelien 1025
			dateM = date.getRawValue();
1026
		}else {
221 aurelien 1027
			champs = champs.replaceAll(":date", "");
216 aurelien 1028
		}
1029
 
1030
		if(especeModifiee) {
1031
			especeM = espece.getText();
221 aurelien 1032
			numNomSelM = numeroNom;
216 aurelien 1033
		}else {
221 aurelien 1034
			champs = champs.replaceAll(":espece", "");
216 aurelien 1035
		}
1036
 
1037
		if(commModifie) {
1038
			commM = comment.getText();
1039
		}else {
221 aurelien 1040
			champs = champs.replaceAll(":commentaire", "");
216 aurelien 1041
		}
1042
 
221 aurelien 1043
		champs = champs.replaceAll(":",", ");
1044
		if(champs.startsWith(",")) {
1045
			champs = champs.replaceFirst(",", "");
1046
		}
216 aurelien 1047
 
221 aurelien 1048
		String message = "Voulez vous modifier le(s) champ(s) suivant(s) : "+champs+"   pour les observations selectionnées ?" ;
1049
 
216 aurelien 1050
		if(champs.trim().equals("")) {
1051
			Window.alert("Aucun champ n'a été modifié");
1052
		} else {
221 aurelien 1053
			Observation obs = new Observation(especeM,numNomSelM,communeM,departementM,lieuDitM,stationM,milieuM, commM,dateM);
216 aurelien 1054
			obs.setNumeroOrdre(numeroOrdre);
1055
			if(Window.confirm(message)) {
1056
				observationMediateur.modifierObservationEnMasse(obs);
221 aurelien 1057
				reinitialiserValeurModifiees();
216 aurelien 1058
			}
1059
		}
1060
	}
1061
 
77 jpm 1062
	private void supprimerObservation() {
1063
 
216 aurelien 1064
		observationMediateur.supprimerObservation(this, numeroOrdre);
77 jpm 1065
	}
12 david 1066
 
71 jpm 1067
 
1068
	public void afficherDetailsObservation(Observation obs)
1069
	{
104 jpm 1070
		raz() ;
216 aurelien 1071
		String idLoc ;
1072
		if(obs.getIdentifiantLocalite() != VALEURS_MULTIPLES) {
1073
			idLoc =obs.getIdentifiantLocalite().replaceAll(" ","/");
1074
			idLoc = idLoc.replaceAll("%","");
1075
			idLoc = idLoc.replaceAll("\"","");
1076
			idLoc = idLoc.replace('\\',' ');
1077
			idLoc = idLoc.trim();
1078
		} else {
1079
			idLoc = obs.getIdentifiantLocalite();
1080
		}
71 jpm 1081
 
221 aurelien 1082
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
71 jpm 1083
			String[] dateEtHeure = obs.getDate().split(" ", 2);
110 aurelien 1084
			if(verifierFormatDate(dateEtHeure[0])) {
1085
				date.setValue(dateEtHeure[0]) ;
1086
			}
1087
			else
1088
			{
1089
				date.setRawValue("");
1090
			}
221 aurelien 1091
		} else {
1092
			date.setRawValue(VALEURS_MULTIPLES);
1093
			date.clearInvalid();
71 jpm 1094
		}
1095
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
1096
			lieudit.setValue(obs.getLieudit()) ;
1097
		}
1098
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
1099
			station.setValue(obs.getStation()) ;
1100
		}
1101
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1102
			milieu.setValue(obs.getMilieu()) ;
1103
		}
1104
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1105
			comment.setValue(obs.getCommentaire()) ;
1106
		}
1107
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
221 aurelien 1108
			if(!idLoc.equals("000null")) {
1109
				if(!idLoc.equals(VALEURS_MULTIPLES)) {
1110
					commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
1111
				} else {
1112
					commune.setValue(VALEURS_MULTIPLES);
1113
				}
140 aurelien 1114
			}
1115
			else
1116
			{
1117
				commune.setValue(obs.getLocalite());
1118
			}
71 jpm 1119
		}
1120
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
140 aurelien 1121
			departement = idLoc;
71 jpm 1122
		}
1123
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
1124
			espece.setValue(obs.getNomSaisi()) ;
1125
		}
1126
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
1127
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
1128
		}
83 david 1129
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
74 david 1130
			numeroOrdre = obs.getNumeroOrdre() ;
1131
		}
1132
 
71 jpm 1133
	}
1134
 
118 david 1135
 
104 jpm 1136
	public void raz()
71 jpm 1137
	{
118 david 1138
		raz(Champs.TOUT);
1139
 
1140
	}
1141
	public void raz(Champs champs)
1142
	{
1143
		switch (champs) {
1144
 
1145
 
1146
			case DATE:
1147
				date.reset() ;
1148
				break;
1149
 
1150
			case LIEUDIT:
1151
				lieudit.reset() ;
1152
				break;
1153
 
1154
			case STATION:
1155
				station.reset() ;
1156
				break;
1157
 
1158
			case MILIEU:
1159
				milieu.reset() ;
1160
				break;
1161
 
1162
			case COMMENT:
1163
				comment.reset() ;
1164
				break;
1165
 
1166
 
1167
			case COMMUNE:
172 aurelien 1168
				commune.reset() ;
118 david 1169
				departement ="";
1170
				break;
1171
 
1172
			case ESPECE:
1173
				espece.reset();
1174
				numeroNom = "" ;
1175
				numeroOrdre = "";
1176
				break;
1177
 
1178
			case TOUT:
132 aurelien 1179
				commune.reset();
118 david 1180
				date.reset() ;
1181
				lieudit.reset() ;
1182
				station.reset() ;
1183
				milieu.reset() ;
1184
				comment.reset() ;
1185
				milieu.reset() ;
1186
				departement ="";
1187
				espece.reset();
1188
				numeroNom = "" ;
1189
				numeroOrdre = "";
1190
				break;
1191
 
1192
		}
71 jpm 1193
 
1194
	}
1195
 
1196
	private void setModification(String mode)
1197
	{
1198
		if(mode.equals("true")) {
1199
 
1200
			boutonOK.setText("Modifier") ;
1201
			setTitle("Modification") ;
77 jpm 1202
			boutonAnnuler.setText("Supprimer") ;
71 jpm 1203
			modification = true ;
97 jpm 1204
			selecteurMode.removeClass("x-selec-crea") ;
1205
			selecteurMode.setCls("x-selec-modif") ;
216 aurelien 1206
			observationMediateur.onModeModification();
71 jpm 1207
		}
1208
		else
1209
		{
120 aurelien 1210
			boutonOK.setText("Ajouter") ;
71 jpm 1211
			setTitle("Saisir") ;
77 jpm 1212
			boutonAnnuler.setText("Réinitialiser") ;
71 jpm 1213
			modification = false ;
97 jpm 1214
			selecteurMode.removeClass("x-selec-modif") ;
1215
			selecteurMode.setCls("x-selec-crea") ;
94 jpm 1216
 
132 aurelien 1217
		}
71 jpm 1218
	}
1219
 
1220
	/**
1221
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
1222
	 * @return
1223
	 */
1224
	public boolean getModification()
1225
	{
1226
		return modification ;
1227
	}
110 aurelien 1228
 
216 aurelien 1229
	/**
1230
	 * renvoie vrai si on est en mode modification de masse, faux sinon
1231
	 * @return
1232
	 */
1233
	public boolean getMasseModification()
1234
	{
1235
		return masseModification ;
1236
	}
1237
 
110 aurelien 1238
	public boolean verifierFormatDate(String date) {
1239
 
132 aurelien 1240
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
110 aurelien 1241
		if(date.matches(regex) && !date.equals("0000-00-00")) {
1242
			return true ;
1243
		}
1244
		else {
1245
			return false;
1246
		}
1247
	}
216 aurelien 1248
 
1249
	public void setMasseModification(boolean masseModification) {
1250
		this.masseModification = masseModification;
1251
		if(masseModification) {
1252
			reinitialiserValeurModifiees();
1253
		}
1254
	}
132 aurelien 1255
 
216 aurelien 1256
	private void calculerAfficherDifferences(ListeObservation listeObs) {
1257
 
1258
		String departement = null;
1259
		String commune = null;
1260
		String lieuDit = null;
1261
		String station = null;
1262
		String milieu = null;
1263
		String espece = null;
1264
		String date = null;
1265
		String notes = null;
1266
 
1267
		String ordreObs = "";
1268
 
1269
		for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
1270
			Observation obsEnCours = listeObs.get(it.next());
1271
			departement = comparerDifferencesChamps(departement, obsEnCours.getIdentifiantLocalite());
1272
			commune = comparerDifferencesChamps(commune, obsEnCours.getLocalite());
1273
			lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
1274
			station = comparerDifferencesChamps(station, obsEnCours.getStation());
1275
			milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
1276
			espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi());
1277
			date = comparerDifferencesChamps(date, obsEnCours.getDate());
1278
			notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire());
1279
 
1280
			ordreObs += obsEnCours.getNumeroOrdre()+",";
1281
		}
1282
 
1283
		Observation obs=new Observation(espece,numeroNom,commune,departement,lieuDit,station,milieu, notes,date);
1284
		obs.setNumeroOrdre(ordreObs);
1285
		rafraichir(obs, false);
1286
 
1287
	}
1288
 
1289
	private String comparerDifferencesChamps(String valeurActuelle, String nouvelleValeur) {
1290
 
1291
		String retour = "000null";
1292
 
1293
			if(valeurActuelle == null) {
1294
				retour = nouvelleValeur;
1295
			} else {
1296
				if(valeurActuelle.equals(nouvelleValeur)) {
1297
					retour = valeurActuelle;
1298
				} else {
1299
					retour = VALEURS_MULTIPLES;
1300
				}
1301
			}
1302
		return retour;
1303
	}
1304
 
1305
	private void reinitialiserValeurModifiees() {
1306
 
1307
		communeModifiee = false;
221 aurelien 1308
		lieuDitModifie = false;
1309
		stationModifiee = false;
216 aurelien 1310
		milieuModifie = false;
1311
		dateModifiee = false;
1312
		especeModifiee = false;
1313
		commModifie = false;
1314
	}
1315
 
1316
	private Field obtenirCorrespondanceChampsEnum(Champs champ) {
1317
		switch(champ) {
1318
    	case DATE:
1319
    		return date;
1320
 
1321
    	case COMMUNE:
1322
    		return commune;
1323
 
1324
		case LIEUDIT:
1325
			return lieudit;
1326
 
1327
		case STATION:
1328
			return station;
1329
 
1330
		case MILIEU:
1331
			return milieu;
1332
 
1333
		case COMMENT:
1334
			return comment;
1335
 
1336
    	case ESPECE:
1337
    		return espece;
1338
    	}
1339
		return null;
1340
	}
12 david 1341
}