Subversion Repositories eFlore/Applications.cel

Rev

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

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