| Line 1... |
Line 1... |
| 1 |
package org.tela_botanica.client.vues;
|
1 |
package org.tela_botanica.client.vues;
|
| Line -... |
Line 2... |
| - |
|
2 |
|
| - |
|
3 |
import java.util.Iterator;
|
| 2 |
|
4 |
|
| 3 |
import org.tela_botanica.client.Mediateur;
|
5 |
import org.tela_botanica.client.Mediateur;
|
| 4 |
import org.tela_botanica.client.i18n.Constantes;
|
6 |
import org.tela_botanica.client.i18n.Constantes;
|
| - |
|
7 |
import org.tela_botanica.client.images.Images;
|
| - |
|
8 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
| - |
|
9 |
import org.tela_botanica.client.modeles.Valeur;
|
| Line 5... |
Line 10... |
| 5 |
import org.tela_botanica.client.images.Images;
|
10 |
import org.tela_botanica.client.modeles.ValeurListe;
|
| 6 |
|
11 |
|
| - |
|
12 |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
| 7 |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
13 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
| - |
|
14 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
| - |
|
15 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
| - |
|
16 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
| 8 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
17 |
import com.extjs.gxt.ui.client.event.Events;
|
| 9 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
18 |
import com.extjs.gxt.ui.client.event.Listener;
|
| 10 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
19 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
| 11 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
20 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
| 12 |
import com.extjs.gxt.ui.client.widget.TabItem;
|
21 |
import com.extjs.gxt.ui.client.widget.TabItem;
|
| 13 |
import com.extjs.gxt.ui.client.widget.TabPanel;
|
22 |
import com.extjs.gxt.ui.client.widget.TabPanel;
|
| - |
|
23 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
| - |
|
24 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
| - |
|
25 |
import com.extjs.gxt.ui.client.widget.form.CheckBox;
|
| 14 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
26 |
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
|
| - |
|
27 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
| - |
|
28 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
| - |
|
29 |
import com.extjs.gxt.ui.client.widget.form.Radio;
|
| 15 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
30 |
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
|
| - |
|
31 |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
|
| 16 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
32 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
| - |
|
33 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
| 17 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
34 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
| 18 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
35 |
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
|
| Line 19... |
Line 36... |
| 19 |
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
|
36 |
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
|
| Line 37... |
Line 54... |
| 37 |
|
54 |
|
| 38 |
protected FormPanel panneauFormulaire = null;
|
55 |
protected FormPanel panneauFormulaire = null;
|
| 39 |
protected ButtonBar barreOutilsValidation = null;
|
56 |
protected ButtonBar barreOutilsValidation = null;
|
| Line -... |
Line 57... |
| - |
|
57 |
protected TabPanel onglets = null;
|
| - |
|
58 |
|
| - |
|
59 |
protected String menuIdCourant = null;
|
| 40 |
protected TabPanel onglets = null;
|
60 |
protected static Boolean clicBoutonvalidation = false;
|
| 41 |
|
61 |
|
| 42 |
public Formulaire(Mediateur mediateurCourrant, String modeDeCreation) {
|
62 |
public Formulaire(Mediateur mediateurCourrant, String modeDeCreation) {
|
| 43 |
// Initialisation de variables
|
63 |
// Initialisation de variables
|
| 44 |
mode = modeDeCreation;
|
64 |
mode = modeDeCreation;
|
| Line 56... |
Line 76... |
| 56 |
panneauFormulaire.setIcon(Images.ICONES.formAjouter());
|
76 |
panneauFormulaire.setIcon(Images.ICONES.formAjouter());
|
| 57 |
panneauFormulaire.setCollapsible(false);
|
77 |
panneauFormulaire.setCollapsible(false);
|
| 58 |
panneauFormulaire.setHeading(i18nC.titreAjoutFormStructurePanneau());
|
78 |
panneauFormulaire.setHeading(i18nC.titreAjoutFormStructurePanneau());
|
| 59 |
panneauFormulaire.setButtonAlign(HorizontalAlignment.CENTER);
|
79 |
panneauFormulaire.setButtonAlign(HorizontalAlignment.CENTER);
|
| 60 |
panneauFormulaire.setLayout(new FitLayout());
|
80 |
panneauFormulaire.setLayout(new FitLayout());
|
| - |
|
81 |
|
| - |
|
82 |
creerBarreOutilsValidation();
|
| 61 |
}
|
83 |
}
|
| Line 62... |
Line 84... |
| 62 |
|
84 |
|
| Line 63... |
Line 85... |
| 63 |
protected abstract void creerOnglets();
|
85 |
protected abstract void creerOnglets();
|
| Line 104... |
Line 126... |
| 104 |
bouton.setIcon(icone);
|
126 |
bouton.setIcon(icone);
|
| 105 |
bouton.addSelectionListener(ecouteur);
|
127 |
bouton.addSelectionListener(ecouteur);
|
| Line 106... |
Line 128... |
| 106 |
|
128 |
|
| 107 |
return bouton;
|
129 |
return bouton;
|
| - |
|
130 |
}
|
| - |
|
131 |
|
| - |
|
132 |
protected abstract void soumettreFormulaire();
|
| - |
|
133 |
|
| - |
|
134 |
|
| - |
|
135 |
protected void verifierApresRafraichissement() {
|
| - |
|
136 |
// Si le bouton Valider a été cliqué, nous affichons la liste des structures
|
| - |
|
137 |
if (clicBoutonvalidation) {
|
| - |
|
138 |
mediateur.clicMenu(menuIdCourant);
|
| - |
|
139 |
clicBoutonvalidation = false;
|
| - |
|
140 |
}
|
| - |
|
141 |
}
|
| - |
|
142 |
|
| - |
|
143 |
/** Méthode simplifiant la création de FormLayout.
|
| - |
|
144 |
* Chacun des paramètres peut prendre la valeur null pour utiliser la valeur par défaut.
|
| - |
|
145 |
*
|
| - |
|
146 |
* @param labelWidth largeur des labels.
|
| - |
|
147 |
* @param labelAlign alignement des labels
|
| - |
|
148 |
* @return
|
| - |
|
149 |
*/
|
| - |
|
150 |
protected FormLayout creerFormLayout(Integer labelWidth, LabelAlign labelAlign) {
|
| - |
|
151 |
FormLayout formLayout = new FormLayout();
|
| - |
|
152 |
if (labelWidth != null) {
|
| - |
|
153 |
formLayout.setLabelWidth(labelWidth);
|
| - |
|
154 |
}
|
| - |
|
155 |
if (labelAlign != null) {
|
| - |
|
156 |
formLayout.setLabelAlign(labelAlign);
|
| - |
|
157 |
}
|
| - |
|
158 |
return formLayout;
|
| - |
|
159 |
}
|
| - |
|
160 |
|
| - |
|
161 |
/** Méthode simplifiant la création de bouton radio oui/non
|
| - |
|
162 |
*
|
| - |
|
163 |
* @param listeNom nom de la liste de valeur
|
| - |
|
164 |
* @return
|
| - |
|
165 |
*/
|
| - |
|
166 |
protected RadioGroup creerChoixUniqueRadioGroupe(String groupeNom, String listeNom) {
|
| - |
|
167 |
groupeNom += "_grp";
|
| - |
|
168 |
// NOTE : il semblerait qu'il faille aussi utiliser setName() pour éviter tout problème...
|
| - |
|
169 |
RadioGroup radioGroup = new RadioGroup(groupeNom);
|
| - |
|
170 |
radioGroup.setName(groupeNom);
|
| - |
|
171 |
|
| - |
|
172 |
if (listeNom.equals("ouiNon")) {
|
| - |
|
173 |
ValeurListe ouiNonListe = new ValeurListe();
|
| - |
|
174 |
ouiNonListe.ajouter(new Valeur("1", i18nC.oui(), "NULL", "NULL"));
|
| - |
|
175 |
ouiNonListe.ajouter(new Valeur("0", i18nC.non(), "NULL", "NULL"));
|
| - |
|
176 |
creerChoixUniqueBoutonRadio(radioGroup, ouiNonListe);
|
| - |
|
177 |
}
|
| - |
|
178 |
|
| - |
|
179 |
return radioGroup;
|
| - |
|
180 |
}
|
| - |
|
181 |
|
| - |
|
182 |
protected void creerChoixUniqueBoutonRadio(RadioGroup radioGroupe, ValeurListe listeValeurs) {
|
| - |
|
183 |
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
|
| - |
|
184 |
Valeur val = listeValeurs.get(it.next());
|
| - |
|
185 |
|
| - |
|
186 |
Radio radioBtn = new Radio();
|
| - |
|
187 |
radioBtn.setName(radioGroupe.getName().replace("_grp", ""));
|
| - |
|
188 |
radioBtn.setId(val.getId()+"_"+radioBtn.getName());
|
| - |
|
189 |
radioBtn.setBoxLabel(val.getNom());
|
| - |
|
190 |
radioBtn.setValueAttribute(val.getId());
|
| - |
|
191 |
radioBtn.addListener(Events.Change, new Listener<ComponentEvent>() {
|
| - |
|
192 |
|
| - |
|
193 |
public void handleEvent(ComponentEvent be) {
|
| - |
|
194 |
//Window.alert(((Radio) be.component).getName());
|
| - |
|
195 |
afficherChampSupplementaire(((Radio) be.getComponent()));
|
| - |
|
196 |
}
|
| - |
|
197 |
|
| - |
|
198 |
});
|
| - |
|
199 |
|
| - |
|
200 |
if (! val.getDescription().equals("NULL")) {
|
| - |
|
201 |
radioBtn.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription()));
|
| - |
|
202 |
}
|
| - |
|
203 |
radioGroupe.add(radioBtn);
|
| - |
|
204 |
}
|
| - |
|
205 |
}
|
| - |
|
206 |
|
| - |
|
207 |
protected abstract void afficherChampSupplementaire(Radio radioBtn);
|
| - |
|
208 |
|
| - |
|
209 |
|
| - |
|
210 |
/** Méthode simplifiant la création de choix multiple sous forme de case à cocher.
|
| - |
|
211 |
* Apelle un service retournant la liste des valeurs représentant les cases à cocher.
|
| - |
|
212 |
* Ajoute ou pas un champ "Autre".
|
| - |
|
213 |
*
|
| - |
|
214 |
* @return ContentPanel le panneau contenant les cases à cocher
|
| - |
|
215 |
*/
|
| - |
|
216 |
protected LayoutContainer creerChoixMultipleCp() {
|
| - |
|
217 |
LayoutContainer conteneur = new LayoutContainer();
|
| - |
|
218 |
conteneur.setLayout(creerFormLayout(650, LabelAlign.TOP));
|
| - |
|
219 |
return conteneur;
|
| - |
|
220 |
}
|
| - |
|
221 |
|
| - |
|
222 |
/** Méthode simplifiant la création de choix multiple sous forme de case à cocher.
|
| - |
|
223 |
* Apelle un service retournant la liste des valeurs représentant les cases à cocher.
|
| - |
|
224 |
* Ajoute ou pas un champ "Autre".
|
| - |
|
225 |
*
|
| - |
|
226 |
* @param cp panneau conteant le groupe de case à cocher
|
| - |
|
227 |
* @param cacGroup le groupe de case à cocher
|
| - |
|
228 |
* @param listeValeurs la liste de valeurs à transformer en case à cocher
|
| - |
|
229 |
* @param boolAutreChp booléen indiquant si oui ou non le champ autre doit apparaître
|
| - |
|
230 |
* @return
|
| - |
|
231 |
*/
|
| - |
|
232 |
protected void creerChoixMultipleCac(LayoutContainer cp, final CheckBoxGroup cacGroupe, ValeurListe listeValeurs, final Field<String> autreChp) {
|
| - |
|
233 |
cp.addListener(Events.Hide, new Listener<BaseEvent>() {
|
| - |
|
234 |
|
| - |
|
235 |
public void handleEvent(BaseEvent be) {
|
| - |
|
236 |
cacGroupe.reset();
|
| - |
|
237 |
autreChp.setValue("");
|
| - |
|
238 |
}
|
| - |
|
239 |
|
| - |
|
240 |
});
|
| - |
|
241 |
|
| - |
|
242 |
cacGroupe.setAutoWidth(true);
|
| - |
|
243 |
cacGroupe.setStyleAttribute("padding", "3px");
|
| - |
|
244 |
cacGroupe.setData("liste_id", listeValeurs.getId());
|
| - |
|
245 |
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
|
| - |
|
246 |
Valeur val = listeValeurs.get(it.next());
|
| - |
|
247 |
String nom = val.get("nom");
|
| - |
|
248 |
CheckBox cac = new CheckBox();
|
| - |
|
249 |
cac.setId("val-"+val.getId());
|
| - |
|
250 |
cac.setData("id", val.getId());
|
| - |
|
251 |
cac.setBoxLabel(nom);
|
| - |
|
252 |
if (! val.getDescription().equals("NULL")) {
|
| - |
|
253 |
cac.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription()));
|
| - |
|
254 |
}
|
| - |
|
255 |
cacGroupe.add(cac);
|
| - |
|
256 |
}
|
| - |
|
257 |
cp.add(cacGroupe);
|
| - |
|
258 |
|
| - |
|
259 |
if (autreChp != null) {
|
| - |
|
260 |
// FIXME : éviter le chevauchement du texte des cases à cocher avec le label "Autre" sur les petits écrans
|
| - |
|
261 |
LayoutContainer conteneur = new LayoutContainer();
|
| - |
|
262 |
conteneur.setLayout(creerFormLayout(50, LabelAlign.TOP));
|
| - |
|
263 |
autreChp.setId("autre-"+listeValeurs.getId());
|
| - |
|
264 |
autreChp.setFieldLabel("Autre");
|
| - |
|
265 |
autreChp.setLabelStyle("font-weight:normal;");
|
| - |
|
266 |
conteneur.add(autreChp, new FormData(500, 0));
|
| - |
|
267 |
|
| - |
|
268 |
cp.add(conteneur);
|
| - |
|
269 |
}
|
| - |
|
270 |
cp.layout();
|
| 108 |
}
|
271 |
}
|