Subversion Repositories eFlore/Applications.cel

Rev

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

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