Subversion Repositories eFlore/Applications.cel

Rev

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

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