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