Subversion Repositories eFlore/Applications.cel

Rev

Rev 120 | Rev 132 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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