Subversion Repositories eFlore/Applications.cel

Rev

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

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