Subversion Repositories eFlore/Applications.cel

Rev

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

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