150 |
gduche |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
189 |
gduche |
3 |
|
|
|
4 |
|
197 |
gduche |
5 |
import java.util.HashMap;
|
|
|
6 |
import java.util.Iterator;
|
189 |
gduche |
7 |
|
197 |
gduche |
8 |
|
150 |
gduche |
9 |
import org.tela_botanica.client.RegistreId;
|
|
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
11 |
import org.tela_botanica.client.modeles.Personne;
|
|
|
12 |
import org.tela_botanica.client.modeles.StructureListe;
|
|
|
13 |
|
|
|
14 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
15 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
197 |
gduche |
16 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
|
|
17 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
150 |
gduche |
18 |
import com.extjs.gxt.ui.client.util.Params;
|
|
|
19 |
import com.extjs.gxt.ui.client.widget.Html;
|
197 |
gduche |
20 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
189 |
gduche |
21 |
import com.extjs.gxt.ui.client.widget.TabItem;
|
|
|
22 |
import com.extjs.gxt.ui.client.widget.TabPanel;
|
200 |
gduche |
23 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
197 |
gduche |
24 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
200 |
gduche |
25 |
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
197 |
gduche |
26 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
150 |
gduche |
27 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
197 |
gduche |
28 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
|
|
29 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
|
|
30 |
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
|
|
|
31 |
import com.google.gwt.dom.client.LinkElement;
|
|
|
32 |
import com.google.gwt.dom.client.NodeList;
|
|
|
33 |
import com.google.gwt.user.client.Window;
|
189 |
gduche |
34 |
import com.google.gwt.user.client.ui.Hyperlink;
|
197 |
gduche |
35 |
import com.google.gwt.user.client.ui.Image;
|
189 |
gduche |
36 |
import com.google.gwt.user.client.ui.Label;
|
200 |
gduche |
37 |
import com.google.gwt.user.client.ui.TextBox;
|
189 |
gduche |
38 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
39 |
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
150 |
gduche |
40 |
|
189 |
gduche |
41 |
public class PersonneDetailPanneauVue extends TabPanel implements Rafraichissable {
|
150 |
gduche |
42 |
|
197 |
gduche |
43 |
// Le panneau détail se compose de formulaires tabulés
|
189 |
gduche |
44 |
|
197 |
gduche |
45 |
// Onglet 1 : identite & contact
|
|
|
46 |
private TabItem identite;
|
|
|
47 |
private FieldSet fsIdentite;
|
|
|
48 |
private FieldSet fsContact;
|
189 |
gduche |
49 |
|
200 |
gduche |
50 |
// Onglet 2 : Adresses
|
|
|
51 |
private TabItem tabAdresse;
|
|
|
52 |
private FieldSet fsAdressePerso;
|
198 |
gduche |
53 |
// contient : adresse perso / adresse pro
|
|
|
54 |
|
200 |
gduche |
55 |
//TODO : Onglet Info Naturaliste
|
198 |
gduche |
56 |
|
|
|
57 |
// > Se baser sur la présentation thunderBird
|
|
|
58 |
|
|
|
59 |
|
150 |
gduche |
60 |
public PersonneDetailPanneauVue() {
|
189 |
gduche |
61 |
|
198 |
gduche |
62 |
//Constructeur de la classe
|
150 |
gduche |
63 |
Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
|
189 |
gduche |
64 |
setLayout(new FitLayout());
|
150 |
gduche |
65 |
|
197 |
gduche |
66 |
identite = new TabItem("Identité");
|
200 |
gduche |
67 |
identite.setLayout(new TableLayout(2));
|
197 |
gduche |
68 |
identite.setScrollMode(Scroll.AUTO);
|
189 |
gduche |
69 |
|
200 |
gduche |
70 |
/*
|
|
|
71 |
* NOTES : J'ai utilisé un TableLayout pour avoir une présentation ou l'image, si elle existe, soit placée à droite des informations d'identité.
|
|
|
72 |
* Cependant, une imagetrop grande bouleverse la mise en page.
|
|
|
73 |
* Il faut trouver une solution pour fixer ca :
|
|
|
74 |
* - par CSS ?
|
|
|
75 |
* - utiliser un FlexTable ?
|
|
|
76 |
* - utiliser plusieurs panneaux?
|
|
|
77 |
* */
|
|
|
78 |
|
197 |
gduche |
79 |
fsIdentite = new FieldSet();
|
|
|
80 |
fsIdentite.setLayout(new FormLayout());
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
fsContact = new FieldSet();
|
|
|
84 |
fsContact.setLayout(new FormLayout());
|
|
|
85 |
|
|
|
86 |
this.add(identite);
|
|
|
87 |
|
200 |
gduche |
88 |
//Onglet Adresse:
|
|
|
89 |
tabAdresse = new TabItem("Adresses");
|
|
|
90 |
fsAdressePerso = new FieldSet();
|
|
|
91 |
fsAdressePerso.setLayout(new FormLayout());
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
198 |
gduche |
95 |
//TODO : ajouter info naturaliste
|
|
|
96 |
|
150 |
gduche |
97 |
}
|
|
|
98 |
|
|
|
99 |
public void afficherDetailPersonne(Personne personne) {
|
|
|
100 |
if (personne != null) {
|
198 |
gduche |
101 |
|
|
|
102 |
|
|
|
103 |
//MAJ Identité : Configurer les fieldSet
|
197 |
gduche |
104 |
identite.removeAll();
|
150 |
gduche |
105 |
|
197 |
gduche |
106 |
fsIdentite.setHeading("Identité");
|
|
|
107 |
fsIdentite.setWidth("350px");
|
183 |
gduche |
108 |
|
197 |
gduche |
109 |
fsContact.setHeading("Contact");
|
|
|
110 |
fsContact.setWidth("350px");
|
183 |
gduche |
111 |
|
197 |
gduche |
112 |
identite.add(fsIdentite);
|
|
|
113 |
|
198 |
gduche |
114 |
//La personne peut avoir un logo
|
197 |
gduche |
115 |
String logoUrl = (String) personne.obtenirValeurChamp("truk_logo");
|
198 |
gduche |
116 |
|
197 |
gduche |
117 |
if ((logoUrl!=null)&&(!logoUrl.trim().equals(""))) {
|
198 |
gduche |
118 |
//Si c'est le cas, on l'affiche sur la même ligne que fsIdentité
|
197 |
gduche |
119 |
Image img = new Image();
|
|
|
120 |
img.setUrl(logoUrl);
|
200 |
gduche |
121 |
img.setStyleName("logo-personne");
|
198 |
gduche |
122 |
|
|
|
123 |
// FIXME : pour avoir un affichage correct, je force la redimension à 300px. Idéalement, ce serait un max-height qu'il faudrait.
|
|
|
124 |
// FIXME : L'image devrait se mettre sur deux lignes au lieu d'une, ca décale tout ...
|
|
|
125 |
img.setHeight("300px");
|
|
|
126 |
|
197 |
gduche |
127 |
identite.add(img);
|
189 |
gduche |
128 |
|
197 |
gduche |
129 |
} else {
|
198 |
gduche |
130 |
//Sinon, on doit mettre une case vide pour garder une présentation en colonne de fsIdentite & fsContact
|
197 |
gduche |
131 |
identite.add(new Label());
|
189 |
gduche |
132 |
}
|
150 |
gduche |
133 |
|
197 |
gduche |
134 |
identite.add(fsContact);
|
183 |
gduche |
135 |
|
197 |
gduche |
136 |
fsIdentite.removeAll();
|
|
|
137 |
fsContact.removeAll();
|
|
|
138 |
//Ajout des champs Identité
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
// TODO: projet
|
|
|
143 |
|
|
|
144 |
// nom complet
|
|
|
145 |
Object nomComplet = personne.obtenirValeurChamp("fmt_nom_complet");
|
|
|
146 |
ajouterTextFieldNonEditable(fsIdentite,"Nom", nomComplet);
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
// TODO : nom autre
|
|
|
150 |
|
|
|
151 |
// abreviation
|
|
|
152 |
Object abreviation = personne.obtenirValeurChamp("abreviation");
|
|
|
153 |
ajouterTextFieldNonEditable(fsIdentite, "Abreviation", abreviation);
|
|
|
154 |
|
|
|
155 |
// date naissance
|
|
|
156 |
Object dateNaissance = personne.obtenirValeurChamp("date_naissance");
|
|
|
157 |
ajouterTextFieldNonEditable(fsIdentite, "Date de naissance", dateNaissance);
|
|
|
158 |
|
|
|
159 |
// lieu naissance
|
|
|
160 |
Object lieuNaissance = personne.obtenirValeurChamp("lieu_naissance");
|
|
|
161 |
ajouterTextFieldNonEditable(fsIdentite, "Lieu de naissance", lieuNaissance);
|
|
|
162 |
|
|
|
163 |
// date deces
|
|
|
164 |
Object dateDeces = personne.obtenirValeurChamp("date_deces");
|
|
|
165 |
ajouterTextFieldNonEditable(fsIdentite, "Date de décès", dateDeces);
|
|
|
166 |
|
|
|
167 |
// lieu deces
|
|
|
168 |
Object lieuDeces = personne.obtenirValeurChamp("lieu_deces");
|
|
|
169 |
ajouterTextFieldNonEditable(fsIdentite, "Lieu de décès", lieuDeces);
|
|
|
170 |
|
200 |
gduche |
171 |
//Description
|
|
|
172 |
String description = (String) personne.obtenirValeurChamp("description");
|
|
|
173 |
if ((description!=null)&&(!description.trim().equals(""))) {
|
|
|
174 |
TextArea txtDescription = new TextArea();
|
|
|
175 |
txtDescription.setFieldLabel("Description");
|
|
|
176 |
txtDescription.setValue(description);
|
|
|
177 |
|
|
|
178 |
rendreNonEditable(txtDescription);
|
|
|
179 |
|
|
|
180 |
fsIdentite.add(txtDescription);
|
|
|
181 |
}
|
197 |
gduche |
182 |
|
|
|
183 |
|
|
|
184 |
//CONTACT
|
|
|
185 |
|
198 |
gduche |
186 |
//FIXME : courriel est un champ TRUK
|
|
|
187 |
// on doit afficher N entrées
|
200 |
gduche |
188 |
String courriel = (String) personne.obtenirValeurChamp("courriel");
|
197 |
gduche |
189 |
Hyperlink lnkCourriel = new Hyperlink();
|
|
|
190 |
lnkCourriel.setHTML("<b style=\"margin:0 50px 0 0 ; color:black;\">Courriel:</b><a href=\"mailto:" + courriel + "\">" + courriel + "</a>");
|
|
|
191 |
fsContact.add(lnkCourriel);
|
|
|
192 |
|
|
|
193 |
fsContact.addText("<br >");
|
|
|
194 |
|
198 |
gduche |
195 |
|
|
|
196 |
/*
|
|
|
197 |
* Adresses :
|
197 |
gduche |
198 |
String adresse01 = (String) personne.obtenirValeurChamp("adresse_01");
|
|
|
199 |
ajouterTextFieldNonEditable(fsContact, "Adresse", adresse01);
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
String adresse02 = (String) personne.obtenirValeurChamp("adresse_02");
|
|
|
203 |
ajouterTextFieldNonEditable(fsContact, "", adresse02);
|
|
|
204 |
|
|
|
205 |
String boitePostale = (String) personne.obtenirValeurChamp("bp");
|
|
|
206 |
ajouterTextFieldNonEditable(fsContact, "Boite Postale", boitePostale);
|
|
|
207 |
|
|
|
208 |
String codePostal = (String) personne.obtenirValeurChamp("code_postal");
|
|
|
209 |
ajouterTextFieldNonEditable(fsContact, "Code postal", codePostal);
|
|
|
210 |
|
|
|
211 |
String ville = (String) personne.obtenirValeurChamp("ville");
|
|
|
212 |
ajouterTextFieldNonEditable(fsContact, "Ville", ville);
|
|
|
213 |
|
|
|
214 |
String region = (String) personne.obtenirValeurChamp("region");
|
|
|
215 |
ajouterTextFieldNonEditable(fsContact, "Région", region);
|
|
|
216 |
|
|
|
217 |
String pays = (String) personne.obtenirValeurChamp("pays");
|
|
|
218 |
ajouterTextFieldNonEditable(fsContact, "Pays", pays);
|
|
|
219 |
|
198 |
gduche |
220 |
fsContact.addText("<br >"); */
|
197 |
gduche |
221 |
|
|
|
222 |
|
|
|
223 |
|
150 |
gduche |
224 |
layout();
|
197 |
gduche |
225 |
}
|
|
|
226 |
}
|
|
|
227 |
|
200 |
gduche |
228 |
private void ajouterTextFieldNonEditable(FieldSet fs, String tfLabel, Object tfValue) {
|
197 |
gduche |
229 |
|
|
|
230 |
if ((tfValue!=null)&&(!tfValue.toString().trim().equals(""))) {
|
189 |
gduche |
231 |
|
197 |
gduche |
232 |
TextField tf = new TextField();
|
|
|
233 |
|
|
|
234 |
tf.setFieldLabel(tfLabel);
|
|
|
235 |
if ((tfLabel==null)||("".equals(tfLabel))) {
|
|
|
236 |
tf.setHideLabel(true);
|
|
|
237 |
tf.setStyleAttribute("margin", "0 0 0 105px");
|
|
|
238 |
}
|
|
|
239 |
tf.setValue(tfValue);
|
|
|
240 |
|
|
|
241 |
// Non éditable : on empêche l'évènement par défaut
|
200 |
gduche |
242 |
rendreNonEditable(tf);
|
|
|
243 |
|
|
|
244 |
//Ajout au fieldSet
|
|
|
245 |
fs.add(tf);
|
|
|
246 |
}
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
private void rendreNonEditable(Field field) {
|
197 |
gduche |
250 |
|
200 |
gduche |
251 |
field.addKeyListener(new KeyListener() {
|
197 |
gduche |
252 |
public void componentKeyPress(ComponentEvent ev) {
|
|
|
253 |
ev.stopEvent();
|
|
|
254 |
}
|
|
|
255 |
});
|
200 |
gduche |
256 |
}
|
197 |
gduche |
257 |
|
|
|
258 |
|
183 |
gduche |
259 |
public void rafraichir(Object nouvelleDonnees) {
|
|
|
260 |
if (nouvelleDonnees instanceof Personne) {
|
|
|
261 |
afficherDetailPersonne((Personne) nouvelleDonnees);
|
150 |
gduche |
262 |
} else if (nouvelleDonnees instanceof StructureListe) {
|
|
|
263 |
StructureListe listeInstitutions = (StructureListe) nouvelleDonnees;
|
|
|
264 |
// Test pour savoir si la liste contient des éléments
|
|
|
265 |
if (listeInstitutions.size() == 0) {
|
183 |
gduche |
266 |
afficherDetailPersonne(null);
|
150 |
gduche |
267 |
}
|
183 |
gduche |
268 |
}
|
150 |
gduche |
269 |
}
|
|
|
270 |
|
197 |
gduche |
271 |
}
|