Subversion Repositories eFlore/Applications.cel

Rev

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

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