Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 83 Rev 94
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
 
15
 
16
import com.google.gwt.user.client.Window;
16
import com.google.gwt.user.client.Window;
17
import com.gwtext.client.core.EventCallback;
17
import com.gwtext.client.core.EventCallback;
18
import com.gwtext.client.core.EventObject;
18
import com.gwtext.client.core.EventObject;
19
import com.gwtext.client.core.ListenerConfig;
19
import com.gwtext.client.core.ListenerConfig;
20
import com.gwtext.client.core.Position;
20
import com.gwtext.client.core.Position;
21
import com.gwtext.client.core.Template;
21
import com.gwtext.client.core.Template;
22
import com.gwtext.client.data.ArrayReader;
22
import com.gwtext.client.data.ArrayReader;
23
import com.gwtext.client.data.FieldDef;
23
import com.gwtext.client.data.FieldDef;
24
import com.gwtext.client.data.MemoryProxy;
24
import com.gwtext.client.data.MemoryProxy;
25
import com.gwtext.client.data.RecordDef;
25
import com.gwtext.client.data.RecordDef;
26
import com.gwtext.client.data.SimpleStore;
26
import com.gwtext.client.data.SimpleStore;
27
import com.gwtext.client.data.Store;
27
import com.gwtext.client.data.Store;
28
import com.gwtext.client.data.StringFieldDef;
28
import com.gwtext.client.data.StringFieldDef;
29
import com.gwtext.client.widgets.Button;
29
import com.gwtext.client.widgets.Button;
30
import com.gwtext.client.widgets.Panel;
30
import com.gwtext.client.widgets.Panel;
31
import com.gwtext.client.widgets.Toolbar;
31
import com.gwtext.client.widgets.Toolbar;
32
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
32
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
33
import com.gwtext.client.widgets.form.ComboBox;
33
import com.gwtext.client.widgets.form.ComboBox;
34
import com.gwtext.client.widgets.form.DateField;
34
import com.gwtext.client.widgets.form.DateField;
35
import com.gwtext.client.widgets.form.FormPanel;
35
import com.gwtext.client.widgets.form.FormPanel;
36
import com.gwtext.client.widgets.form.Hidden;
36
import com.gwtext.client.widgets.form.Hidden;
37
import com.gwtext.client.widgets.form.TextField;
37
import com.gwtext.client.widgets.form.TextField;
38
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
38
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
39
import com.gwtext.client.widgets.layout.ColumnLayout;
39
import com.gwtext.client.widgets.layout.ColumnLayout;
40
import com.gwtext.client.widgets.layout.ColumnLayoutData;
40
import com.gwtext.client.widgets.layout.ColumnLayoutData;
41
import com.gwtext.client.widgets.layout.FormLayout;
41
import com.gwtext.client.widgets.layout.FormLayout;
42
import com.gwtext.client.data.Record;
42
import com.gwtext.client.data.Record;
43
 
43
 
44
/**
44
/**
45
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
45
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
46
 * @author aurelien
46
 * @author aurelien
47
 *
47
 *
48
 */
48
 */
49
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
49
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
50
 
50
 
51
 
51
 
52
	/**
52
	/**
53
	 * Le médiateur associé à la vue
53
	 * Le médiateur associé à la vue
54
	 */
54
	 */
55
	private ObservationMediateur	observationMediateur		= null;
55
	private ObservationMediateur	observationMediateur		= null;
56
	
56
	
57
	
57
	
58
 
58
 
59
	private DateField date = null;
59
	private DateField date = null;
60
	private TextField lieudit = null;
60
	private TextField lieudit = null;
61
	private TextField station = null;
61
	private TextField station = null;
62
	private TextField milieu = null;
62
	private TextField milieu = null;
63
	private TextField comment = null;
63
	private TextField comment = null;
64
	private ComboBox  commune = null;
64
	private ComboBox  commune = null;
65
	private String departement = null;
65
	private String departement = null;
66
	private ComboBox  espece = null;
66
	private ComboBox  espece = null;
67
	private String numeroNom = null;
67
	private String numeroNom = null;
68
	private String numeroOrdre = null;
68
	private String numeroOrdre = null;
69
 
69
 
70
 
70
 
71
	private Button boutonOK = new Button("Créer");
71
	private Button boutonOK = new Button("Créer");
72
	private Button boutonAnnuler = new Button("Réinitialiser");
72
	private Button boutonAnnuler = new Button("Réinitialiser");
73
 
73
 
74
	private boolean selectionCommune=false;
74
	private boolean selectionCommune=false;
75
	private boolean selectionEspece=false;
75
	private boolean selectionEspece=false;
76
	
76
	
77
	private boolean modification = false ;
77
	private boolean modification = false ;
78
	private Toolbar bt = null ;
78
	private Toolbar bt = null ;
79
	
79
	
80
	private final int KEY_ALT = 18;
80
	private final int KEY_ALT = 18;
81
	private final int KEY_BACKSPACE = 8;
81
	private final int KEY_BACKSPACE = 8;
82
	private final int KEY_CTRL = 17;
82
	private final int KEY_CTRL = 17;
83
	private final int KEY_DELETE = 46;
83
	private final int KEY_DELETE = 46;
84
	private final int KEY_DOWN = 40;
84
	private final int KEY_DOWN = 40;
85
	private final int KEY_END = 35;
85
	private final int KEY_END = 35;
86
	private final int KEY_ENTER = 13;
86
	private final int KEY_ENTER = 13;
87
	private final int KEY_ESCAPE = 27;
87
	private final int KEY_ESCAPE = 27;
88
	private final int KEY_HOME = 36;
88
	private final int KEY_HOME = 36;
89
	private final int KEY_LEFT = 37;
89
	private final int KEY_LEFT = 37;
90
	private final int KEY_PAGEDOWN = 34;
90
	private final int KEY_PAGEDOWN = 34;
91
	private final int KEY_PAGEUP = 33;
91
	private final int KEY_PAGEUP = 33;
92
	private final int KEY_RIGHT = 39;
92
	private final int KEY_RIGHT = 39;
93
	private final int KEY_SHIFT = 16;
93
	private final int KEY_SHIFT = 16;
94
	private final int KEY_TAB = 9;
94
	private final int KEY_TAB = 9;
95
	private final int KEY_UP = 38;
95
	private final int KEY_UP = 38;
96
	
96
	
97
	/**
97
	/**
98
	 * Combobox permettant de selectionner le mode
98
	 * Combobox permettant de selectionner le mode
99
	 * modification ou bien création
99
	 * modification ou bien création
100
	 */
100
	 */
101
	private ComboBox selecteurMode = new ComboBox();
101
	private ComboBox selecteurMode = new ComboBox();
102
	
102
	
103
	Store storeMode = null ;
103
	Store storeMode = null ;
104
 
104
 
105
	/**
105
	/**
106
	 * Booleen d'instanciation
106
	 * Booleen d'instanciation
107
	 */
107
	 */
108
	boolean estInstancie = false ;
108
	boolean estInstancie = false ;
109
	
109
	
110
	/**
110
	/**
111
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
111
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
112
	 */
112
	 */
113
	@SuppressWarnings("unused")
113
	@SuppressWarnings("unused")
114
	private FormulaireSaisieObservationVue()
114
	private FormulaireSaisieObservationVue()
115
	{
115
	{
116
		super() ;
116
		super() ;
117
	}
117
	}
118
	
118
	
119
	/**
119
	/**
120
	 * Constructeur avec argument
120
	 * Constructeur avec argument
121
	 * @param im
121
	 * @param im
122
	 */
122
	 */
123
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
123
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
124
	{
124
	{
125
 
125
 
126
		
126
		
127
		// on associe le médiateur
127
		// on associe le médiateur
128
		observationMediateur = obs ;
128
		observationMediateur = obs ;
129
		
129
		
130
		
130
		
131
		setHeader(true);
131
		setHeader(true);
132
		
132
		
133
		FormPanel panneauFormulaire = new FormPanel(Position.RIGHT);
133
		FormPanel panneauFormulaire = new FormPanel(Position.RIGHT);
134
		panneauFormulaire.setBorder(false);
134
		panneauFormulaire.setBorder(false);
135
		
135
		
136
		// Panneau intermediaire qui contient deux colonnes de formulaire
136
		// Panneau intermediaire qui contient deux colonnes de formulaire
137
		
137
		
138
		Panel panneauIntermediaire = new Panel();  
138
		Panel panneauIntermediaire = new Panel();  
139
		panneauIntermediaire.setLayout(new ColumnLayout());  
139
		panneauIntermediaire.setLayout(new ColumnLayout());  
140
		panneauIntermediaire.setBorder(false);
140
		panneauIntermediaire.setBorder(false);
141
		   
141
		   
142
		//create first panel and add fields to it  
142
		//create first panel and add fields to it  
143
		Panel panneauPremierColonne = new Panel();  
143
		Panel panneauPremierColonne = new Panel();  
144
		panneauPremierColonne.setLayout(new FormLayout());  
144
		panneauPremierColonne.setLayout(new FormLayout());  
145
		panneauPremierColonne.setBorder(false);
145
		panneauPremierColonne.setBorder(false);
146
 
146
 
147
		//create second panel and add fields to it  
147
		//create second panel and add fields to it  
148
	    Panel panneauSecondeColonne = new Panel();  
148
	    Panel panneauSecondeColonne = new Panel();  
149
		panneauSecondeColonne.setLayout(new FormLayout());  
149
		panneauSecondeColonne.setLayout(new FormLayout());  
150
		panneauSecondeColonne.setBorder(false);
150
		panneauSecondeColonne.setBorder(false);
151
		
151
		
152
		this.setPaddings(5) ;
152
		this.setPaddings(5) ;
153
	
153
	
154
 
154
 
155
 
155
 
156
		commune=new ComboBox("Commune","commune",275 );  
156
		commune=new ComboBox("Commune","commune",275 );  
157
		
157
		
158
		
158
		
159
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
159
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
160
 
160
 
161
		
161
		
162
		commune.setTpl(resultTplCommune);
162
		commune.setTpl(resultTplCommune);
163
		commune.setMode(ComboBox.REMOTE);
163
		commune.setMode(ComboBox.REMOTE);
164
		// commune.setPageSize(10); // Ne fonctionne pas 
164
		// commune.setPageSize(10); // Ne fonctionne pas 
165
		commune.setItemSelector("div.search-item-commune");
165
		commune.setItemSelector("div.search-item-commune");
166
		commune.setTypeAhead(true);  
166
		commune.setTypeAhead(true);  
167
		commune.setLoadingText("Recherche...");  
167
		commune.setLoadingText("Recherche...");  
168
		  
168
		  
169
		commune.setHideTrigger(true);
169
		commune.setHideTrigger(true);
170
		
170
		
171
		
171
		
172
     
172
     
173
 
173
 
174
 
174
 
175
	    panneauPremierColonne.add(commune);  
175
	    panneauPremierColonne.add(commune);  
176
 
176
 
177
		
177
		
178
	    
178
	    
179
	    station = new TextField("Station", "station", 275);  
179
	    station = new TextField("Station", "station", 275);  
180
	    station.setAllowBlank(true);  
180
	    station.setAllowBlank(true);  
181
	    panneauPremierColonne.add(station);  
181
	    panneauPremierColonne.add(station);  
182
	    
182
	    
183
	    date = new DateField("Date", "date", 100);  
183
	    date = new DateField("Date", "date", 100);  
184
	    date.setAllowBlank(true);
184
	    date.setAllowBlank(true);
185
	    date.setFormat("d/m/Y") ;
185
	    date.setFormat("d/m/Y") ;
186
	    panneauPremierColonne.add(date);  
186
	    panneauPremierColonne.add(date);  
187
 
187
 
188
	 	
188
	 	
189
		espece=new ComboBox("Espèce","nom",275 );  
189
		espece=new ComboBox("Espèce","nom",275 );  
190
		
190
		
191
		
191
		
192
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";  
192
		final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";  
193
 
193
 
194
		
194
		
195
		espece.setTpl(resultTplEspece);
195
		espece.setTpl(resultTplEspece);
196
		espece.setMode(ComboBox.REMOTE);
196
		espece.setMode(ComboBox.REMOTE);
197
		// commune.setPageSize(10); // Ne fonctionne pas 
197
		// commune.setPageSize(10); // Ne fonctionne pas 
198
		espece.setItemSelector("div.search-item-espece");
198
		espece.setItemSelector("div.search-item-espece");
199
		espece.setTypeAhead(true);  
199
		espece.setTypeAhead(true);  
200
		espece.setLoadingText("Recherche...");  
200
		espece.setLoadingText("Recherche...");  
201
		  
201
		  
202
		espece.setHideTrigger(true);
202
		espece.setHideTrigger(true);
203
		
203
		
204
 
204
 
205
 
205
 
206
	    panneauPremierColonne.add(espece);  
206
	    panneauPremierColonne.add(espece);  
207
	    
207
	    
208
	    comment = new TextField("Notes", "comment", 275);  
208
	    comment = new TextField("Notes", "comment", 275);  
209
	    comment.setAllowBlank(true);  
209
	    comment.setAllowBlank(true);  
210
	    panneauPremierColonne.add(comment); 
210
	    panneauPremierColonne.add(comment); 
211
	    
211
	    
212
	    
212
	    
213
	    lieudit = new TextField("Lieu-dit", "lieudit", 275);  
213
	    lieudit = new TextField("Lieu-dit", "lieudit", 275);  
214
	    lieudit.setAllowBlank(true);  
214
	    lieudit.setAllowBlank(true);  
215
	    panneauSecondeColonne.add(lieudit);  
215
	    panneauSecondeColonne.add(lieudit);  
216
	       
216
	       
217
	
217
	
218
	    milieu = new TextField("Milieu", "milieu", 275);  
218
	    milieu = new TextField("Milieu", "milieu", 275);  
219
	    milieu.setAllowBlank(true);  
219
	    milieu.setAllowBlank(true);  
220
	    panneauSecondeColonne.add(milieu);  
220
	    panneauSecondeColonne.add(milieu);  
221
	   
221
	   
222
	 
222
	 
223
		
223
		
224
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
224
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
225
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
225
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
226
		
226
		
227
		panneauFormulaire.add(panneauIntermediaire);
227
		panneauFormulaire.add(panneauIntermediaire);
228
		
-
 
229
		/*final Template tp = new Template("<div class=\"x-combo-list-item\">"
-
 
230
				+ "{nom_mode}" + "<div class=\"x-clear\"></div></div>");
-
 
231
		tp.compile();*/
-
 
232
		
228
		
233
		Object[][] mode = {{"création",false} , {"modification", true} };
229
		Object[][] mode = {{"création",false} , {"modification", true} };
234
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
230
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
235
				mode);
231
				mode);
236
		storeMode.load();
232
		storeMode.load();
237
		selecteurMode.setStore(storeMode);
233
		selecteurMode.setStore(storeMode);
238
		selecteurMode.setDisplayField("nom_mode") ;
234
		selecteurMode.setDisplayField("nom_mode") ;
239
		selecteurMode.setLabel("mode ") ;
235
		selecteurMode.setLabel("mode ") ;
240
		selecteurMode.setForceSelection(true) ;
236
		selecteurMode.setForceSelection(true) ;
241
		selecteurMode.setValue("création") ;
237
		selecteurMode.setValue("création") ;
242
		selecteurMode.setEditable(false) ;
238
		selecteurMode.setEditable(false) ;
243
		
239
		
244
		bt = new Toolbar() ;
240
		bt = new Toolbar() ;
245
		bt.addSpacer() ;
241
		bt.addSpacer() ;
246
		bt.addText("Mode de saisie ") ;
242
		bt.addText("Mode de saisie ") ;
247
		bt.addField(selecteurMode) ;
243
		bt.addField(selecteurMode) ;
248
		
244
		
249
		
245
		
250
		
246
		
251
		
247
		
252
		panneauFormulaire.addButton(boutonOK);
248
		panneauFormulaire.addButton(boutonOK);
253
		    
249
		    
254
		panneauFormulaire.addButton(boutonAnnuler);
250
		panneauFormulaire.addButton(boutonAnnuler);
255
		
251
		
256
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
252
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
257
 
253
 
258
			public void onSelect(ComboBox comboBox, Record record, int index) {
254
			public void onSelect(ComboBox comboBox, Record record, int index) {
259
				
255
				
260
				// et on met la valeur à jour dans la combobox
256
				// et on met la valeur à jour dans la combobox
261
				comboBox.setValue(record.getAsString("nom_mode"));
257
				comboBox.setValue(record.getAsString("nom_mode"));
262
				setModification(record.getAsString("mode")) ;
258
				setModification(record.getAsString("mode")) ;
263
			}
259
			}
264
 
260
 
265
		});
261
		});
266
	
262
	
267
		this.add(panneauFormulaire) ;
263
		this.add(panneauFormulaire) ;
268
		this.setTopToolbar(bt) ;
264
		this.setTopToolbar(bt) ;
269
		
265
		
270
		
266
		
271
		this.setAutoHeight(true);
267
		this.setAutoHeight(true);
272
	
268
	
273
	
269
	
274
		// on ajoute les listeners
270
		// on ajoute les listeners
275
		ajouterListeners() ;
271
		ajouterListeners() ;
276
		
272
		
277
		
273
		
278
 
274
 
279
	}
275
	}
280
	
276
	
281
	private void ajouterListeners()
277
	private void ajouterListeners()
282
	{
278
	{	
283
		
-
 
284
		
-
 
285
		// Listener completion communne 
279
		// Listener completion communne 
286
		
280
		
287
		   commune.addListener(new ComboBoxListenerAdapter() {  
281
		   commune.addListener(new ComboBoxListenerAdapter() {  
288
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
282
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
289
	                 commune.setValue(record.getAsString("commune"));
283
	                 commune.setValue(record.getAsString("commune"));
290
	                 departement=record.getAsString("departement");
284
	                 departement=record.getAsString("departement");
291
	                 selectionCommune=true;
285
	                 selectionCommune=true;
292
	             }  
286
	             }  
293
	         });  
287
	         });  
294
	         
288
	         
295
	        
289
	        
296
			ListenerConfig listenerConfigCommune=new ListenerConfig();
290
			ListenerConfig listenerConfigCommune=new ListenerConfig();
297
			listenerConfigCommune.setDelay(10);
291
			listenerConfigCommune.setDelay(10);
298
			listenerConfigCommune.setStopPropagation(false);
292
			listenerConfigCommune.setStopPropagation(false);
299
			listenerConfigCommune.setStopEvent(false);
293
			listenerConfigCommune.setStopEvent(false);
300
			
294
			
301
 
295
 
302
		
296
		
303
		    commune.addKeyPressListener(new EventCallback()	{
297
		    commune.addKeyPressListener(new EventCallback()	{
304
		    	
298
		    	
305
		    	    public void execute(EventObject e) {
299
		    	    public void execute(EventObject e) {
306
		    	    	
300
		    	    	
307
		    	    		  
301
		    	    		  
308
		    	    		  switch(e.getKey()) {
302
		    	    		  switch(e.getKey()) {
309
		    	    	      	    		  
303
		    	    	      	    		  
310
		    	    		  
304
		    	    		  
311
		    	    		  case KEY_ALT:
305
		    	    		  case KEY_ALT:
312
		    	    	      case KEY_CTRL:
306
		    	    	      case KEY_CTRL:
313
		    	    	      case KEY_DOWN:
307
		    	    	      case KEY_DOWN:
314
		    	    	      case KEY_END:
308
		    	    	      case KEY_END:
315
		    	    	      case KEY_ESCAPE:
309
		    	    	      case KEY_ESCAPE:
316
		    	    	      case KEY_HOME:
310
		    	    	      case KEY_HOME:
317
		    	    	      case KEY_LEFT:
311
		    	    	      case KEY_LEFT:
318
		    	    	      case KEY_PAGEDOWN:
312
		    	    	      case KEY_PAGEDOWN:
319
		    	    	      case KEY_PAGEUP:
313
		    	    	      case KEY_PAGEUP:
320
		    	    	      case KEY_RIGHT:
314
		    	    	      case KEY_RIGHT:
321
		    	    	      case KEY_SHIFT:
315
		    	    	      case KEY_SHIFT:
322
		    	    	      case KEY_TAB:
316
		    	    	      case KEY_TAB:
323
		    	    	      case KEY_UP:
317
		    	    	      case KEY_UP:
324
		    	    	    	
318
		    	    	    	
325
		    	    	        break;
319
		    	    	        break;
326
		    	    	      
320
		    	    	      
327
		    	    	      case KEY_ENTER:
321
		    	    	      case KEY_ENTER:
328
		    	    	    	  
322
		    	    	    	  
329
		    	    	    	 if (selectionCommune) {
323
		    	    	    	 if (selectionCommune) {
330
		    	    	    		 selectionCommune=false;
324
		    	    	    		 selectionCommune=false;
331
		    	    	    	 }
325
		    	    	    	 }
332
		    	    	    	 else {
326
		    	    	    	 else {
333
		    	    	    		// lancer mise a jour 	    	    	    		 
327
		    	    	    		// lancer mise a jour 	    	    	    		 
334
		    	    	    	 }
328
		    	    	    	 }
335
		    	    	    	
329
		    	    	    	
336
		    	    	    	
330
		    	    	    	
337
		    	    	    	  break;
331
		    	    	    	  break;
338
		    	    	       
332
		    	    	       
339
		    	    	      default:
333
		    	    	      default:
340
		    	    	    	  
334
		    	    	    	  
341
		    	    	    	  departement="";
335
		    	    	    	  departement="";
342
		    	    	    	  obtenirListeReferentielCommune();
336
		    	    	    	  obtenirListeReferentielCommune();
343
		    	    	    	  	    	    	        
337
		    	    	    	  	    	    	        
344
		    	    	        break;
338
		    	    	        break;
345
		    	    	    }
339
		    	    	    }
346
 
340
 
347
		    	    	 
341
		    	    	 
348
		    	    	
342
		    	    	
349
		     		}
343
		     		}
350
		    	 
344
		    	 
351
		    		},    listenerConfigCommune
345
		    		},    listenerConfigCommune
352
		    	
346
		    	
353
			);
347
			);
354
		    
348
		    
355
			// Listener completion espece 
349
			// Listener completion espece 
356
 
350
 
357
			
351
			
358
			espece.addListener(new ComboBoxListenerAdapter() {  
352
			espece.addListener(new ComboBoxListenerAdapter() {  
359
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
353
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
360
	            	 espece.setValue(record.getAsString("nom"));
354
	            	 espece.setValue(record.getAsString("nom"));
361
	            	 numeroNom=record.getAsString("numeroNom");
355
	            	 numeroNom=record.getAsString("numeroNom");
362
	                 selectionEspece=true;
356
	                 selectionEspece=true;
363
	             }  
357
	             }  
364
	         });  
358
	         });  
365
	         
359
	         
366
 
360
 
367
			ListenerConfig listenerConfigEspece=new ListenerConfig();
361
			ListenerConfig listenerConfigEspece=new ListenerConfig();
368
			listenerConfigEspece.setDelay(10);
362
			listenerConfigEspece.setDelay(10);
369
			listenerConfigEspece.setStopPropagation(false);
363
			listenerConfigEspece.setStopPropagation(false);
370
			listenerConfigEspece.setStopEvent(false);			
364
			listenerConfigEspece.setStopEvent(false);			
371
 
365
 
372
		
366
		
373
			espece.addKeyPressListener(new EventCallback()	{
367
			espece.addKeyPressListener(new EventCallback()	{
374
		    	
368
		    	
375
		    	    public void execute(EventObject e) {
369
		    	    public void execute(EventObject e) {
376
		    	    	
370
		    	    	
377
		    	    		  
371
		    	    		  
378
		    	    		  switch(e.getKey()) {
372
		    	    		  switch(e.getKey()) {
379
		    	    	      	    		  
373
		    	    	      	    		  
380
		    	    		  
374
		    	    		  
381
		    	    		  case KEY_ALT:
375
		    	    		  case KEY_ALT:
382
		    	    	      case KEY_CTRL:
376
		    	    	      case KEY_CTRL:
383
		    	    	      case KEY_DOWN:
377
		    	    	      case KEY_DOWN:
384
		    	    	      case KEY_END:
378
		    	    	      case KEY_END:
385
		    	    	      case KEY_ESCAPE:
379
		    	    	      case KEY_ESCAPE:
386
		    	    	      case KEY_HOME:
380
		    	    	      case KEY_HOME:
387
		    	    	      case KEY_LEFT:
381
		    	    	      case KEY_LEFT:
388
		    	    	      case KEY_PAGEDOWN:
382
		    	    	      case KEY_PAGEDOWN:
389
		    	    	      case KEY_PAGEUP:
383
		    	    	      case KEY_PAGEUP:
390
		    	    	      case KEY_RIGHT:
384
		    	    	      case KEY_RIGHT:
391
		    	    	      case KEY_SHIFT:
385
		    	    	      case KEY_SHIFT:
392
		    	    	      case KEY_TAB:
386
		    	    	      case KEY_TAB:
393
		    	    	      case KEY_UP:
387
		    	    	      case KEY_UP:
394
		    	    	    	
388
		    	    	    	
395
		    	    	        break;
389
		    	    	        break;
396
		    	    	      
390
		    	    	      
397
		    	    	      case KEY_ENTER:
391
		    	    	      case KEY_ENTER:
398
		    	    	    	  
392
		    	    	    	  
399
		    	    	    	 if (selectionEspece) {
393
		    	    	    	 if (selectionEspece) {
400
		    	    	    		 selectionEspece=false;
394
		    	    	    		 selectionEspece=false;
401
		    	    	    	 }
395
		    	    	    	 }
402
		    	    	    	 else {
396
		    	    	    	 else {
403
		    	    	    		// lancer mise a jour 	    	    	    		 
397
		    	    	    		// lancer mise a jour 	    	    	    		 
404
		    	    	    	 }
398
		    	    	    	 }
405
		    	    	    	
399
		    	    	    	
406
		    	    	    	
400
		    	    	    	
407
		    	    	    	  break;
401
		    	    	    	  break;
408
		    	    	       
402
		    	    	       
409
		    	    	      default:
403
		    	    	      default:
410
		    	    	    	  
404
		    	    	    	  
411
		    	    	    	  numeroNom="";
405
		    	    	    	  numeroNom="";
412
		    	    	    	  obtenirListeReferentielNom();
406
		    	    	    	  obtenirListeReferentielNom();
413
		    	    	    	  	    	    	        
407
		    	    	    	  	    	    	        
414
		    	    	        break;
408
		    	    	        break;
415
		    	    	    }
409
		    	    	    }
416
 
410
 
417
		    	    	 
411
		    	    	 
418
		    	    	
412
		    	    	
419
		     		}
413
		     		}
420
		    	 
414
		    	 
421
		    		},    listenerConfigEspece
415
		    		},    listenerConfigEspece
422
		    	
416
		    	
423
			);
417
			);
424
		    
418
		    
425
 
419
 
426
		  
420
		  
427
 
421
 
428
		boutonOK.addListener(new ButtonListenerAdapter() {
422
		boutonOK.addListener(new ButtonListenerAdapter() {
429
			
423
			
430
			public void onClick(Button button, EventObject e) {
424
			public void onClick(Button button, EventObject e) {
431
				
425
				
432
				if(modification)
426
				if(modification)
433
				{
427
				{
434
					modifierObservation() ;
428
					modifierObservation() ;
435
				}
429
				}
436
				else
430
				else
437
				{
431
				{
438
					ajouterObservation();
432
					ajouterObservation();
439
				}
433
				}
440
				
434
				
441
				
435
				
442
			}
436
			}
443
			
437
			
444
		});
438
		});
445
		
439
		
446
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
440
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
447
			
441
			
448
			public void onClick(Button button, EventObject e) {
442
			public void onClick(Button button, EventObject e) {
449
				
443
				
450
				if(modification)
444
				if(modification)
451
				{
445
				{
452
					supprimerObservation() ;
446
					supprimerObservation() ;
453
				}
447
				}
454
				else
448
				else
455
				{
449
				{
456
					viderChampsObservation();
450
					viderChampsObservation();
457
				}
451
				}
458
				
452
				
459
				
453
				
460
			}
454
			}
461
			
455
			
462
		});
456
		});
463
	
457
	
464
	
458
	
465
	}
459
	}
466
	
460
	
467
	/**
461
	/**
468
	 * Desactive visuellement ce panneau
462
	 * Desactive visuellement ce panneau
469
	 */
463
	 */
470
	public void desactiverPanneau()
464
	public void desactiverPanneau()
471
	{
465
	{
472
		this.setDisabled(true) ;
466
		this.setDisabled(true) ;
473
	}
467
	}
474
	
468
	
475
	/**
469
	/**
476
	 * Active visuellement ce panneau
470
	 * Active visuellement ce panneau
477
	 */
471
	 */
478
	public void activerPanneau()
472
	public void activerPanneau()
479
	{
473
	{
480
		this.setDisabled(false) ;
474
		this.setDisabled(false) ;
481
	}
475
	}
482
 
476
 
483
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
477
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
484
		
478
		
485
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
479
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
486
			if(nouvelleDonnees instanceof ListeReferentielCommune)
480
			if(nouvelleDonnees instanceof ListeReferentielCommune)
487
			{
481
			{
488
				
482
				
489
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
483
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
490
					Object[][] communeData = new Object[data.size()][2];
484
					Object[][] communeData = new Object[data.size()][2];
491
					int i = 0 ;
485
					int i = 0 ;
492
				
486
				
493
					// on la parse et on récupère les informations quiç nous interessent
487
					// on la parse et on récupère les informations quiç nous interessent
494
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
488
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
495
					{
489
					{
496
						
490
						
497
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
491
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
498
						
492
						
499
						communeData[i][0]= ref.getCommune();
493
						communeData[i][0]= ref.getCommune();
500
						communeData[i][1]= ref.getDepartement();
494
						communeData[i][1]= ref.getDepartement();
501
						
495
						
502
																	
496
																	
503
						i++ ;
497
						i++ ;
504
					}
498
					}
505
					
499
					
506
					   //	  creation du store
500
					   //	  creation du store
507
					FieldDef defCommune = new StringFieldDef("commune");
501
					FieldDef defCommune = new StringFieldDef("commune");
508
					FieldDef defDepartement = new StringFieldDef("departement");
502
					FieldDef defDepartement = new StringFieldDef("departement");
509
					
503
					
510
					
504
					
511
					FieldDef[] defTab = { defCommune, defDepartement};
505
					FieldDef[] defTab = { defCommune, defDepartement};
512
					
506
					
513
					RecordDef rd = new RecordDef(defTab);
507
					RecordDef rd = new RecordDef(defTab);
514
					
508
					
515
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
509
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
516
					final ArrayReader reader = new ArrayReader(rd);		
510
					final ArrayReader reader = new ArrayReader(rd);		
517
					
511
					
518
					Store store=new Store(dataProxy,reader);
512
					Store store=new Store(dataProxy,reader);
519
					store.load() ;
513
					store.load() ;
520
		
514
		
521
					commune.setStore(store);					
515
					commune.setStore(store);					
522
							
516
							
523
			}
517
			}
524
			
518
			
525
			//			 si l'on a reçu une liste du referentiel nom (complétion referentiel nom)
519
			//			 si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
526
			
520
			
527
			if(nouvelleDonnees instanceof ListeReferentielNom)
521
			if(nouvelleDonnees instanceof ListeReferentielNom)
528
			{
522
			{
529
				
523
				
530
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
524
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
531
					Object[][] nomData = new Object[data.size()][2];
525
					Object[][] nomData = new Object[data.size()][2];
532
					int i = 0 ;
526
					int i = 0 ;
533
				
527
				
534
					// on la parse et on récupère les informations quiç nous interessent
528
					// on la parse et on récupère les informations quiç nous interessent
535
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
529
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
536
					{
530
					{
537
						
531
						
538
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
532
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
539
						
533
						
540
						nomData[i][0]= ref.getNom();
534
						nomData[i][0]= ref.getNom();
541
						nomData[i][1]= ref.getNumeroNom();
535
						nomData[i][1]= ref.getNumeroNom();
542
						
536
						
543
																	
537
																	
544
						i++ ;
538
						i++ ;
545
					}
539
					}
546
					
540
					
547
					   //	  creation du store
541
					   //	  creation du store
548
					FieldDef defNom = new StringFieldDef("nom");
542
					FieldDef defNom = new StringFieldDef("nom");
549
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
543
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
550
					
544
					
551
					
545
					
552
					FieldDef[] defTab = { defNom, defNumeroNom};
546
					FieldDef[] defTab = { defNom, defNumeroNom};
553
					
547
					
554
					RecordDef rd = new RecordDef(defTab);
548
					RecordDef rd = new RecordDef(defTab);
555
					
549
					
556
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
550
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
557
					final ArrayReader reader = new ArrayReader(rd);		
551
					final ArrayReader reader = new ArrayReader(rd);		
558
					
552
					
559
					Store store=new Store(dataProxy,reader);
553
					Store store=new Store(dataProxy,reader);
560
					store.load() ;
554
					store.load() ;
561
		
555
		
562
					espece.setStore(store);
556
					espece.setStore(store);
563
				
557
				
564
					
558
					
565
							
559
							
566
			}
560
			}
567
			
561
			
568
			// On recoit une observation dont on veut afficher le detail 
562
			// On recoit une observation dont on veut afficher le detail 
569
			
563
			
570
			if(nouvelleDonnees instanceof Observation)
564
			if(nouvelleDonnees instanceof Observation)
571
			{
565
			{
572
				Observation obs = (Observation)nouvelleDonnees ;
566
				Observation obs = (Observation)nouvelleDonnees ;
573
				afficherDetailsObservation(obs) ;
567
				afficherDetailsObservation(obs) ;
574
			}
568
			}
575
			
569
			
576
			// Sur Mise à jour ou suppression d'une suppression ?
570
			// Sur Mise à jour ou suppression d'une suppression ?
577
			
571
			
578
			if(nouvelleDonnees instanceof String)
572
			if(nouvelleDonnees instanceof String)
579
			{
573
			{
580
				String str = (String)nouvelleDonnees ;
574
				String str = (String)nouvelleDonnees ;
581
				observationMediateur.obtenirListeObservation() ;
575
				observationMediateur.obtenirListeObservation() ;
582
			}
576
			}
583
 
577
 
584
	}
578
	}
585
	
579
	
586
 
580
 
587
	public void obtenirListeReferentielCommune() {
581
	public void obtenirListeReferentielCommune() {
-
 
582
		
588
	 String com=commune.getText().replaceAll(" ","/");
583
	 String com=commune.getText().replaceAll(" ","/");
589
	 com=com.replaceAll("%","");
584
	 com=com.replaceAll("%","");
590
		  
585
		  
591
	 observationMediateur.obtenirListeReferentielCommune(this,com);
586
	 observationMediateur.obtenirListeReferentielCommune(this,com);
592
	 
587
	 
593
	}
588
	}
594
	
589
	
595
 
590
 
596
	public void obtenirListeReferentielNom() {
591
	public void obtenirListeReferentielNom() {
597
	 
592
	 
598
	  String esp=espece.getText().replaceAll(" ","/");
593
	  String esp=espece.getText().replaceAll(" ","/");
599
	  esp=esp.replaceAll("%","");
594
	  esp=esp.replaceAll("%","");
600
		
595
		
601
	  observationMediateur.obtenirListeReferentielNom(this,esp);
596
	  observationMediateur.obtenirListeReferentielNom(this,esp);
602
	 
597
	 
603
	}
598
	}
604
   
599
   
605
 
600
 
606
	public void ajouterObservation() {
601
	public void ajouterObservation() {
607
 
602
 
608
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
603
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
609
		observationMediateur.ajouterObservation(obs);
604
		observationMediateur.ajouterObservation(obs);
610
	}
605
	}
611
	
606
	
612
	private void modifierObservation() {
607
	private void modifierObservation() {
613
		
608
		
614
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText());
609
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText());
615
		obs.setNumeroOrdre(numeroOrdre);
610
		obs.setNumeroOrdre(numeroOrdre);
616
		observationMediateur.modifierObservation(obs);
611
		observationMediateur.modifierObservation(obs);
617
		
612
		
618
	}
613
	}
619
	
614
	
620
	private void supprimerObservation() {
615
	private void supprimerObservation() {
621
		
616
		
622
			observationMediateur.supprimerObservation(this, numeroOrdre);
617
			observationMediateur.supprimerObservation(this, numeroOrdre);
623
	}
618
	}
624
 
619
 
625
	
620
	
626
	public void afficherDetailsObservation(Observation obs)
621
	public void afficherDetailsObservation(Observation obs)
627
	{
622
	{
628
		viderChampsObservation() ;
623
		viderChampsObservation() ;
629
		
624
		
630
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
625
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
631
			String[] dateEtHeure = obs.getDate().split(" ", 2);
626
			String[] dateEtHeure = obs.getDate().split(" ", 2);
632
			date.setValue(dateEtHeure[0]) ;
627
			date.setValue(dateEtHeure[0]) ;
633
		}
628
		}
634
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
629
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
635
			lieudit.setValue(obs.getLieudit()) ;
630
			lieudit.setValue(obs.getLieudit()) ;
636
		}
631
		}
637
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
632
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
638
			station.setValue(obs.getStation()) ;
633
			station.setValue(obs.getStation()) ;
639
		}
634
		}
640
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
635
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
641
			milieu.setValue(obs.getMilieu()) ;
636
			milieu.setValue(obs.getMilieu()) ;
642
		}
637
		}
643
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
638
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
644
			comment.setValue(obs.getCommentaire()) ;
639
			comment.setValue(obs.getCommentaire()) ;
645
		}
640
		}
646
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
641
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
647
			commune.setValue(obs.getLocalite()) ;
642
			commune.setValue(obs.getLocalite()) ;
648
		}
643
		}
649
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
644
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
650
			departement = obs.getIdentifiantLocalite();
645
			departement = obs.getIdentifiantLocalite();
651
		}
646
		}
652
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
647
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
653
			espece.setValue(obs.getNomSaisi()) ;
648
			espece.setValue(obs.getNomSaisi()) ;
654
		}
649
		}
655
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
650
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
656
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
651
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
657
		}
652
		}
658
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
653
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
659
			numeroOrdre = obs.getNumeroOrdre() ;
654
			numeroOrdre = obs.getNumeroOrdre() ;
660
		}
655
		}
661
		
656
		
662
	}
657
	}
663
	
658
	
664
	public void viderChampsObservation()
659
	public void viderChampsObservation()
665
	{
660
	{
666
 
661
 
667
		date.reset() ;
662
		date.reset() ;
668
		lieudit.reset() ;
663
		lieudit.reset() ;
669
		station.reset() ;
664
		station.reset() ;
670
		milieu.reset();
665
		milieu.reset();
671
		comment.reset();
666
		comment.reset();
672
		commune.reset();
667
		commune.reset();
673
		departement = "";
668
		departement = "";
674
		espece.reset();
669
		espece.reset();
675
		numeroNom = "" ;
670
		numeroNom = "" ;
676
		numeroOrdre = "";
671
		numeroOrdre = "";
677
		
672
		
678
	}
673
	}
679
	
674
	
680
	private void setModification(String mode)
675
	private void setModification(String mode)
681
	{
676
	{
682
		if(mode.equals("true")) {
677
		if(mode.equals("true")) {
683
 
678
 
684
			boutonOK.setText("Modifier") ;
679
			boutonOK.setText("Modifier") ;
685
			setTitle("Modification") ;
680
			setTitle("Modification") ;
686
			boutonAnnuler.setText("Supprimer") ;
681
			boutonAnnuler.setText("Supprimer") ;
687
			modification = true ;
682
			modification = true ;
-
 
683
			
688
		}
684
		}
689
		else
685
		else
690
		{
686
		{
691
 
687
 
692
			boutonOK.setText("Créer") ;
688
			boutonOK.setText("Créer") ;
693
			setTitle("Saisir") ;
689
			setTitle("Saisir") ;
694
			boutonAnnuler.setText("Réinitialiser") ;
690
			boutonAnnuler.setText("Réinitialiser") ;
695
			modification = false ;
691
			modification = false ;
-
 
692
			
696
		}
693
		}
697
		
694
		
698
	}
695
	}
699
	
696
	
700
	
697
	
701
	/**
698
	/**
702
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
699
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
703
	 * @return
700
	 * @return
704
	 */
701
	 */
705
	public boolean getModification()
702
	public boolean getModification()
706
	{
703
	{
707
		return modification ;
704
		return modification ;
708
	}
705
	}
709
	
706
	
710
 
707
 
711
}
708
}