| Line 1... |
Line 1... |
| 1 |
package org.tela_botanica.client.vues;
|
1 |
package org.tela_botanica.client.vues;
|
| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| - |
|
3 |
import org.tela_botanica.client.Mediateur;
|
| 3 |
import org.tela_botanica.client.Mediateur;
|
4 |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
|
| - |
|
5 |
import org.tela_botanica.client.composants.ChampMultiValeurs;
|
| 4 |
import org.tela_botanica.client.composants.ChampMultiValeurs;
|
6 |
import org.tela_botanica.client.composants.ConteneurMultiChamps;
|
| 5 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
7 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 6 |
import org.tela_botanica.client.modeles.Collection;
|
8 |
import org.tela_botanica.client.modeles.Collection;
|
| 7 |
import org.tela_botanica.client.modeles.CollectionListe;
|
9 |
import org.tela_botanica.client.modeles.CollectionListe;
|
| 8 |
import org.tela_botanica.client.modeles.Projet;
|
10 |
import org.tela_botanica.client.modeles.Projet;
|
| Line 11... |
Line 13... |
| 11 |
import org.tela_botanica.client.modeles.StructureListe;
|
13 |
import org.tela_botanica.client.modeles.StructureListe;
|
| 12 |
import org.tela_botanica.client.modeles.Valeur;
|
14 |
import org.tela_botanica.client.modeles.Valeur;
|
| 13 |
import org.tela_botanica.client.modeles.ValeurListe;
|
15 |
import org.tela_botanica.client.modeles.ValeurListe;
|
| Line 14... |
Line 16... |
| 14 |
|
16 |
|
| - |
|
17 |
import com.extjs.gxt.ui.client.store.ListStore;
|
| - |
|
18 |
import com.extjs.gxt.ui.client.util.Margins;
|
| - |
|
19 |
import com.extjs.gxt.ui.client.util.Padding;
|
| - |
|
20 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
| - |
|
21 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
| 15 |
import com.extjs.gxt.ui.client.store.ListStore;
|
22 |
import com.extjs.gxt.ui.client.widget.Text;
|
| 16 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
23 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
| 17 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
24 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
| 18 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
25 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
| - |
|
26 |
import com.extjs.gxt.ui.client.widget.form.HiddenField;
|
| - |
|
27 |
import com.extjs.gxt.ui.client.widget.form.LabelField;
|
| 19 |
import com.extjs.gxt.ui.client.widget.form.HiddenField;
|
28 |
import com.extjs.gxt.ui.client.widget.form.NumberField;
|
| 20 |
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
29 |
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
| 21 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
30 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
| - |
|
31 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
| 22 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
32 |
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
|
| - |
|
33 |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
|
| - |
|
34 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
| 23 |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
|
35 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
| - |
|
36 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
| - |
|
37 |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout;
|
| - |
|
38 |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData;
|
| - |
|
39 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
| 24 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
40 |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout.HBoxLayoutAlign;
|
| - |
|
41 |
import com.google.gwt.core.client.GWT;
|
| Line 25... |
Line 42... |
| 25 |
import com.google.gwt.core.client.GWT;
|
42 |
import com.google.gwt.i18n.client.NumberFormat;
|
| Line 26... |
Line 43... |
| 26 |
|
43 |
|
| Line 27... |
Line 44... |
| 27 |
public class CollectionFormGeneral extends FormulaireOnglet implements Rafraichissable {
|
44 |
public class CollectionFormGeneral extends FormulaireOnglet implements Rafraichissable {
|
| 28 |
|
45 |
|
| 29 |
private HiddenField<String> idCollectionChp;
|
46 |
private HiddenField<String> idCollectionChp;
|
| - |
|
47 |
|
| 30 |
|
48 |
private ComboBox<Projet> projetsCombo = null;
|
| 31 |
private ListStore<Projet> projetsStore;
|
49 |
private ComboBox<Structure> structuresCombo = null;
|
| - |
|
50 |
private ComboBox<Collection> collectionsCombo = null;
|
| 32 |
private ComboBox<Projet> projetsCombo;
|
51 |
|
| 33 |
private ComboBox<Structure> structuresCombo;
|
52 |
private FieldSet descriptionFieldSet = null;
|
| 34 |
private ListStore<Structure> structuresStore;
|
53 |
private ComboBox<Valeur> typeDepotCombo = null;
|
| 35 |
private ComboBox<Collection> collectionsCombo;
|
54 |
|
| 36 |
private ListStore<Collection> collectionsStore;
|
55 |
private TextArea lieuCouvertureChp = null;
|
| Line 37... |
Line 56... |
| 37 |
|
56 |
|
| Line 38... |
Line 57... |
| 38 |
private FieldSet descriptionFieldSet;
|
57 |
private ChampComboBoxListeValeurs specimenTypeCombo = null;
|
| 39 |
private ListStore<Valeur> typeDepotStore;
|
58 |
private ChampComboBoxListeValeurs precisionTypeNbreCombo = null;
|
| 40 |
private ComboBox<Valeur> typeDepotCombo;
|
59 |
private NumberField nbreTypeChp = null;
|
| 41 |
|
60 |
|
| Line 49... |
Line 68... |
| 49 |
creerChampsCache();
|
68 |
creerChampsCache();
|
| 50 |
creerFieldsetLiaison();
|
69 |
creerFieldsetLiaison();
|
| 51 |
creerFieldsetAdministratif();
|
70 |
creerFieldsetAdministratif();
|
| 52 |
creerFieldsetDescription();
|
71 |
creerFieldsetDescription();
|
| 53 |
creerFieldsetCouverture();
|
72 |
creerFieldsetCouverture();
|
| - |
|
73 |
creerFieldsetType();
|
| 54 |
}
|
74 |
}
|
| Line 55... |
Line 75... |
| 55 |
|
75 |
|
| 56 |
private void creerChampsCache() {
|
76 |
private void creerChampsCache() {
|
| 57 |
// Champs cachés
|
77 |
// Champs cachés
|
| Line 63... |
Line 83... |
| 63 |
FieldSet liaisonFieldSet = new FieldSet();
|
83 |
FieldSet liaisonFieldSet = new FieldSet();
|
| 64 |
liaisonFieldSet.setHeading(i18nC.liaisonTitreCollection());
|
84 |
liaisonFieldSet.setHeading(i18nC.liaisonTitreCollection());
|
| 65 |
liaisonFieldSet.setCollapsible(true);
|
85 |
liaisonFieldSet.setCollapsible(true);
|
| 66 |
liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
|
86 |
liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
|
| Line 67... |
Line -... |
| 67 |
|
- |
|
| 68 |
projetsStore = new ListStore<Projet>();
|
87 |
|
| 69 |
projetsCombo = new ComboBox<Projet>();
|
88 |
projetsCombo = new ComboBox<Projet>();
|
| 70 |
projetsCombo.setTabIndex(tabIndex++);
|
89 |
projetsCombo.setTabIndex(tabIndex++);
|
| 71 |
projetsCombo.setFieldLabel(i18nC.projetChamp());
|
90 |
projetsCombo.setFieldLabel(i18nC.projetChamp());
|
| 72 |
projetsCombo.setDisplayField("nom");
|
91 |
projetsCombo.setDisplayField("nom");
|
| Line 75... |
Line 94... |
| 75 |
@Override
|
94 |
@Override
|
| 76 |
public String validate(Field<?> field, String value) {
|
95 |
public String validate(Field<?> field, String value) {
|
| 77 |
String retour = null;
|
96 |
String retour = null;
|
| 78 |
if (field.getRawValue().equals("")) {
|
97 |
if (field.getRawValue().equals("")) {
|
| 79 |
field.setValue(null);
|
98 |
field.setValue(null);
|
| 80 |
} else if (projetsStore.findModel("nom", field.getRawValue()) == null) {
|
99 |
} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) {
|
| 81 |
String contenuBrut = field.getRawValue();
|
100 |
String contenuBrut = field.getRawValue();
|
| 82 |
field.setValue(null);
|
101 |
field.setValue(null);
|
| 83 |
field.setRawValue(contenuBrut);
|
102 |
field.setRawValue(contenuBrut);
|
| 84 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
103 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
| 85 |
}
|
104 |
}
|
| 86 |
return retour;
|
105 |
return retour;
|
| 87 |
}
|
106 |
}
|
| 88 |
});
|
107 |
});
|
| 89 |
projetsCombo.setTriggerAction(TriggerAction.ALL);
|
108 |
projetsCombo.setTriggerAction(TriggerAction.ALL);
|
| 90 |
projetsCombo.setStore(projetsStore);
|
109 |
projetsCombo.setStore(new ListStore<Projet>());
|
| 91 |
liaisonFieldSet.add(projetsCombo, new FormData(450, 0));
|
110 |
liaisonFieldSet.add(projetsCombo, new FormData(450, 0));
|
| 92 |
mediateur.selectionnerProjets(this);
|
111 |
mediateur.selectionnerProjets(this);
|
| Line 93... |
Line -... |
| 93 |
|
- |
|
| 94 |
structuresStore = new ListStore<Structure>();
|
112 |
|
| 95 |
structuresCombo = new ComboBox<Structure>();
|
113 |
structuresCombo = new ComboBox<Structure>();
|
| 96 |
structuresCombo.setTabIndex(tabIndex++);
|
114 |
structuresCombo.setTabIndex(tabIndex++);
|
| 97 |
structuresCombo.setFieldLabel(i18nC.lienStructureCollection());
|
115 |
structuresCombo.setFieldLabel(i18nC.lienStructureCollection());
|
| 98 |
structuresCombo.setDisplayField("nom");
|
116 |
structuresCombo.setDisplayField("nom");
|
| Line 101... |
Line 119... |
| 101 |
@Override
|
119 |
@Override
|
| 102 |
public String validate(Field<?> field, String value) {
|
120 |
public String validate(Field<?> field, String value) {
|
| 103 |
String retour = null;
|
121 |
String retour = null;
|
| 104 |
if (field.getRawValue().equals("")) {
|
122 |
if (field.getRawValue().equals("")) {
|
| 105 |
field.setValue(null);
|
123 |
field.setValue(null);
|
| 106 |
} else if (structuresStore.findModel("nom", field.getRawValue()) == null) {
|
124 |
} else if (structuresCombo.getStore().findModel("nom", field.getRawValue()) == null) {
|
| 107 |
String contenuBrut = field.getRawValue();
|
125 |
String contenuBrut = field.getRawValue();
|
| 108 |
field.setValue(null);
|
126 |
field.setValue(null);
|
| 109 |
field.setRawValue(contenuBrut);
|
127 |
field.setRawValue(contenuBrut);
|
| 110 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
128 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
| 111 |
}
|
129 |
}
|
| 112 |
return retour;
|
130 |
return retour;
|
| 113 |
}
|
131 |
}
|
| 114 |
});
|
132 |
});
|
| 115 |
structuresCombo.setTriggerAction(TriggerAction.ALL);
|
133 |
structuresCombo.setTriggerAction(TriggerAction.ALL);
|
| 116 |
structuresCombo.setStore(structuresStore);
|
134 |
structuresCombo.setStore(new ListStore<Structure>());
|
| 117 |
liaisonFieldSet.add(structuresCombo, new FormData(450, 0));
|
135 |
liaisonFieldSet.add(structuresCombo, new FormData(450, 0));
|
| 118 |
mediateur.selectionnerStructureParProjet(this, null);
|
136 |
mediateur.selectionnerStructureParProjet(this, null);
|
| Line 119... |
Line -... |
| 119 |
|
- |
|
| 120 |
collectionsStore = new ListStore<Collection>();
|
137 |
|
| 121 |
collectionsCombo = new ComboBox<Collection>();
|
138 |
collectionsCombo = new ComboBox<Collection>();
|
| 122 |
collectionsCombo.setTabIndex(tabIndex++);
|
139 |
collectionsCombo.setTabIndex(tabIndex++);
|
| 123 |
collectionsCombo.setFieldLabel(i18nC.lienMereCollection());
|
140 |
collectionsCombo.setFieldLabel(i18nC.lienMereCollection());
|
| 124 |
collectionsCombo.setDisplayField("nom");
|
141 |
collectionsCombo.setDisplayField("nom");
|
| Line 127... |
Line 144... |
| 127 |
@Override
|
144 |
@Override
|
| 128 |
public String validate(Field<?> field, String value) {
|
145 |
public String validate(Field<?> field, String value) {
|
| 129 |
String retour = null;
|
146 |
String retour = null;
|
| 130 |
if (field.getRawValue().equals("")) {
|
147 |
if (field.getRawValue().equals("")) {
|
| 131 |
field.setValue(null);
|
148 |
field.setValue(null);
|
| 132 |
} else if (collectionsStore.findModel("nom", field.getRawValue()) == null) {
|
149 |
} else if (collectionsCombo.getStore().findModel("nom", field.getRawValue()) == null) {
|
| 133 |
String contenuBrut = field.getRawValue();
|
150 |
String contenuBrut = field.getRawValue();
|
| 134 |
field.setValue(null);
|
151 |
field.setValue(null);
|
| 135 |
field.setRawValue(contenuBrut);
|
152 |
field.setRawValue(contenuBrut);
|
| 136 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
153 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
| 137 |
}
|
154 |
}
|
| 138 |
GWT.log("Validation : "+field.getRawValue()+"-"+field.getValue(), null);
|
155 |
GWT.log("Validation : "+field.getRawValue()+"-"+field.getValue(), null);
|
| 139 |
return retour;
|
156 |
return retour;
|
| 140 |
}
|
157 |
}
|
| 141 |
});
|
158 |
});
|
| 142 |
collectionsCombo.setTriggerAction(TriggerAction.ALL);
|
159 |
collectionsCombo.setTriggerAction(TriggerAction.ALL);
|
| 143 |
collectionsCombo.setStore(collectionsStore);
|
160 |
collectionsCombo.setStore(new ListStore<Collection>());
|
| 144 |
liaisonFieldSet.add(collectionsCombo, new FormData(450, 0));
|
161 |
liaisonFieldSet.add(collectionsCombo, new FormData(450, 0));
|
| 145 |
mediateur.selectionnerCollectionParProjet(this, null);
|
162 |
mediateur.selectionnerCollectionParProjet(this, null);
|
| Line 146... |
Line 163... |
| 146 |
|
163 |
|
| 147 |
this.add(liaisonFieldSet);
|
164 |
this.add(liaisonFieldSet);
|
| Line 152... |
Line 169... |
| 152 |
FieldSet administratifFieldSet = new FieldSet();
|
169 |
FieldSet administratifFieldSet = new FieldSet();
|
| 153 |
administratifFieldSet.setHeading(i18nC.collectionGeneralTitre());
|
170 |
administratifFieldSet.setHeading(i18nC.collectionGeneralTitre());
|
| 154 |
administratifFieldSet.setCollapsible(true);
|
171 |
administratifFieldSet.setCollapsible(true);
|
| 155 |
administratifFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
|
172 |
administratifFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
|
| Line 156... |
Line -... |
| 156 |
|
- |
|
| 157 |
typeDepotStore = new ListStore<Valeur>();
|
- |
|
| 158 |
typeDepotCombo = new ComboBox<Valeur>();
|
- |
|
| 159 |
typeDepotCombo.setTabIndex(tabIndex++);
|
173 |
|
| 160 |
typeDepotCombo.setFieldLabel(i18nC.typeDepot());
|
- |
|
| 161 |
typeDepotCombo.setDisplayField("nom");
|
- |
|
| 162 |
typeDepotCombo.setForceSelection(true);
|
- |
|
| 163 |
typeDepotCombo.setValidator(new Validator() {
|
- |
|
| 164 |
@Override
|
- |
|
| 165 |
public String validate(Field<?> field, String value) {
|
- |
|
| 166 |
String retour = null;
|
- |
|
| 167 |
if (field.getRawValue().equals("")) {
|
- |
|
| 168 |
field.setValue(null);
|
- |
|
| 169 |
} else if (typeDepotStore.findModel("nom", field.getRawValue()) == null) {
|
- |
|
| 170 |
String contenuBrut = field.getRawValue();
|
- |
|
| 171 |
field.setValue(null);
|
- |
|
| 172 |
field.setRawValue(contenuBrut);
|
- |
|
| 173 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
- |
|
| 174 |
}
|
- |
|
| 175 |
return retour;
|
- |
|
| 176 |
}
|
- |
|
| 177 |
});
|
- |
|
| 178 |
typeDepotCombo.setTriggerAction(TriggerAction.ALL);
|
- |
|
| 179 |
typeDepotCombo.setStore(typeDepotStore);
|
174 |
typeDepotCombo = new ChampComboBoxListeValeurs(i18nC.typeDepot(), "typeDepot", tabIndex++);
|
| 180 |
administratifFieldSet.add(typeDepotCombo, new FormData(250, 0));
|
- |
|
| Line 181... |
Line 175... |
| 181 |
mediateur.obtenirListeValeurEtRafraichir(this, "typeDepot");
|
175 |
administratifFieldSet.add(typeDepotCombo);
|
| 182 |
|
176 |
|
| Line 183... |
Line 177... |
| 183 |
ChampMultiValeurs nomsAlternatifsChp = new ChampMultiValeurs(i18nC.intituleAlternatifCollection());
|
177 |
ChampMultiValeurs nomsAlternatifsChp = new ChampMultiValeurs(i18nC.intituleAlternatifCollection());
|
| Line 225... |
Line 219... |
| 225 |
couvertureFieldSet.add(lieuCouvertureChp, new FormData(550, 0));
|
219 |
couvertureFieldSet.add(lieuCouvertureChp, new FormData(550, 0));
|
| Line 226... |
Line 220... |
| 226 |
|
220 |
|
| 227 |
this.add(couvertureFieldSet);
|
221 |
this.add(couvertureFieldSet);
|
| Line -... |
Line 222... |
| - |
|
222 |
}
|
| - |
|
223 |
|
| - |
|
224 |
private void creerFieldsetType() {
|
| - |
|
225 |
FieldSet typeFieldSet = new FieldSet();
|
| - |
|
226 |
typeFieldSet.setHeading("Spécimens «types»");
|
| - |
|
227 |
typeFieldSet.setCollapsible(true);
|
| - |
|
228 |
typeFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
|
| - |
|
229 |
|
| - |
|
230 |
specimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.specimenTypeCollection(), "onpi", tabIndex++);
|
| - |
|
231 |
typeFieldSet.add(specimenTypeCombo);
|
| - |
|
232 |
|
| - |
|
233 |
ConteneurMultiChamps nbreTypeConteneur = new ConteneurMultiChamps(i18nC.nbreSpecimenTypeCollection());
|
| - |
|
234 |
|
| - |
|
235 |
nbreTypeChp = new NumberField();
|
| - |
|
236 |
nbreTypeChp.setFormat(NumberFormat.getFormat("#"));
|
| - |
|
237 |
nbreTypeConteneur.ajouterChamp(nbreTypeChp, new HBoxLayoutData(new Margins(0, 20, 0, 0)));
|
| - |
|
238 |
|
| - |
|
239 |
precisionTypeNbreCombo = new ChampComboBoxListeValeurs(null, "ea");
|
| - |
|
240 |
precisionTypeNbreCombo.setTrie("id_valeur");
|
| - |
|
241 |
precisionTypeNbreCombo.setEmptyText(i18nC.precisionNbreSpecimenTypeCollectionChpVide());
|
| - |
|
242 |
nbreTypeConteneur.ajouterChamp(precisionTypeNbreCombo);
|
| - |
|
243 |
|
| - |
|
244 |
typeFieldSet.add(nbreTypeConteneur);
|
| - |
|
245 |
|
| - |
|
246 |
classementSpecimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.classementSpecimenTypeCollection(), "typeClassement", tabIndex++);
|
| - |
|
247 |
typeFieldSet.add(classementSpecimenTypeCombo);
|
| - |
|
248 |
|
| - |
|
249 |
Text infoType = new Text(i18nC.specimenTypeCollectionInfo());
|
| - |
|
250 |
typeFieldSet.add(infoType);
|
| - |
|
251 |
|
| - |
|
252 |
this.add(typeFieldSet);
|
| 228 |
}
|
253 |
}
|
| 229 |
|
254 |
|
| 230 |
public void rafraichir(Object nouvellesDonnees) {
|
255 |
public void rafraichir(Object nouvellesDonnees) {
|
| 231 |
if (nouvellesDonnees instanceof ProjetListe) {
|
256 |
if (nouvellesDonnees instanceof ProjetListe) {
|
| 232 |
ProjetListe projets = (ProjetListe) nouvellesDonnees;
|
257 |
ProjetListe projets = (ProjetListe) nouvellesDonnees;
|