Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 164 Rev 171
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
 
3
 
4
 
4
 
5
import java.util.Iterator;
5
import java.util.Iterator;
6
 
6
 
7
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.modeles.ListeReferentielCommune;
8
import org.tela_botanica.client.modeles.ListeReferentielCommune;
9
import org.tela_botanica.client.modeles.ListeReferentielNom;
9
import org.tela_botanica.client.modeles.ListeReferentielNom;
10
import org.tela_botanica.client.modeles.Observation;
10
import org.tela_botanica.client.modeles.Observation;
11
import org.tela_botanica.client.modeles.ReferentielCommune;
11
import org.tela_botanica.client.modeles.ReferentielCommune;
12
import org.tela_botanica.client.modeles.ReferentielNom;
12
import org.tela_botanica.client.modeles.ReferentielNom;
13
import org.tela_botanica.client.observation.ObservationMediateur;
13
import org.tela_botanica.client.observation.ObservationMediateur;
14
 
14
 
15
import com.google.gwt.user.client.Window;
15
import com.google.gwt.user.client.Window;
16
import com.gwtext.client.core.EventCallback;
16
import com.gwtext.client.core.EventCallback;
17
import com.gwtext.client.core.EventObject;
17
import com.gwtext.client.core.EventObject;
18
import com.gwtext.client.core.ListenerConfig;
18
import com.gwtext.client.core.ListenerConfig;
19
import com.gwtext.client.core.Position;
19
import com.gwtext.client.core.Position;
20
import com.gwtext.client.data.ArrayReader;
20
import com.gwtext.client.data.ArrayReader;
21
import com.gwtext.client.data.FieldDef;
21
import com.gwtext.client.data.FieldDef;
22
import com.gwtext.client.data.MemoryProxy;
22
import com.gwtext.client.data.MemoryProxy;
23
import com.gwtext.client.data.RecordDef;
23
import com.gwtext.client.data.RecordDef;
24
import com.gwtext.client.data.SimpleStore;
24
import com.gwtext.client.data.SimpleStore;
25
import com.gwtext.client.data.Store;
25
import com.gwtext.client.data.Store;
26
import com.gwtext.client.data.StringFieldDef;
26
import com.gwtext.client.data.StringFieldDef;
27
import com.gwtext.client.widgets.BoxComponent;
27
import com.gwtext.client.widgets.BoxComponent;
28
import com.gwtext.client.widgets.Button;
28
import com.gwtext.client.widgets.Button;
29
import com.gwtext.client.widgets.Component;
29
import com.gwtext.client.widgets.Component;
30
import com.gwtext.client.widgets.Container;
30
import com.gwtext.client.widgets.Container;
31
import com.gwtext.client.widgets.Panel;
31
import com.gwtext.client.widgets.Panel;
32
import com.gwtext.client.widgets.Toolbar;
32
import com.gwtext.client.widgets.Toolbar;
33
import com.gwtext.client.widgets.event.BoxComponentListener;
33
import com.gwtext.client.widgets.event.BoxComponentListener;
34
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
34
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
35
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
35
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
36
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
36
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
37
import com.gwtext.client.widgets.form.ComboBox;
37
import com.gwtext.client.widgets.form.ComboBox;
38
import com.gwtext.client.widgets.form.DateField;
38
import com.gwtext.client.widgets.form.DateField;
39
import com.gwtext.client.widgets.form.FormPanel;
39
import com.gwtext.client.widgets.form.FormPanel;
40
import com.gwtext.client.widgets.form.TextArea;
40
import com.gwtext.client.widgets.form.TextArea;
41
import com.gwtext.client.widgets.form.TextField;
41
import com.gwtext.client.widgets.form.TextField;
42
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
42
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
43
import com.gwtext.client.widgets.layout.ColumnLayout;
43
import com.gwtext.client.widgets.layout.ColumnLayout;
44
import com.gwtext.client.widgets.layout.ColumnLayoutData;
44
import com.gwtext.client.widgets.layout.ColumnLayoutData;
45
import com.gwtext.client.widgets.layout.FormLayout;
45
import com.gwtext.client.widgets.layout.FormLayout;
46
import com.gwtext.client.data.Record;
46
import com.gwtext.client.data.Record;
47
 
47
 
48
/**
48
/**
49
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
49
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
50
 * @author aurelien
50
 * @author aurelien
51
 *
51
 *
52
 */
52
 */
53
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
53
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
54
 
54
 
55
 
55
 
56
	/**
56
	/**
57
	 * Le médiateur associé à la vue
57
	 * Le médiateur associé à la vue
58
	 */
58
	 */
59
	private ObservationMediateur	observationMediateur		= null;
59
	private ObservationMediateur	observationMediateur		= null;
60
	
60
	
61
	
61
	
62
 
62
 
63
	private DateField date = null;
63
	private DateField date = null;
64
	private TextField lieudit = null;
64
	private TextField lieudit = null;
65
	private TextField station = null;
65
	private TextField station = null;
66
	private TextField milieu = null;
66
	private TextField milieu = null;
67
	private TextField comment = null;
67
	private TextField comment = null;
68
	private ComboBox  commune = null;
68
	private ComboBox  commune = null;
69
	private String departement = null;
69
	private String departement = null;
70
	private ComboBox  espece = null;
70
	private ComboBox  espece = null;
71
	private String numeroNom = null;
71
	private String numeroNom = null;
72
	private String numeroOrdre = null;
72
	private String numeroOrdre = null;
73
 
73
 
74
	// Pour remise a zero partielle lors d'une validation
74
	// Pour remise a zero partielle lors d'une validation
75
	
75
	
76
	private  enum Champs {
76
	private  enum Champs {
77
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT 
77
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT 
78
	};
78
	};
79
	
79
	
80
	
80
	
81
 
81
 
82
	private String formatDate = null ;
82
	private String formatDate = null ;
83
	private Button boutonOK = new Button("Créer");
83
	private Button boutonOK = new Button("Créer");
84
	private Button boutonAnnuler = new Button("Réinitialiser");
84
	private Button boutonAnnuler = new Button("Réinitialiser");
85
 
85
 
86
	private boolean selectionCommune=false;
86
	private boolean selectionCommune=false;
87
	private boolean selectionEspece=false;
87
	private boolean selectionEspece=false;
88
	
88
	
89
	private boolean modification = false ;
89
	private boolean modification = false ;
90
	private Toolbar bt = null ;
90
	private Toolbar bt = null ;
91
	
91
	
92
	private final int KEY_ALT = 18;
92
	private final int KEY_ALT = 18;
93
	private final int KEY_BACKSPACE = 8;
93
	private final int KEY_BACKSPACE = 8;
94
	private final int KEY_CTRL = 17;
94
	private final int KEY_CTRL = 17;
95
	private final int KEY_DELETE = 46;
95
	private final int KEY_DELETE = 46;
96
	private final int KEY_DOWN = 40;
96
	private final int KEY_DOWN = 40;
97
	private final int KEY_END = 35;
97
	private final int KEY_END = 35;
98
	private final int KEY_ENTER = 13;
98
	private final int KEY_ENTER = 13;
99
	private final int KEY_ESCAPE = 27;
99
	private final int KEY_ESCAPE = 27;
100
	private final int KEY_HOME = 36;
100
	private final int KEY_HOME = 36;
101
	private final int KEY_LEFT = 37;
101
	private final int KEY_LEFT = 37;
102
	private final int KEY_PAGEDOWN = 34;
102
	private final int KEY_PAGEDOWN = 34;
103
	private final int KEY_PAGEUP = 33;
103
	private final int KEY_PAGEUP = 33;
104
	private final int KEY_RIGHT = 39;
104
	private final int KEY_RIGHT = 39;
105
	private final int KEY_SHIFT = 16;
105
	private final int KEY_SHIFT = 16;
106
	private final int KEY_TAB = 9;
106
	private final int KEY_TAB = 9;
107
	private final int KEY_UP = 38;
107
	private final int KEY_UP = 38;
108
	
108
	
109
	private int tailleChamps = 350 ;
109
	private int tailleChamps = 350 ;
110
	
110
	
111
	/**
111
	/**
112
	 * Combobox permettant de selectionner le mode
112
	 * Combobox permettant de selectionner le mode
113
	 * modification ou bien création
113
	 * modification ou bien création
114
	 */
114
	 */
115
	private ComboBox selecteurMode = new ComboBox();
115
	private ComboBox selecteurMode = new ComboBox();
116
	
116
	
117
	Store storeMode = null ;
117
	Store storeMode = null ;
118
 
118
 
119
	/**
119
	/**
120
	 * Booleen d'instanciation
120
	 * Booleen d'instanciation
121
	 */
121
	 */
122
	boolean estInstancie = false ;
122
	boolean estInstancie = false ;
123
	
123
	
124
	/**
124
	/**
125
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
125
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
126
	 */
126
	 */
127
	@SuppressWarnings("unused")
127
	@SuppressWarnings("unused")
128
	private FormulaireSaisieObservationVue()
128
	private FormulaireSaisieObservationVue()
129
	{
129
	{
130
		super() ;
130
		super() ;
131
	}
131
	}
132
	
132
	
133
	/**
133
	/**
134
	 * Constructeur avec argument
134
	 * Constructeur avec argument
135
	 * @param im
135
	 * @param im
136
	 */
136
	 */
137
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
137
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
138
	{
138
	{
139
		// on associe le médiateur
139
		// on associe le médiateur
140
		observationMediateur = obs ;
140
		observationMediateur = obs ;
141
		
141
		
142
		
142
		
143
		setHeader(true);
143
		setHeader(true);
144
		
144
		
145
		FormPanel panneauFormulaire = new FormPanel(Position.RIGHT);
145
		FormPanel panneauFormulaire = new FormPanel(Position.RIGHT);
146
		panneauFormulaire.setBorder(false);
146
		panneauFormulaire.setBorder(false);
147
		
147
		
148
		// Panneau intermediaire qui contient deux colonnes de formulaire
148
		// Panneau intermediaire qui contient deux colonnes de formulaire
149
		
149
		
150
		Panel panneauIntermediaire = new Panel();  
150
		Panel panneauIntermediaire = new Panel();  
151
		panneauIntermediaire.setLayout(new ColumnLayout());  
151
		panneauIntermediaire.setLayout(new ColumnLayout());  
152
		panneauIntermediaire.setBorder(false);
152
		panneauIntermediaire.setBorder(false);
153
		   
153
		   
154
		//create first panel and add fields to it  
154
		//create first panel and add fields to it  
155
		Panel panneauPremierColonne = new Panel();  
155
		Panel panneauPremierColonne = new Panel();  
156
		panneauPremierColonne.setLayout(new FormLayout());  
156
		panneauPremierColonne.setLayout(new FormLayout());  
157
		panneauPremierColonne.setBorder(false);
157
		panneauPremierColonne.setBorder(false);
158
 
158
 
159
		//create second panel and add fields to it  
159
		//create second panel and add fields to it  
160
	    Panel panneauSecondeColonne = new Panel();  
160
	    Panel panneauSecondeColonne = new Panel();  
161
		panneauSecondeColonne.setLayout(new FormLayout());  
161
		panneauSecondeColonne.setLayout(new FormLayout());  
162
		panneauSecondeColonne.setBorder(false);
162
		panneauSecondeColonne.setBorder(false);
163
		
163
		
164
		this.setPaddings(5) ;
164
		this.setPaddings(5) ;
165
	
165
	
166
		commune=new ComboBox("Commune","commune",tailleChamps );  
166
		commune=new ComboBox("Commune","commune",tailleChamps );  
167
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
167
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
168
		commune.setTpl(resultTplCommune);
168
		commune.setTpl(resultTplCommune);
169
		commune.setMode(ComboBox.REMOTE);
169
		commune.setMode(ComboBox.REMOTE);
170
		// commune.setPageSize(10); // Ne fonctionne pas 
170
		// commune.setPageSize(10); // Ne fonctionne pas 
171
		commune.setItemSelector("div.search-item-commune");
171
		commune.setItemSelector("div.search-item-commune");
172
		commune.setTypeAhead(true);  
172
		commune.setTypeAhead(true);  
173
		commune.setLoadingText("Recherche...");  
173
		commune.setLoadingText("Recherche...");  
174
		  
174
		  
175
		commune.setHideTrigger(true);
175
		commune.setHideTrigger(true);
176
		commune.setTabIndex(1);
176
		commune.setTabIndex(1);
177
		
177
		
178
	    panneauPremierColonne.add(commune);  
178
	    panneauPremierColonne.add(commune);  
179
 
179
 
180
	    station = new TextField("Station", "station", tailleChamps);  
180
	    station = new TextField("Station", "station", tailleChamps);  
181
	    station.setAllowBlank(true);
181
	    station.setAllowBlank(true);
182
	    station.setTabIndex(3);
182
	    station.setTabIndex(3);
183
	    panneauPremierColonne.add(station);  
183
	    panneauPremierColonne.add(station);  
184
	    
184
	    
185
	    date = new DateField("Date", "date", 100);  
185
	    date = new DateField("Date", "date", 100);  
186
	    date.setAllowBlank(true);
186
	    date.setAllowBlank(true);
187
	    formatDate = "d/m/Y";
187
	    formatDate = "d/m/Y";
188
	    date.setFormat(formatDate) ;
188
	    date.setFormat(formatDate) ;
189
	    date.setTabIndex(5);
189
	    date.setTabIndex(5);
190
	    panneauPremierColonne.add(date);  
190
	    panneauPremierColonne.add(date);  
191
 
191
 
192
	 	
192
	 	
193
		espece=new ComboBox("Espèce","nom",tailleChamps );  
193
		espece=new ComboBox("Espèce","nom",tailleChamps );  
194
		
194
		
195
		
195
		
196
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";  
196
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";  
197
 
197
 
198
		
198
		
199
		espece.setTpl(resultTplEspece);
199
		espece.setTpl(resultTplEspece);
200
		espece.setMode(ComboBox.REMOTE);
200
		espece.setMode(ComboBox.REMOTE);
201
		// commune.setPageSize(10); // Ne fonctionne pas 
201
		// commune.setPageSize(10); // Ne fonctionne pas 
202
		espece.setItemSelector("div.search-item-espece");
202
		espece.setItemSelector("div.search-item-espece");
203
		espece.setTypeAhead(true);  
203
		espece.setTypeAhead(true);  
204
		espece.setLoadingText("Recherche...");  
204
		espece.setLoadingText("Recherche...");  
205
		  
205
		  
206
		espece.setHideTrigger(true);
206
		espece.setHideTrigger(true);
207
		espece.setTabIndex(6);
207
		espece.setTabIndex(6);
208
 
208
 
209
	    panneauPremierColonne.add(espece);   
209
	    panneauPremierColonne.add(espece);   
210
	    
210
	    
211
	    lieudit = new TextField("Lieu-dit", "lieudit", tailleChamps);  
211
	    lieudit = new TextField("Lieu-dit", "lieudit", tailleChamps);  
212
	    lieudit.setAllowBlank(true);
212
	    lieudit.setAllowBlank(true);
213
	    lieudit.setTabIndex(2);
213
	    lieudit.setTabIndex(2);
214
	    panneauSecondeColonne.add(lieudit);  
214
	    panneauSecondeColonne.add(lieudit);  
215
	       
215
	       
216
	
216
	
217
	    milieu = new TextField("Milieu", "milieu", tailleChamps);  
217
	    milieu = new TextField("Milieu", "milieu", tailleChamps);  
218
	    milieu.setAllowBlank(true);
218
	    milieu.setAllowBlank(true);
219
	    milieu.setTabIndex(4);
219
	    milieu.setTabIndex(4);
220
	    panneauSecondeColonne.add(milieu);
220
	    panneauSecondeColonne.add(milieu);
221
	    
221
	    
222
	    comment = new TextArea("Notes", "comment");  
222
	    comment = new TextArea("Notes", "comment");  
223
	    comment.setAllowBlank(true);
223
	    comment.setAllowBlank(true);
224
	    comment.setHeight(50);
224
	    comment.setHeight(50);
225
	    comment.setWidth(tailleChamps);
225
	    comment.setWidth(tailleChamps);
226
	    comment.setTabIndex(7);
226
	    comment.setTabIndex(7);
227
	    panneauSecondeColonne.add(comment);
227
	    panneauSecondeColonne.add(comment);
228
	   
228
	   
229
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
229
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
230
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
230
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
231
		
231
		
232
		panneauFormulaire.add(panneauIntermediaire);
232
		panneauFormulaire.add(panneauIntermediaire);
233
		
233
		
234
		Object[][] mode = {{"création",false} , {"modification", true} };
234
		Object[][] mode = {{"création",false} , {"modification", true} };
235
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
235
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
236
				mode);
236
				mode);
237
		storeMode.load();
237
		storeMode.load();
238
		selecteurMode.setStore(storeMode);
238
		selecteurMode.setStore(storeMode);
239
		selecteurMode.setDisplayField("nom_mode") ;
239
		selecteurMode.setDisplayField("nom_mode") ;
240
		selecteurMode.setLabel("mode ") ;
240
		selecteurMode.setLabel("mode ") ;
241
		selecteurMode.setForceSelection(true) ;
241
		selecteurMode.setForceSelection(true) ;
242
		selecteurMode.setValue("création") ;
242
		selecteurMode.setValue("création") ;
243
		selecteurMode.setEditable(false) ;
243
		selecteurMode.setEditable(false) ;
244
		selecteurMode.setCls("x-selec-crea") ;
244
		selecteurMode.setCls("x-selec-crea") ;
245
		
245
		
246
		bt = new Toolbar() ;
246
		bt = new Toolbar() ;
247
		bt.addSpacer() ;
247
		bt.addSpacer() ;
248
		bt.addText("Mode de saisie ") ;
248
		bt.addText("Mode de saisie ") ;
249
		bt.addField(selecteurMode) ;
249
		bt.addField(selecteurMode) ;
250
		
250
		
251
		boutonOK.setTabIndex(8);
251
		boutonOK.setTabIndex(8);
252
		boutonAnnuler.setTabIndex(9);
252
		boutonAnnuler.setTabIndex(9);
253
		
253
		
254
		panneauFormulaire.addButton(boutonOK);
254
		panneauFormulaire.addButton(boutonOK);
255
		    
255
		    
256
		panneauFormulaire.addButton(boutonAnnuler);
256
		panneauFormulaire.addButton(boutonAnnuler);
257
		
257
		
258
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
258
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
259
 
259
 
260
			public void onSelect(ComboBox comboBox, Record record, int index) {
260
			public void onSelect(ComboBox comboBox, Record record, int index) {
261
				
261
				
262
				// et on met la valeur à jour dans la combobox
262
				// et on met la valeur à jour dans la combobox
263
				comboBox.setValue(record.getAsString("nom_mode"));
263
				comboBox.setValue(record.getAsString("nom_mode"));
264
				setModification(record.getAsString("mode")) ;
264
				setModification(record.getAsString("mode")) ;
265
			}
265
			}
266
 
266
 
267
		});
267
		});
268
	
268
	
269
		this.add(panneauFormulaire) ;
269
		this.add(panneauFormulaire) ;
270
		this.setTopToolbar(bt) ;
270
		this.setTopToolbar(bt) ;
271
		
271
		
272
		this.setAutoScroll(true);
272
		this.setAutoScroll(true);
273
		//this.setAutoHeight(true);
273
		//this.setAutoHeight(true);
274
	
274
	
275
	
275
	
276
		// on ajoute les listeners
276
		// on ajoute les listeners
277
		ajouterListeners() ;
277
		ajouterListeners() ;
278
		
278
		
279
	}
279
	}
280
	
280
	
281
	private void ajouterListeners()
281
	private void ajouterListeners()
282
	{	
282
	{	
283
		// Listener completion communne 
283
		// Listener completion communne 
284
		
284
		
285
		   commune.addListener(new ComboBoxListenerAdapter() {  
285
		   commune.addListener(new ComboBoxListenerAdapter() {  
286
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
286
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
287
	                 commune.setValue(record.getAsString("commune"));
287
	                 commune.setValue(record.getAsString("commune"));
288
	                 departement=record.getAsString("departement");
288
	                 departement=record.getAsString("departement");
289
	                 selectionCommune=true;
289
	                 selectionCommune=true;
290
	             }  
290
	             }  
291
	         });  
291
	         });  
292
	         
292
	         
293
	        
293
	        
294
			ListenerConfig listenerConfigCommune=new ListenerConfig();
294
			ListenerConfig listenerConfigCommune=new ListenerConfig();
295
			listenerConfigCommune.setDelay(10);
295
			listenerConfigCommune.setDelay(10);
296
			listenerConfigCommune.setStopPropagation(false);
296
			listenerConfigCommune.setStopPropagation(false);
297
			listenerConfigCommune.setStopEvent(false);
297
			listenerConfigCommune.setStopEvent(false);
298
			
298
			
299
		    commune.addKeyPressListener(new EventCallback()	{
299
		    commune.addKeyPressListener(new EventCallback()	{
300
		    	
300
		    	
301
	    	    public void execute(EventObject e) {
301
	    	    public void execute(EventObject e) {
302
	    	    	
302
	    	    	
303
	    	    		  
303
	    	    		  
304
	    	    		switch(e.getKey()) {
304
	    	    		switch(e.getKey()) {
305
	    	    	      
305
	    	    	      
306
    	    				case KEY_ALT:
306
    	    				case KEY_ALT:
307
	    	    	        case KEY_CTRL:
307
	    	    	        case KEY_CTRL:
308
	    	    	        case KEY_DOWN:
308
	    	    	        case KEY_DOWN:
309
	    	    	        case KEY_END:
309
	    	    	        case KEY_END:
310
	    	    	        case KEY_ESCAPE:
310
	    	    	        case KEY_ESCAPE:
311
	    	    	        case KEY_HOME:
311
	    	    	        case KEY_HOME:
312
	    	    	        case KEY_LEFT:
312
	    	    	        case KEY_LEFT:
313
	    	    	        case KEY_PAGEDOWN:
313
	    	    	        case KEY_PAGEDOWN:
314
	    	    	        case KEY_PAGEUP:
314
	    	    	        case KEY_PAGEUP:
315
	    	    	        case KEY_RIGHT:
315
	    	    	        case KEY_RIGHT:
316
	    	    	        case KEY_SHIFT:
316
	    	    	        case KEY_SHIFT:
317
	    	    	        case KEY_TAB:
317
	    	    	        case KEY_TAB:
318
	    	    	        case KEY_UP:
318
	    	    	        case KEY_UP:
319
	    	    	    	
319
	    	    	    	
320
	    	    	        break;
320
	    	    	        break;
321
	    	    		
321
	    	    		
322
	    	    	    	case KEY_ENTER:
322
	    	    	    	case KEY_ENTER:
323
	    	    	    	  
323
	    	    	    	  
324
		    	    	    	 if (selectionCommune) {
324
		    	    	    	 if (selectionCommune) {
325
		    	    	    		 selectionCommune=false;
325
		    	    	    		 selectionCommune=false;
326
		    	    	    	 }
326
		    	    	    	 }
327
		    	    	    	else {
327
		    	    	    	else {
328
	
328
	
329
		    	    	    		validerSaisie(Champs.COMMUNE);
329
		    	    	    		validerSaisie(Champs.COMMUNE);
330
		    	    	    		// lancer mise a jour 	    	    	    		 
330
		    	    	    		// lancer mise a jour 	    	    	    		 
331
		    	    	    	 }
331
		    	    	    	 }
332
		    	    	    break;
332
		    	    	    break;
333
	    	    	       
333
	    	    	       
334
		    	    	    default:
334
		    	    	    default:
335
		    	    	    	  
335
		    	    	    	  
336
		    	    	    	  departement="";
336
		    	    	    	  departement="";
337
		    	    	    	  obtenirListeReferentielCommune();
337
		    	    	    	  obtenirListeReferentielCommune();
338
		    	    	    	  	    	    	        
338
		    	    	    	  	    	    	        
339
		    	    	    break;
339
		    	    	    break;
340
	    	    	    }
340
	    	    	    }
341
	     			}
341
	     			}
342
	    		},    listenerConfigCommune
342
	    		},    listenerConfigCommune
343
			);
343
			);
344
		    
344
		    
345
		    date.addKeyPressListener(new EventCallback() {
345
		    date.addKeyPressListener(new EventCallback() {
346
 
346
 
347
				public void execute(EventObject e) {
347
				public void execute(EventObject e) {
348
					// TODO Auto-generated method stub
348
					// TODO Auto-generated method stub
349
					switch(e.getKey()) {
349
					switch(e.getKey()) {
350
	  	    	      
350
	  	    	      
351
	  	    	      case KEY_ENTER:	  	    	    	  
351
	  	    	      case KEY_ENTER:	  	    	    	  
352
	  	    	    		validerSaisie(Champs.DATE); 	    	    		 
352
	  	    	    		validerSaisie(Champs.DATE); 	    	    		 
353
	  	    	    	  break;
353
	  	    	    	  break;
354
	  	    	       
354
	  	    	       
355
	  	    	      default:
355
	  	    	      default:
356
					}
356
					}
357
				}
357
				}
358
		    });
358
		    });
359
		    
359
		    
360
		    station.addKeyPressListener(new EventCallback() {
360
		    station.addKeyPressListener(new EventCallback() {
361
 
361
 
362
				public void execute(EventObject e) {
362
				public void execute(EventObject e) {
363
					// TODO Auto-generated method stub
363
					// TODO Auto-generated method stub
364
					switch(e.getKey()) {
364
					switch(e.getKey()) {
365
	  	    	      
365
	  	    	      
366
	  	    	      case KEY_ENTER:	  	    	    	  
366
	  	    	      case KEY_ENTER:	  	    	    	  
367
	  	    	    		validerSaisie(Champs.STATION); 	    	    		 
367
	  	    	    		validerSaisie(Champs.STATION); 	    	    		 
368
	  	    	    	  break;
368
	  	    	    	  break;
369
	  	    	       
369
	  	    	       
370
	  	    	      default:
370
	  	    	      default:
371
					}
371
					}
372
				}
372
				}
373
		    });
373
		    });
374
		    
374
		    
375
		    
375
		    
376
			
376
			
377
			// Listener completion espece 
377
			// Listener completion espece 
378
			espece.addListener(new ComboBoxListenerAdapter() {  
378
			espece.addListener(new ComboBoxListenerAdapter() {  
379
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
379
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
380
	            	 espece.setValue(record.getAsString("nom"));
380
	            	 espece.setValue(record.getAsString("nom"));
381
	            	 numeroNom=record.getAsString("numeroNom");
381
	            	 numeroNom=record.getAsString("numeroNom");
382
	                 selectionEspece=true;
382
	                 selectionEspece=true;
383
	                 observationMediateur.obtenirImageInformationExternes(numeroNom);
383
	                 observationMediateur.obtenirImageInformationExternes(numeroNom);
384
	             }  
384
	             }  
385
	         });  
385
	         });  
386
	         
386
	         
387
 
387
 
388
			ListenerConfig listenerConfigEspece=new ListenerConfig();
388
			ListenerConfig listenerConfigEspece=new ListenerConfig();
389
			listenerConfigEspece.setDelay(10);
389
			listenerConfigEspece.setDelay(10);
390
			listenerConfigEspece.setStopPropagation(false);
390
			listenerConfigEspece.setStopPropagation(false);
391
			listenerConfigEspece.setStopEvent(false);			
391
			listenerConfigEspece.setStopEvent(false);			
392
 
392
 
393
		
393
		
394
			espece.addKeyPressListener(new EventCallback()	{
394
			espece.addKeyPressListener(new EventCallback()	{
395
		    	
395
		    	
396
		    	    public void execute(EventObject e) {
396
		    	    public void execute(EventObject e) {
397
		    	    	
397
		    	    	
398
		    	    		  
398
		    	    		  
399
		    	    		  switch(e.getKey()) {
399
		    	    		  switch(e.getKey()) {
400
		    	    	      	    		  
400
		    	    	      	    		  
401
		    	    		  
401
		    	    		  
402
		    	    		  case KEY_ALT:
402
		    	    		  case KEY_ALT:
403
		    	    	      case KEY_CTRL:
403
		    	    	      case KEY_CTRL:
404
		    	    	      case KEY_DOWN:
404
		    	    	      case KEY_DOWN:
405
		    	    	      case KEY_END:
405
		    	    	      case KEY_END:
406
		    	    	      case KEY_ESCAPE:
406
		    	    	      case KEY_ESCAPE:
407
		    	    	      case KEY_HOME:
407
		    	    	      case KEY_HOME:
408
		    	    	      case KEY_LEFT:
408
		    	    	      case KEY_LEFT:
409
		    	    	      case KEY_PAGEDOWN:
409
		    	    	      case KEY_PAGEDOWN:
410
		    	    	      case KEY_PAGEUP:
410
		    	    	      case KEY_PAGEUP:
411
		    	    	      case KEY_RIGHT:
411
		    	    	      case KEY_RIGHT:
412
		    	    	      case KEY_SHIFT:
412
		    	    	      case KEY_SHIFT:
413
		    	    	      case KEY_TAB:
413
		    	    	      case KEY_TAB:
414
		    	    	      case KEY_UP:
414
		    	    	      case KEY_UP:
415
		    	    	    	
415
		    	    	    	
416
		    	    	        break;
416
		    	    	        break;
417
		    	    	      
417
		    	    	      
418
		    	    	      case KEY_ENTER:
418
		    	    	      case KEY_ENTER:
419
		    	    	    	  
419
		    	    	    	  
420
			    	    	    	if(selectionEspece) {
420
			    	    	    	if(selectionEspece) {
421
			    	    	    		 selectionEspece=false;
421
			    	    	    		 selectionEspece=false;
422
			    	    	    	}
422
			    	    	    	}
423
			    	    	    	else {
423
			    	    	    	else {
424
			    	    	    		validerSaisie(Champs.ESPECE); 	    	    		 
424
			    	    	    		validerSaisie(Champs.ESPECE); 	    	    		 
425
			    	    	    	}
425
			    	    	    	}
426
		    	    	    	
426
		    	    	    	
427
		    	    	    	  break;
427
		    	    	    	  break;
428
		    	    	       
428
		    	    	       
429
		    	    	      default:
429
		    	    	      default:
430
		    	    	    	  
430
		    	    	    	  
431
		    	    	    	  numeroNom="";
431
		    	    	    	  numeroNom="";
432
		    	    	    	  obtenirListeReferentielNom();
432
		    	    	    	  obtenirListeReferentielNom();
433
		    	    	    	  	    	    	        
433
		    	    	    	  	    	    	        
434
		    	    	        break;
434
		    	    	        break;
435
		    	    	    }
435
		    	    	    }
436
 
436
 
437
		    	    	 
437
		    	    	 
438
		    	    	
438
		    	    	
439
		     		}
439
		     		}
440
		    	 
440
		    	 
441
		    		},    listenerConfigEspece
441
		    		},    listenerConfigEspece
442
		    	
442
		    	
443
			);
443
			);
444
		    
444
		    
445
			lieudit.addKeyPressListener(new EventCallback() {
445
			lieudit.addKeyPressListener(new EventCallback() {
446
 
446
 
447
				public void execute(EventObject e) {
447
				public void execute(EventObject e) {
448
					// TODO Auto-generated method stub
448
					// TODO Auto-generated method stub
449
					switch(e.getKey()) {
449
					switch(e.getKey()) {
450
	  	    	      
450
	  	    	      
451
	  	    	      case KEY_ENTER:	  	    	    	  
451
	  	    	      case KEY_ENTER:	  	    	    	  
452
	  	    	    		validerSaisie(Champs.LIEUDIT); 	    	    		 
452
	  	    	    		validerSaisie(Champs.LIEUDIT); 	    	    		 
453
	  	    	    	  break;
453
	  	    	    	  break;
454
	  	    	       
454
	  	    	       
455
	  	    	      default:
455
	  	    	      default:
456
					}
456
					}
457
				}
457
				}
458
		    });
458
		    });
459
			
459
			
460
			milieu.addKeyPressListener(new EventCallback() {
460
			milieu.addKeyPressListener(new EventCallback() {
461
 
461
 
462
				public void execute(EventObject e) {
462
				public void execute(EventObject e) {
463
					// TODO Auto-generated method stub
463
					// TODO Auto-generated method stub
464
					switch(e.getKey()) {
464
					switch(e.getKey()) {
465
	  	    	      
465
	  	    	      
466
	  	    	      case KEY_ENTER:	  	    	    	  
466
	  	    	      case KEY_ENTER:	  	    	    	  
467
	  	    	    		validerSaisie(Champs.MILIEU); 	    	    		 
467
	  	    	    		validerSaisie(Champs.MILIEU); 	    	    		 
468
	  	    	    	  break;
468
	  	    	    	  break;
469
	  	    	       
469
	  	    	       
470
	  	    	      default:
470
	  	    	      default:
471
					}
471
					}
472
				}
472
				}
473
		    });
473
		    });
474
			
474
			
475
			/*comment.addKeyPressListener(new EventCallback() {
475
			/*comment.addKeyPressListener(new EventCallback() {
476
 
476
 
477
				public void execute(EventObject e) {
477
				public void execute(EventObject e) {
478
					// TODO Auto-generated method stub
478
					// TODO Auto-generated method stub
479
					switch(e.getKey()) {
479
					switch(e.getKey()) {
480
	  	    	      
480
	  	    	      
481
	  	    	      case KEY_ENTER:	  	    	    	  
481
	  	    	      case KEY_ENTER:	  	    	    	  
482
	  	    	    		validerSaisie(Champs.COMMENT); 	    	    		 
482
	  	    	    		validerSaisie(Champs.COMMENT); 	    	    		 
483
	  	    	    	  break;
483
	  	    	    	  break;
484
	  	    	       
484
	  	    	       
485
	  	    	      default:
485
	  	    	      default:
486
					}
486
					}
487
				}
487
				}
488
		    });*/
488
		    });*/
489
 
489
 
490
		  
490
		  
491
 
491
 
492
		boutonOK.addListener(new ButtonListenerAdapter() {
492
		boutonOK.addListener(new ButtonListenerAdapter() {
493
			
493
			
494
			public void onClick(Button button, EventObject e) {
494
			public void onClick(Button button, EventObject e) {
495
		
495
		
496
				if(modification) {
496
				if(modification) {
497
					modifierObservation() ;
497
					modifierObservation() ;
498
				}
498
				}
499
				else {
499
				else {
500
					ajouterObservation();
500
					ajouterObservation();
501
				}
501
				}
502
				
502
				
503
				
503
				
504
			}
504
			}
505
			
505
			
506
		});
506
		});
507
		
507
		
508
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
508
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
509
			
509
			
510
			public void onClick(Button button, EventObject e) {
510
			public void onClick(Button button, EventObject e) {
511
				
511
				
512
				if(modification)
512
				if(modification)
513
				{
513
				{
514
					supprimerObservation() ;
514
					supprimerObservation() ;
515
				}
515
				}
516
				else
516
				else
517
				{
517
				{
518
					raz();
518
					raz();
519
				}
519
				}
520
				
520
				
521
				
521
				
522
			}
522
			}
523
			
523
			
524
		});
524
		});
525
		
525
		
526
		this.addListener(new ContainerListenerAdapter() {
526
		this.addListener(new ContainerListenerAdapter() {
527
			public void onAfterLayout(Container self) {
527
			public void onAfterLayout(Container self) {
528
				
528
				
529
				ajusterTailleChamps();
529
				ajusterTailleChamps();
530
				commune.focus();
530
				commune.focus();
531
			}
531
			}
532
		});	
532
		});	
533
		
533
		
534
		this.addListener(new BoxComponentListenerAdapter() {
534
		this.addListener(new BoxComponentListenerAdapter() {
535
				public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight)  {
535
				public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight)  {
536
				
536
				
537
				ajusterTailleChamps();
537
				ajusterTailleChamps();
538
			}
538
			}
539
		});
539
		});
540
	}
540
	}
541
	
541
	
542
	/**
542
	/**
543
	 * Validation de la saisie 
543
	 * Validation de la saisie 
544
	 */
544
	 */
545
	
545
	
546
	private void validerSaisie(Champs champs) {
546
	private void validerSaisie(Champs champs) {
547
		
547
		
548
		if(modification) {
548
		if(modification) {
549
			modifierObservation() ;
549
			modifierObservation() ;
550
		
550
		
551
		}
551
		}
552
		else {
552
		else {
553
			ajouterObservation();
553
			ajouterObservation();
554
			raz(champs);
554
			raz(champs);
555
		}
555
		}
556
	}
556
	}
557
	
557
	
558
	/**
558
	/**
559
	 * Desactive visuellement ce panneau
559
	 * Desactive visuellement ce panneau
560
	 */
560
	 */
561
	public void desactiverPanneau()
561
	public void desactiverPanneau()
562
	{
562
	{
563
		this.setDisabled(true) ;
563
		this.setDisabled(true) ;
564
	}
564
	}
565
	
565
	
566
	/**
566
	/**
567
	 * Active visuellement ce panneau
567
	 * Active visuellement ce panneau
568
	 */
568
	 */
569
	public void activerPanneau()
569
	public void activerPanneau()
570
	{
570
	{
571
		this.setDisabled(false) ;
571
		this.setDisabled(false) ;
572
	}
572
	}
573
 
573
 
574
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
574
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
575
		
575
		
576
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
576
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
577
			if(nouvelleDonnees instanceof ListeReferentielCommune)
577
			if(nouvelleDonnees instanceof ListeReferentielCommune)
578
			{
578
			{
579
				
579
				
580
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
580
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
581
					Object[][] communeData = new Object[data.size()][2];
581
					Object[][] communeData = new Object[data.size()][2];
582
					int i = 0 ;
582
					int i = 0 ;
583
				
583
				
584
					// on la parse et on récupère les informations quiç nous interessent
584
					// on la parse et on récupère les informations quiç nous interessent
585
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
585
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
586
					{
586
					{
587
						
587
						
588
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
588
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
589
						
589
						
590
						communeData[i][0]= ref.getCommune();
590
						communeData[i][0]= ref.getCommune();
591
						communeData[i][1]= ref.getDepartement();
591
						communeData[i][1]= ref.getDepartement();
592
						
592
						
593
																	
593
																	
594
						i++ ;
594
						i++ ;
595
					}
595
					}
596
					
596
					
597
					   //	  creation du store
597
					   //	  creation du store
598
					FieldDef defCommune = new StringFieldDef("commune");
598
					FieldDef defCommune = new StringFieldDef("commune");
599
					FieldDef defDepartement = new StringFieldDef("departement");
599
					FieldDef defDepartement = new StringFieldDef("departement");
600
					
600
					
601
					
601
					
602
					FieldDef[] defTab = { defCommune, defDepartement};
602
					FieldDef[] defTab = { defCommune, defDepartement};
603
					
603
					
604
					RecordDef rd = new RecordDef(defTab);
604
					RecordDef rd = new RecordDef(defTab);
605
					
605
					
606
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
606
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
607
					final ArrayReader reader = new ArrayReader(rd);		
607
					final ArrayReader reader = new ArrayReader(rd);		
608
					
608
					
609
					Store store=new Store(dataProxy,reader);
609
					Store store=new Store(dataProxy,reader);
610
					store.load() ;
610
					store.load() ;
611
		
611
		
612
					commune.setStore(store);
612
					commune.setStore(store);
613
			}
613
			}
614
			
614
			
615
			//			 si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
615
			//			 si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
616
			
616
			
617
			if(nouvelleDonnees instanceof ListeReferentielNom)
617
			if(nouvelleDonnees instanceof ListeReferentielNom)
618
			{
618
			{
619
				
619
				
620
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
620
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
621
					Object[][] nomData = new Object[data.size()][2];
621
					Object[][] nomData = new Object[data.size()][2];
622
					int i = 0 ;
622
					int i = 0 ;
623
				
623
				
624
					// on la parse et on récupère les informations quiç nous interessent
624
					// on la parse et on récupère les informations quiç nous interessent
625
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
625
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
626
					{
626
					{
627
						
627
						
628
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
628
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
629
						
629
						
630
						nomData[i][0]= ref.getNom();
630
						nomData[i][0]= ref.getNom();
631
						nomData[i][1]= ref.getNumeroNom();
631
						nomData[i][1]= ref.getNumeroNom();
632
						
632
						
633
																	
633
																	
634
						i++ ;
634
						i++ ;
635
					}
635
					}
636
					
636
					
637
					   //	  creation du store
637
					   //	  creation du store
638
					FieldDef defNom = new StringFieldDef("nom");
638
					FieldDef defNom = new StringFieldDef("nom");
639
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
639
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
640
					
640
					
641
					
641
					
642
					FieldDef[] defTab = { defNom, defNumeroNom};
642
					FieldDef[] defTab = { defNom, defNumeroNom};
643
					
643
					
644
					RecordDef rd = new RecordDef(defTab);
644
					RecordDef rd = new RecordDef(defTab);
645
					
645
					
646
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
646
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
647
					final ArrayReader reader = new ArrayReader(rd);		
647
					final ArrayReader reader = new ArrayReader(rd);		
648
					
648
					
649
					Store store=new Store(dataProxy,reader);
649
					Store store=new Store(dataProxy,reader);
650
					store.load() ;
650
					store.load() ;
651
		
651
		
652
					espece.setStore(store);
652
					espece.setStore(store);
653
				
653
				
654
					
654
					
655
							
655
							
656
			}
656
			}
657
			
657
			
658
			// On recoit une observation dont on veut afficher le detail 
658
			// On recoit une observation dont on veut afficher le detail 
659
			
659
			
660
			if(nouvelleDonnees instanceof Observation)
660
			if(nouvelleDonnees instanceof Observation)
661
			{
661
			{
662
				Observation obs = (Observation)nouvelleDonnees ;
662
				Observation obs = (Observation)nouvelleDonnees ;
663
				afficherDetailsObservation(obs) ;
663
				afficherDetailsObservation(obs) ;
664
			}
664
			}
665
			
665
			
666
			// Sur Mise à jour ou suppression d'une suppression ?
666
			// Sur Mise à jour ou suppression d'une suppression ?
667
			
667
			
668
			if(nouvelleDonnees instanceof String)
668
			if(nouvelleDonnees instanceof String)
669
			{
669
			{
670
				String str = (String)nouvelleDonnees ;
670
				String str = (String)nouvelleDonnees ;
671
				observationMediateur.obtenirNombreObservation() ;
671
				observationMediateur.obtenirNombreObservation() ;
672
			}
672
			}
673
			
673
			
674
			if(nouvelleDonnees instanceof String[]) {
674
			if(nouvelleDonnees instanceof String[]) {
675
				String[] anumNom = (String[])nouvelleDonnees ;
675
				String[] anumNom = (String[])nouvelleDonnees ;
676
				numeroNom = anumNom[1];
676
				numeroNom = anumNom[1];
677
				espece.setValue(anumNom[0]);
677
				espece.setValue(anumNom[0]);
678
				setModification("false");
678
				setModification("false");
679
			}
679
			}
680
 
680
 
681
	}
681
	}
682
	
682
	
683
 
683
 
684
	public void obtenirListeReferentielCommune() {
684
	public void obtenirListeReferentielCommune() {
685
		
685
		
686
	 String com=commune.getText().replaceAll(" ","/");
686
	 String com=commune.getText().replaceAll(" ","/");
687
	 com=com.replaceAll("%","");
687
	 com=com.replaceAll("%","");
688
		  
688
		  
689
	 observationMediateur.obtenirListeReferentielCommune(this,com);
689
	 observationMediateur.obtenirListeReferentielCommune(this,com);
690
	 
690
	 
691
	}
691
	}
692
	
692
	
693
 
693
 
694
	public void obtenirListeReferentielNom() {
694
	public void obtenirListeReferentielNom() {
695
	 
695
	 
696
	  String esp=espece.getText().replaceAll(" ","/");
696
	  String esp=espece.getText().replaceAll(" ","/");
697
	  esp=esp.replaceAll("%","");
697
	  esp=esp.replaceAll("%","");
698
		
698
		
699
	  observationMediateur.obtenirListeReferentielNom(this,esp);
699
	  observationMediateur.obtenirListeReferentielNom(this,esp);
700
	 
700
	 
701
	}
701
	}
702
   
702
   
703
 
703
 
704
	public void ajouterObservation() {
704
	public void ajouterObservation() {
705
		
705
		
706
		if(departement.equals("000null") || departement.equals("")) {
706
		if(departement.equals("000null") || departement.equals("")) {
707
			String[] depCom = commune.getText().split(" ");
707
			String[] depCom = commune.getText().split(" ");
708
			if(depCom.length > 1) {
708
			if(depCom.length > 1) {
709
				String dep = depCom[1].replace('(', ' ');
709
				String dep = depCom[1].replace('(', ' ');
710
				dep =dep.replace(')', ' ');
710
				dep =dep.replace(')', ' ');
711
				dep = dep.trim();
711
				dep = dep.trim();
712
				dep = dep.replace('\\',' ');
712
				dep = dep.replace('\\',' ');
713
				dep = dep.trim();
713
				dep = dep.trim();
714
				
714
				
715
				try
715
				try
716
				{
716
				{
717
					int nDep = Integer.parseInt(dep);
717
					int nDep = Integer.parseInt(dep);
718
					if(nDep > 0 && nDep < 110) {
718
					if(nDep > 0 && nDep < 110) {
719
						departement = dep ;
719
						departement = dep ;
720
					}
720
					}
721
				}
721
				}
722
				catch(NumberFormatException e)
722
				catch(NumberFormatException e)
723
				{
723
				{
724
					departement = "" ;
724
					departement = "" ;
725
				}
725
				}
726
			}
726
			}
727
		}
727
		}
728
 
728
 
729
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
729
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
730
		observationMediateur.ajouterObservation(obs);
730
		observationMediateur.ajouterObservation(obs);
731
	}
731
	}
732
	
732
	
733
	private void modifierObservation() {
733
	private void modifierObservation() {
734
		
734
		
735
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());
735
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());
736
		obs.setNumeroOrdre(numeroOrdre);
736
		obs.setNumeroOrdre(numeroOrdre);
737
		observationMediateur.modifierObservation(obs);
737
		observationMediateur.modifierObservation(obs);
738
		
738
		
739
	}
739
	}
740
	
740
	
741
	private void supprimerObservation() {
741
	private void supprimerObservation() {
742
		
742
		
743
			observationMediateur.supprimerObservation(this, numeroOrdre);
743
			observationMediateur.supprimerObservation(this, numeroOrdre);
744
	}
744
	}
745
 
745
 
746
	
746
	
747
	public void afficherDetailsObservation(Observation obs)
747
	public void afficherDetailsObservation(Observation obs)
748
	{
748
	{
749
		raz() ;
749
		raz() ;
750
		char g ;
750
		char g ;
751
		
751
		
752
		String idLoc =obs.getIdentifiantLocalite().replaceAll(" ","/");
752
		String idLoc =obs.getIdentifiantLocalite().replaceAll(" ","/");
753
		idLoc = idLoc.replaceAll("%","");
753
		idLoc = idLoc.replaceAll("%","");
754
		idLoc = idLoc.replaceAll("\"","");
754
		idLoc = idLoc.replaceAll("\"","");
755
		idLoc = idLoc.replace('\\',' ');
755
		idLoc = idLoc.replace('\\',' ');
756
		idLoc = idLoc.trim();
756
		idLoc = idLoc.trim();
757
		
757
		
758
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
758
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
759
			String[] dateEtHeure = obs.getDate().split(" ", 2);
759
			String[] dateEtHeure = obs.getDate().split(" ", 2);
760
			if(verifierFormatDate(dateEtHeure[0])) {
760
			if(verifierFormatDate(dateEtHeure[0])) {
761
				date.setValue(dateEtHeure[0]) ;
761
				date.setValue(dateEtHeure[0]) ;
762
			}
762
			}
763
			else
763
			else
764
			{
764
			{
765
				date.setRawValue(""); 
765
				date.setRawValue(""); 
766
			}
766
			}
767
		}
767
		}
768
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
768
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
769
			lieudit.setValue(obs.getLieudit()) ;
769
			lieudit.setValue(obs.getLieudit()) ;
770
		}
770
		}
771
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
771
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
772
			station.setValue(obs.getStation()) ;
772
			station.setValue(obs.getStation()) ;
773
		}
773
		}
774
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
774
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
775
			milieu.setValue(obs.getMilieu()) ;
775
			milieu.setValue(obs.getMilieu()) ;
776
		}
776
		}
777
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
777
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
778
			comment.setValue(obs.getCommentaire()) ;
778
			comment.setValue(obs.getCommentaire()) ;
779
		}
779
		}
780
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
780
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
781
			if(!idLoc.equals("000null")) {
781
			if(!idLoc.equals("000null")) {
782
				commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
782
				commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
783
			}
783
			}
784
			else
784
			else
785
			{
785
			{
786
				commune.setValue(obs.getLocalite());
786
				commune.setValue(obs.getLocalite());
787
			}
787
			}
788
		}
788
		}
789
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
789
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
790
			departement = idLoc;
790
			departement = idLoc;
791
		}
791
		}
792
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
792
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
793
			espece.setValue(obs.getNomSaisi()) ;
793
			espece.setValue(obs.getNomSaisi()) ;
794
		}
794
		}
795
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
795
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
796
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
796
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
797
		}
797
		}
798
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
798
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
799
			numeroOrdre = obs.getNumeroOrdre() ;
799
			numeroOrdre = obs.getNumeroOrdre() ;
800
		}
800
		}
801
		
801
		
802
	}
802
	}
803
	
803
	
804
	
804
	
805
	public void raz()
805
	public void raz()
806
	{
806
	{
807
		raz(Champs.TOUT);
807
		raz(Champs.TOUT);
808
		
808
		
809
	}
809
	}
810
	public void raz(Champs champs)
810
	public void raz(Champs champs)
811
	{
811
	{
812
		switch (champs) {
812
		switch (champs) {
813
		
813
		
814
		
814
		
815
			case DATE:
815
			case DATE:
816
				date.reset() ;
816
				date.reset() ;
817
				break;
817
				break;
818
		
818
		
819
			case LIEUDIT:
819
			case LIEUDIT:
820
				lieudit.reset() ;
820
				lieudit.reset() ;
821
				break;
821
				break;
822
		
822
		
823
			case STATION:
823
			case STATION:
824
				station.reset() ;
824
				station.reset() ;
825
				break;
825
				break;
826
		
826
		
827
			case MILIEU:
827
			case MILIEU:
828
				milieu.reset() ;
828
				milieu.reset() ;
829
				break;
829
				break;
830
		
830
		
831
			case COMMENT:
831
			case COMMENT:
832
				comment.reset() ;
832
				comment.reset() ;
833
				break;
833
				break;
834
 
834
 
835
 
835
 
836
			case COMMUNE:
836
			case COMMUNE:
837
				milieu.reset() ;
837
				commune.reset() ;
838
				departement ="";
838
				departement ="";
839
				break;
839
				break;
840
				
840
				
841
			case ESPECE:
841
			case ESPECE:
842
				espece.reset();
842
				espece.reset();
843
				numeroNom = "" ;
843
				numeroNom = "" ;
844
				numeroOrdre = "";
844
				numeroOrdre = "";
845
				break;
845
				break;
846
				
846
				
847
			case TOUT:
847
			case TOUT:
848
				commune.reset();
848
				commune.reset();
849
				date.reset() ;
849
				date.reset() ;
850
				lieudit.reset() ;
850
				lieudit.reset() ;
851
				station.reset() ;
851
				station.reset() ;
852
				milieu.reset() ;
852
				milieu.reset() ;
853
				comment.reset() ;
853
				comment.reset() ;
854
				milieu.reset() ;
854
				milieu.reset() ;
855
				departement ="";
855
				departement ="";
856
				espece.reset();
856
				espece.reset();
857
				numeroNom = "" ;
857
				numeroNom = "" ;
858
				numeroOrdre = "";
858
				numeroOrdre = "";
859
				break;
859
				break;
860
 
860
 
861
		}
861
		}
862
		
862
		
863
	}
863
	}
864
	
864
	
865
	private void setModification(String mode)
865
	private void setModification(String mode)
866
	{
866
	{
867
		if(mode.equals("true")) {
867
		if(mode.equals("true")) {
868
 
868
 
869
			boutonOK.setText("Modifier") ;
869
			boutonOK.setText("Modifier") ;
870
			setTitle("Modification") ;
870
			setTitle("Modification") ;
871
			boutonAnnuler.setText("Supprimer") ;
871
			boutonAnnuler.setText("Supprimer") ;
872
			modification = true ;
872
			modification = true ;
873
			selecteurMode.removeClass("x-selec-crea") ;
873
			selecteurMode.removeClass("x-selec-crea") ;
874
			selecteurMode.setCls("x-selec-modif") ;
874
			selecteurMode.setCls("x-selec-modif") ;
875
			
875
			
876
		}
876
		}
877
		else
877
		else
878
		{
878
		{
879
 
879
 
880
			boutonOK.setText("Ajouter") ;
880
			boutonOK.setText("Ajouter") ;
881
			setTitle("Saisir") ;
881
			setTitle("Saisir") ;
882
			boutonAnnuler.setText("Réinitialiser") ;
882
			boutonAnnuler.setText("Réinitialiser") ;
883
			modification = false ;
883
			modification = false ;
884
			selecteurMode.removeClass("x-selec-modif") ;
884
			selecteurMode.removeClass("x-selec-modif") ;
885
			selecteurMode.setCls("x-selec-crea") ;
885
			selecteurMode.setCls("x-selec-crea") ;
886
			
886
			
887
		}	
887
		}	
888
	}
888
	}
889
	
889
	
890
	/**
890
	/**
891
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
891
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
892
	 * @return
892
	 * @return
893
	 */
893
	 */
894
	public boolean getModification()
894
	public boolean getModification()
895
	{
895
	{
896
		return modification ;
896
		return modification ;
897
	}
897
	}
898
	
898
	
899
	public boolean verifierFormatDate(String date) {
899
	public boolean verifierFormatDate(String date) {
900
		
900
		
901
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
901
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
902
		if(date.matches(regex) && !date.equals("0000-00-00")) {
902
		if(date.matches(regex) && !date.equals("0000-00-00")) {
903
			return true ;
903
			return true ;
904
		}
904
		}
905
		else {
905
		else {
906
			return false;
906
			return false;
907
		}
907
		}
908
	}
908
	}
909
	
909
	
910
	private void ajusterTailleChamps() {
910
	private void ajusterTailleChamps() {
911
		
911
		
912
		int tailleChamps = (this.getInnerWidth()/100)*40;
912
		int tailleChamps = (this.getInnerWidth()/100)*40;
913
		
913
		
914
		this.tailleChamps = tailleChamps ;
914
		this.tailleChamps = tailleChamps ;
915
		
915
		
916
		commune.setWidth(tailleChamps);
916
		commune.setWidth(tailleChamps);
917
		station.setWidth(tailleChamps);
917
		station.setWidth(tailleChamps);
918
		espece.setWidth(tailleChamps);
918
		espece.setWidth(tailleChamps);
919
		lieudit.setWidth(tailleChamps);
919
		lieudit.setWidth(tailleChamps);
920
		milieu.setWidth(tailleChamps);
920
		milieu.setWidth(tailleChamps);
921
		comment.setWidth(tailleChamps);
921
		comment.setWidth(tailleChamps);
922
 
922
 
923
	}
923
	}
924
 
924
 
925
}
925
}