Subversion Repositories eFlore/Applications.cel

Rev

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

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