Subversion Repositories eFlore/Applications.cel

Rev

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

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