12 |
david |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
import java.util.Iterator;
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
import com.google.gwt.user.client.ui.AbsolutePanel;
|
|
|
9 |
import com.google.gwt.user.client.ui.Composite;
|
|
|
10 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
11 |
import com.gwtext.client.widgets.form.TextField;
|
|
|
12 |
|
|
|
13 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
14 |
import org.tela_botanica.client.modeles.ListeReferentielCommune;
|
|
|
15 |
import org.tela_botanica.client.modeles.ReferentielCommune;
|
|
|
16 |
import org.tela_botanica.client.observation.ObservationMediateur;
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Affiche une liste de localite qui peuvent etre selectionnees, retourne la valeur de la localite selectionne et une code associe
|
|
|
20 |
* (gettext et getvalue pour le code associe)
|
|
|
21 |
* Utilise un assistant de saisie asynchrone.
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
public class LocationAssistantVue extends Composite implements Rafraichissable {
|
|
|
25 |
|
|
|
26 |
private AutoCompleteAsyncTextBox autoCompletebox = null;
|
|
|
27 |
//private HorizontalPanel panel = new HorizontalPanel();
|
|
|
28 |
private AbsolutePanel panel = new AbsolutePanel();
|
|
|
29 |
|
|
|
30 |
private TextField textfield = new TextField("Commune","commune",275);
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
private ObservationMediateur observationMediateur = null;
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
public LocationAssistantVue(ObservationMediateur obs) {
|
|
|
38 |
|
|
|
39 |
observationMediateur=obs;
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
autoCompletebox = new AutoCompleteAsyncTextBox(this);
|
|
|
43 |
|
|
|
44 |
// autoCompletebox.setFocus(true); FIXME : ne fonctionne pas
|
|
|
45 |
|
|
|
46 |
|
13 |
david |
47 |
// autoCompletebox.setFournisseurDeDonnees(observationMediateur.obtenirFournisseurReferentielCommune());
|
12 |
david |
48 |
|
|
|
49 |
|
|
|
50 |
panel.add(textfield);
|
|
|
51 |
panel.add(autoCompletebox,0,0);
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
//autoCompletebox.setWidth("100%");
|
|
|
55 |
initWidget(panel);
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
public String getText() {
|
|
|
62 |
return autoCompletebox.getText();
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
public void setText(String str) {
|
|
|
67 |
autoCompletebox.setText(str);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public void setValue(String value) {
|
|
|
71 |
autoCompletebox.setValue(value);
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public String getValue() {
|
|
|
75 |
return autoCompletebox.getValue();
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
// si l'on a reçu une liste d'observation
|
|
|
83 |
if(nouvelleDonnees instanceof ListeReferentielCommune) {
|
|
|
84 |
|
|
|
85 |
ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
// on la parse et on récupère les informations quiç nous interessent
|
|
|
89 |
for (Iterator it = data.keySet().iterator(); it.hasNext();)
|
|
|
90 |
{
|
|
|
91 |
|
|
|
92 |
ReferentielCommune com=(ReferentielCommune) data.get(it.next());
|
|
|
93 |
|
|
|
94 |
autoCompletebox.addItem(com.getCommune(),com.getDepartement());
|
|
|
95 |
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
autoCompletebox.displayList();
|
|
|
99 |
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
}
|
|
|
107 |
|