Subversion Repositories eFlore/Applications.cel

Rev

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

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