Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 74 Rev 77
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("Annuler");
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
		
228
		
229
		/*final Template tp = new Template("<div class=\"x-combo-list-item\">"
229
		/*final Template tp = new Template("<div class=\"x-combo-list-item\">"
230
				+ "{nom_mode}" + "<div class=\"x-clear\"></div></div>");
230
				+ "{nom_mode}" + "<div class=\"x-clear\"></div></div>");
231
		tp.compile();*/
231
		tp.compile();*/
232
		
232
		
233
		Object[][] mode = {{"création",false} , {"modification", true} };
233
		Object[][] mode = {{"création",false} , {"modification", true} };
234
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
234
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
235
				mode);
235
				mode);
236
		storeMode.load();
236
		storeMode.load();
237
		selecteurMode.setStore(storeMode);
237
		selecteurMode.setStore(storeMode);
238
		selecteurMode.setDisplayField("nom_mode") ;
238
		selecteurMode.setDisplayField("nom_mode") ;
239
		selecteurMode.setLabel("mode ") ;
239
		selecteurMode.setLabel("mode ") ;
240
		selecteurMode.setForceSelection(true) ;
240
		selecteurMode.setForceSelection(true) ;
241
		selecteurMode.setValue("création") ;
241
		selecteurMode.setValue("création") ;
242
		selecteurMode.setEditable(false) ;
242
		selecteurMode.setEditable(false) ;
243
		
243
		
244
		bt = new Toolbar() ;
244
		bt = new Toolbar() ;
245
		bt.addSpacer() ;
245
		bt.addSpacer() ;
246
		bt.addText("Mode de saisie ") ;
246
		bt.addText("Mode de saisie ") ;
247
		bt.addField(selecteurMode) ;
247
		bt.addField(selecteurMode) ;
248
		
248
		
249
		
249
		
250
		
250
		
251
		
251
		
252
		panneauFormulaire.addButton(boutonOK);
252
		panneauFormulaire.addButton(boutonOK);
253
		    
253
		    
254
		panneauFormulaire.addButton(boutonAnnuler);
254
		panneauFormulaire.addButton(boutonAnnuler);
255
		
255
		
256
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
256
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
257
 
257
 
258
			public void onSelect(ComboBox comboBox, Record record, int index) {
258
			public void onSelect(ComboBox comboBox, Record record, int index) {
259
				
259
				
260
				// et on met la valeur à jour dans la combobox
260
				// et on met la valeur à jour dans la combobox
261
				comboBox.setValue(record.getAsString("nom_mode"));
261
				comboBox.setValue(record.getAsString("nom_mode"));
262
				setModification(record.getAsString("mode")) ;
262
				setModification(record.getAsString("mode")) ;
263
			}
263
			}
264
 
264
 
265
		});
265
		});
266
	
266
	
267
		this.add(panneauFormulaire) ;
267
		this.add(panneauFormulaire) ;
268
		this.setBottomToolbar(bt) ;
268
		this.setBottomToolbar(bt) ;
269
		
269
		
270
		
270
		
271
		this.setAutoHeight(true);
271
		this.setAutoHeight(true);
272
	
272
	
273
	
273
	
274
		// on ajoute les listeners
274
		// on ajoute les listeners
275
		ajouterListeners() ;
275
		ajouterListeners() ;
276
		
276
		
277
		
277
		
278
 
278
 
279
	}
279
	}
280
	
280
	
281
	private void ajouterListeners()
281
	private void ajouterListeners()
282
	{
282
	{
283
		
283
		
284
		
284
		
285
		// Listener completion communne 
285
		// Listener completion communne 
286
		
286
		
287
		   commune.addListener(new ComboBoxListenerAdapter() {  
287
		   commune.addListener(new ComboBoxListenerAdapter() {  
288
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
288
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
289
	                 commune.setValue(record.getAsString("commune"));
289
	                 commune.setValue(record.getAsString("commune"));
290
	                 departement=record.getAsString("departement");
290
	                 departement=record.getAsString("departement");
291
	                 selectionCommune=true;
291
	                 selectionCommune=true;
292
	             }  
292
	             }  
293
	         });  
293
	         });  
294
	         
294
	         
295
	        
295
	        
296
			ListenerConfig listenerConfigCommune=new ListenerConfig();
296
			ListenerConfig listenerConfigCommune=new ListenerConfig();
297
			listenerConfigCommune.setDelay(10);
297
			listenerConfigCommune.setDelay(10);
298
			listenerConfigCommune.setStopPropagation(false);
298
			listenerConfigCommune.setStopPropagation(false);
299
			listenerConfigCommune.setStopEvent(false);
299
			listenerConfigCommune.setStopEvent(false);
300
			
300
			
301
 
301
 
302
		
302
		
303
		    commune.addKeyPressListener(new EventCallback()	{
303
		    commune.addKeyPressListener(new EventCallback()	{
304
		    	
304
		    	
305
		    	    public void execute(EventObject e) {
305
		    	    public void execute(EventObject e) {
306
		    	    	
306
		    	    	
307
		    	    		  
307
		    	    		  
308
		    	    		  switch(e.getKey()) {
308
		    	    		  switch(e.getKey()) {
309
		    	    	      	    		  
309
		    	    	      	    		  
310
		    	    		  
310
		    	    		  
311
		    	    		  case KEY_ALT:
311
		    	    		  case KEY_ALT:
312
		    	    	      case KEY_CTRL:
312
		    	    	      case KEY_CTRL:
313
		    	    	      case KEY_DOWN:
313
		    	    	      case KEY_DOWN:
314
		    	    	      case KEY_END:
314
		    	    	      case KEY_END:
315
		    	    	      case KEY_ESCAPE:
315
		    	    	      case KEY_ESCAPE:
316
		    	    	      case KEY_HOME:
316
		    	    	      case KEY_HOME:
317
		    	    	      case KEY_LEFT:
317
		    	    	      case KEY_LEFT:
318
		    	    	      case KEY_PAGEDOWN:
318
		    	    	      case KEY_PAGEDOWN:
319
		    	    	      case KEY_PAGEUP:
319
		    	    	      case KEY_PAGEUP:
320
		    	    	      case KEY_RIGHT:
320
		    	    	      case KEY_RIGHT:
321
		    	    	      case KEY_SHIFT:
321
		    	    	      case KEY_SHIFT:
322
		    	    	      case KEY_TAB:
322
		    	    	      case KEY_TAB:
323
		    	    	      case KEY_UP:
323
		    	    	      case KEY_UP:
324
		    	    	    	
324
		    	    	    	
325
		    	    	        break;
325
		    	    	        break;
326
		    	    	      
326
		    	    	      
327
		    	    	      case KEY_ENTER:
327
		    	    	      case KEY_ENTER:
328
		    	    	    	  
328
		    	    	    	  
329
		    	    	    	 if (selectionCommune) {
329
		    	    	    	 if (selectionCommune) {
330
		    	    	    		 selectionCommune=false;
330
		    	    	    		 selectionCommune=false;
331
		    	    	    	 }
331
		    	    	    	 }
332
		    	    	    	 else {
332
		    	    	    	 else {
333
		    	    	    		// lancer mise a jour 	    	    	    		 
333
		    	    	    		// lancer mise a jour 	    	    	    		 
334
		    	    	    	 }
334
		    	    	    	 }
335
		    	    	    	
335
		    	    	    	
336
		    	    	    	
336
		    	    	    	
337
		    	    	    	  break;
337
		    	    	    	  break;
338
		    	    	       
338
		    	    	       
339
		    	    	      default:
339
		    	    	      default:
340
		    	    	    	  
340
		    	    	    	  
341
		    	    	    	  obtenirListeReferentielCommune();
341
		    	    	    	  obtenirListeReferentielCommune();
342
		    	    	    	  	    	    	        
342
		    	    	    	  	    	    	        
343
		    	    	        break;
343
		    	    	        break;
344
		    	    	    }
344
		    	    	    }
345
 
345
 
346
		    	    	 
346
		    	    	 
347
		    	    	
347
		    	    	
348
		     		}
348
		     		}
349
		    	 
349
		    	 
350
		    		},    listenerConfigCommune
350
		    		},    listenerConfigCommune
351
		    	
351
		    	
352
			);
352
			);
353
		    
353
		    
354
			// Listener completion espece 
354
			// Listener completion espece 
355
 
355
 
356
			
356
			
357
			espece.addListener(new ComboBoxListenerAdapter() {  
357
			espece.addListener(new ComboBoxListenerAdapter() {  
358
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
358
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
359
	            	 espece.setValue(record.getAsString("nom"));
359
	            	 espece.setValue(record.getAsString("nom"));
360
	            	 numeroNom=record.getAsString("numeroNom");
360
	            	 numeroNom=record.getAsString("numeroNom");
361
	                 selectionEspece=true;
361
	                 selectionEspece=true;
362
	             }  
362
	             }  
363
	         });  
363
	         });  
364
	         
364
	         
365
 
365
 
366
			ListenerConfig listenerConfigEspece=new ListenerConfig();
366
			ListenerConfig listenerConfigEspece=new ListenerConfig();
367
			listenerConfigEspece.setDelay(10);
367
			listenerConfigEspece.setDelay(10);
368
			listenerConfigEspece.setStopPropagation(false);
368
			listenerConfigEspece.setStopPropagation(false);
369
			listenerConfigEspece.setStopEvent(false);			
369
			listenerConfigEspece.setStopEvent(false);			
370
 
370
 
371
		
371
		
372
			espece.addKeyPressListener(new EventCallback()	{
372
			espece.addKeyPressListener(new EventCallback()	{
373
		    	
373
		    	
374
		    	    public void execute(EventObject e) {
374
		    	    public void execute(EventObject e) {
375
		    	    	
375
		    	    	
376
		    	    		  
376
		    	    		  
377
		    	    		  switch(e.getKey()) {
377
		    	    		  switch(e.getKey()) {
378
		    	    	      	    		  
378
		    	    	      	    		  
379
		    	    		  
379
		    	    		  
380
		    	    		  case KEY_ALT:
380
		    	    		  case KEY_ALT:
381
		    	    	      case KEY_CTRL:
381
		    	    	      case KEY_CTRL:
382
		    	    	      case KEY_DOWN:
382
		    	    	      case KEY_DOWN:
383
		    	    	      case KEY_END:
383
		    	    	      case KEY_END:
384
		    	    	      case KEY_ESCAPE:
384
		    	    	      case KEY_ESCAPE:
385
		    	    	      case KEY_HOME:
385
		    	    	      case KEY_HOME:
386
		    	    	      case KEY_LEFT:
386
		    	    	      case KEY_LEFT:
387
		    	    	      case KEY_PAGEDOWN:
387
		    	    	      case KEY_PAGEDOWN:
388
		    	    	      case KEY_PAGEUP:
388
		    	    	      case KEY_PAGEUP:
389
		    	    	      case KEY_RIGHT:
389
		    	    	      case KEY_RIGHT:
390
		    	    	      case KEY_SHIFT:
390
		    	    	      case KEY_SHIFT:
391
		    	    	      case KEY_TAB:
391
		    	    	      case KEY_TAB:
392
		    	    	      case KEY_UP:
392
		    	    	      case KEY_UP:
393
		    	    	    	
393
		    	    	    	
394
		    	    	        break;
394
		    	    	        break;
395
		    	    	      
395
		    	    	      
396
		    	    	      case KEY_ENTER:
396
		    	    	      case KEY_ENTER:
397
		    	    	    	  
397
		    	    	    	  
398
		    	    	    	 if (selectionEspece) {
398
		    	    	    	 if (selectionEspece) {
399
		    	    	    		 selectionEspece=false;
399
		    	    	    		 selectionEspece=false;
400
		    	    	    	 }
400
		    	    	    	 }
401
		    	    	    	 else {
401
		    	    	    	 else {
402
		    	    	    		// lancer mise a jour 	    	    	    		 
402
		    	    	    		// lancer mise a jour 	    	    	    		 
403
		    	    	    	 }
403
		    	    	    	 }
404
		    	    	    	
404
		    	    	    	
405
		    	    	    	
405
		    	    	    	
406
		    	    	    	  break;
406
		    	    	    	  break;
407
		    	    	       
407
		    	    	       
408
		    	    	      default:
408
		    	    	      default:
409
		    	    	    	  
409
		    	    	    	  
410
		    	    	    	  obtenirListeReferentielNom();
410
		    	    	    	  obtenirListeReferentielNom();
411
		    	    	    	  	    	    	        
411
		    	    	    	  	    	    	        
412
		    	    	        break;
412
		    	    	        break;
413
		    	    	    }
413
		    	    	    }
414
 
414
 
415
		    	    	 
415
		    	    	 
416
		    	    	
416
		    	    	
417
		     		}
417
		     		}
418
		    	 
418
		    	 
419
		    		},    listenerConfigEspece
419
		    		},    listenerConfigEspece
420
		    	
420
		    	
421
			);
421
			);
422
		    
422
		    
423
 
423
 
424
		  
424
		  
425
 
425
 
426
		boutonOK.addListener(new ButtonListenerAdapter() {
426
		boutonOK.addListener(new ButtonListenerAdapter() {
427
			
427
			
428
			public void onClick(Button button, EventObject e) {
428
			public void onClick(Button button, EventObject e) {
429
				
429
				
430
				if(modification)
430
				if(modification)
431
				{
431
				{
432
					modifierObservation() ;
432
					modifierObservation() ;
433
				}
433
				}
434
				else
434
				else
435
				{
435
				{
436
					ajouterObservation();
436
					ajouterObservation();
437
				}
437
				}
438
				
438
				
439
				
439
				
440
			}
440
			}
441
			
441
			
442
		});
442
		});
443
 
443
		
444
		// on ajoute un écouteur
-
 
445
		/*validerInfo.addListener(new ButtonListenerAdapter() {
444
		boutonAnnuler.addListener(new ButtonListenerAdapter() {
446
 
-
 
447
			// gestion du clic
-
 
448
			
445
			
449
			public void onClick(Button button, EventObject e) {
446
			public void onClick(Button button, EventObject e) {
-
 
447
				
-
 
448
				if(modification)
450
				
449
				{
-
 
450
					supprimerObservation() ;
-
 
451
				}
-
 
452
				else
451
				// lors du clic sur le bouton valider on met à jour les commentaires et la date
453
				{
-
 
454
					viderChampsObservation();
-
 
455
				}
452
		//	getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue(), noteVue.getNote()) ;
456
				
-
 
457
				
453
				
458
			}
454
			}	
-
 
455
		});
459
			
456
		*/
460
		});
457
	
461
	
458
	
462
	
459
	}
463
	}
460
	
464
	
461
	/**
465
	/**
462
	 * Desactive visuellement ce panneau
466
	 * Desactive visuellement ce panneau
463
	 */
467
	 */
464
	public void desactiverPanneau()
468
	public void desactiverPanneau()
465
	{
469
	{
466
		this.setDisabled(true) ;
470
		this.setDisabled(true) ;
467
	}
471
	}
468
	
472
	
469
	/**
473
	/**
470
	 * Active visuellement ce panneau
474
	 * Active visuellement ce panneau
471
	 */
475
	 */
472
	public void activerPanneau()
476
	public void activerPanneau()
473
	{
477
	{
474
		this.setDisabled(false) ;
478
		this.setDisabled(false) ;
475
	}
479
	}
476
 
480
 
477
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
481
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
478
		
482
		
479
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
483
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
480
			if(nouvelleDonnees instanceof ListeReferentielCommune)
484
			if(nouvelleDonnees instanceof ListeReferentielCommune)
481
			{
485
			{
482
				
486
				
483
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
487
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
484
					Object[][] communeData = new Object[data.size()][2];
488
					Object[][] communeData = new Object[data.size()][2];
485
					int i = 0 ;
489
					int i = 0 ;
486
				
490
				
487
					// on la parse et on récupère les informations quiç nous interessent
491
					// on la parse et on récupère les informations quiç nous interessent
488
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
492
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
489
					{
493
					{
490
						
494
						
491
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
495
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
492
						
496
						
493
						communeData[i][0]= ref.getCommune();
497
						communeData[i][0]= ref.getCommune();
494
						communeData[i][1]= ref.getDepartement();
498
						communeData[i][1]= ref.getDepartement();
495
						
499
						
496
																	
500
																	
497
						i++ ;
501
						i++ ;
498
					}
502
					}
499
					
503
					
500
					   //	  creation du store
504
					   //	  creation du store
501
					FieldDef defCommune = new StringFieldDef("commune");
505
					FieldDef defCommune = new StringFieldDef("commune");
502
					FieldDef defDepartement = new StringFieldDef("departement");
506
					FieldDef defDepartement = new StringFieldDef("departement");
503
					
507
					
504
					
508
					
505
					FieldDef[] defTab = { defCommune, defDepartement};
509
					FieldDef[] defTab = { defCommune, defDepartement};
506
					
510
					
507
					RecordDef rd = new RecordDef(defTab);
511
					RecordDef rd = new RecordDef(defTab);
508
					
512
					
509
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
513
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
510
					final ArrayReader reader = new ArrayReader(rd);		
514
					final ArrayReader reader = new ArrayReader(rd);		
511
					
515
					
512
					Store store=new Store(dataProxy,reader);
516
					Store store=new Store(dataProxy,reader);
513
					store.load() ;
517
					store.load() ;
514
		
518
		
515
					commune.setStore(store);					
519
					commune.setStore(store);					
516
							
520
							
517
			}
521
			}
518
			
522
			
519
			//			 si l'on a reçu une liste du referentiel nom (complétion referentiel nom)
523
			//			 si l'on a reçu une liste du referentiel nom (complétion referentiel nom)
520
			
524
			
521
			if(nouvelleDonnees instanceof ListeReferentielNom)
525
			if(nouvelleDonnees instanceof ListeReferentielNom)
522
			{
526
			{
523
				
527
				
524
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
528
					ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
525
					Object[][] nomData = new Object[data.size()][2];
529
					Object[][] nomData = new Object[data.size()][2];
526
					int i = 0 ;
530
					int i = 0 ;
527
				
531
				
528
					// on la parse et on récupère les informations quiç nous interessent
532
					// on la parse et on récupère les informations quiç nous interessent
529
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
533
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
530
					{
534
					{
531
						
535
						
532
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
536
						ReferentielNom ref=(ReferentielNom) data.get(it.next());
533
						
537
						
534
						nomData[i][0]= ref.getNom();
538
						nomData[i][0]= ref.getNom();
535
						nomData[i][1]= ref.getNumeroNom();
539
						nomData[i][1]= ref.getNumeroNom();
536
						
540
						
537
																	
541
																	
538
						i++ ;
542
						i++ ;
539
					}
543
					}
540
					
544
					
541
					   //	  creation du store
545
					   //	  creation du store
542
					FieldDef defNom = new StringFieldDef("nom");
546
					FieldDef defNom = new StringFieldDef("nom");
543
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
547
					FieldDef defNumeroNom = new StringFieldDef("numeroNom");
544
					
548
					
545
					
549
					
546
					FieldDef[] defTab = { defNom, defNumeroNom};
550
					FieldDef[] defTab = { defNom, defNumeroNom};
547
					
551
					
548
					RecordDef rd = new RecordDef(defTab);
552
					RecordDef rd = new RecordDef(defTab);
549
					
553
					
550
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
554
					final MemoryProxy dataProxy = new MemoryProxy(nomData);
551
					final ArrayReader reader = new ArrayReader(rd);		
555
					final ArrayReader reader = new ArrayReader(rd);		
552
					
556
					
553
					Store store=new Store(dataProxy,reader);
557
					Store store=new Store(dataProxy,reader);
554
					store.load() ;
558
					store.load() ;
555
		
559
		
556
					espece.setStore(store);
560
					espece.setStore(store);
557
				
561
				
558
					
562
					
559
							
563
							
560
			}
564
			}
561
			
565
			
562
			if(nouvelleDonnees instanceof Observation)
566
			if(nouvelleDonnees instanceof Observation)
563
			{
567
			{
564
				Observation obs = (Observation)nouvelleDonnees ;
568
				Observation obs = (Observation)nouvelleDonnees ;
565
				afficherDetailsObservation(obs) ;
569
				afficherDetailsObservation(obs) ;
566
			}
570
			}
-
 
571
			
-
 
572
			if(nouvelleDonnees instanceof String)
-
 
573
			{
-
 
574
				String str = (String)nouvelleDonnees ;
-
 
575
				observationMediateur.obtenirListeObservation() ;
-
 
576
			}
567
 
577
 
568
	}
578
	}
569
	
579
	
570
 
580
 
571
	public void obtenirListeReferentielCommune() {
581
	public void obtenirListeReferentielCommune() {
572
	 String com=commune.getText().replaceAll(" ","/");
582
	 String com=commune.getText().replaceAll(" ","/");
573
	 com=com.replaceAll("%","");
583
	 com=com.replaceAll("%","");
574
		  
584
		  
575
	 observationMediateur.obtenirListeReferentielCommune(this,com);
585
	 observationMediateur.obtenirListeReferentielCommune(this,com);
576
	 
586
	 
577
	}
587
	}
578
	
588
	
579
 
589
 
580
	public void obtenirListeReferentielNom() {
590
	public void obtenirListeReferentielNom() {
581
	 
591
	 
582
	  String esp=espece.getText().replaceAll(" ","/");
592
	  String esp=espece.getText().replaceAll(" ","/");
583
	  esp=esp.replaceAll("%","");
593
	  esp=esp.replaceAll("%","");
584
		
594
		
585
	  observationMediateur.obtenirListeReferentielNom(this,esp);
595
	  observationMediateur.obtenirListeReferentielNom(this,esp);
586
	 
596
	 
587
	}
597
	}
588
   
598
   
589
 
599
 
590
	public void ajouterObservation() {
600
	public void ajouterObservation() {
591
 
601
 
592
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText());	
602
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
593
		observationMediateur.ajouterObservation(obs);
603
		observationMediateur.ajouterObservation(obs);
594
	}
604
	}
595
	
605
	
596
	private void modifierObservation() {
606
	private void modifierObservation() {
597
		
607
		
598
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText());	
608
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
599
		observationMediateur.modifierObservation(obs,numeroOrdre);
609
		observationMediateur.modifierObservation(obs,numeroOrdre);
600
		
610
		
601
	}
611
	}
-
 
612
	
-
 
613
	private void supprimerObservation() {
-
 
614
		
-
 
615
			observationMediateur.supprimerObservation(this, numeroOrdre);
-
 
616
	}
602
 
617
 
603
	
618
	
604
	public void afficherDetailsObservation(Observation obs)
619
	public void afficherDetailsObservation(Observation obs)
605
	{
620
	{
606
		viderChampsObservation() ;
621
		viderChampsObservation() ;
607
		
622
		
608
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
623
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
609
			String[] dateEtHeure = obs.getDate().split(" ", 2);
624
			String[] dateEtHeure = obs.getDate().split(" ", 2);
610
			date.setRawValue(dateEtHeure[0]) ;
625
			date.setValue(dateEtHeure[0]) ;
611
		}
626
		}
612
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
627
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
613
			lieudit.setValue(obs.getLieudit()) ;
628
			lieudit.setValue(obs.getLieudit()) ;
614
		}
629
		}
615
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
630
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
616
			station.setValue(obs.getStation()) ;
631
			station.setValue(obs.getStation()) ;
617
		}
632
		}
618
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
633
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
619
			milieu.setValue(obs.getMilieu()) ;
634
			milieu.setValue(obs.getMilieu()) ;
620
		}
635
		}
621
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
636
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
622
			comment.setValue(obs.getCommentaire()) ;
637
			comment.setValue(obs.getCommentaire()) ;
623
		}
638
		}
624
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
639
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
625
			commune.setValue(obs.getLocalite()) ;
640
			commune.setValue(obs.getLocalite()) ;
626
		}
641
		}
627
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
642
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
628
			departement = obs.getIdentifiantLocalite();
643
			departement = obs.getIdentifiantLocalite();
629
		}
644
		}
630
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
645
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
631
			espece.setValue(obs.getNomSaisi()) ;
646
			espece.setValue(obs.getNomSaisi()) ;
632
		}
647
		}
633
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
648
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
634
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
649
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
635
		}
650
		}
636
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
651
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
637
			numeroOrdre = obs.getNumeroOrdre() ;
652
			numeroOrdre = obs.getNumeroOrdre() ;
638
		}
653
		}
639
		
654
		
640
	}
655
	}
641
	
656
	
642
	public void viderChampsObservation()
657
	public void viderChampsObservation()
643
	{
658
	{
644
 
659
 
645
		date.reset() ;
660
		date.reset() ;
646
		lieudit.reset() ;
661
		lieudit.reset() ;
647
		station.reset() ;
662
		station.reset() ;
648
		milieu.reset();
663
		milieu.reset();
649
		comment.reset();
664
		comment.reset();
650
		commune.reset();
665
		commune.reset();
651
		departement = "";
666
		departement = "";
652
		espece.reset();
667
		espece.reset();
653
		numeroNom = "" ;
668
		numeroNom = "" ;
654
		numeroOrdre = "";
669
		numeroOrdre = "";
655
		
670
		
656
	}
671
	}
657
	
672
	
658
	private void setModification(String mode)
673
	private void setModification(String mode)
659
	{
674
	{
660
		if(mode.equals("true")) {
675
		if(mode.equals("true")) {
661
 
676
 
662
			boutonOK.setText("Modifier") ;
677
			boutonOK.setText("Modifier") ;
663
			setTitle("Modification") ;
678
			setTitle("Modification") ;
-
 
679
			boutonAnnuler.setText("Supprimer") ;
664
			modification = true ;
680
			modification = true ;
665
		}
681
		}
666
		else
682
		else
667
		{
683
		{
668
 
684
 
669
			boutonOK.setText("Créer") ;
685
			boutonOK.setText("Créer") ;
670
			setTitle("Saisir") ;
686
			setTitle("Saisir") ;
-
 
687
			boutonAnnuler.setText("Réinitialiser") ;
671
			modification = false ;
688
			modification = false ;
672
		}
689
		}
673
		
690
		
674
	}
691
	}
675
	
692
	
676
	
693
	
677
	/**
694
	/**
678
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
695
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
679
	 * @return
696
	 * @return
680
	 */
697
	 */
681
	public boolean getModification()
698
	public boolean getModification()
682
	{
699
	{
683
		return modification ;
700
		return modification ;
684
	}
701
	}
685
	
702
	
686
 
703
 
687
}
704
}