Subversion Repositories eFlore/Applications.cel

Rev

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

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