Subversion Repositories eFlore/Applications.cel

Rev

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

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