Subversion Repositories eFlore/Applications.cel

Rev

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

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