Line 7... |
Line 7... |
7 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
7 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
8 |
import org.tela_botanica.client.modeles.Information;
|
8 |
import org.tela_botanica.client.modeles.Information;
|
9 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
9 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
10 |
import org.tela_botanica.client.modeles.Valeur;
|
10 |
import org.tela_botanica.client.modeles.Valeur;
|
11 |
import org.tela_botanica.client.modeles.collection.Collection;
|
11 |
import org.tela_botanica.client.modeles.collection.Collection;
|
- |
|
12 |
import org.tela_botanica.client.util.Debug;
|
12 |
import org.tela_botanica.client.util.UtilArray;
|
13 |
import org.tela_botanica.client.util.UtilArray;
|
13 |
import org.tela_botanica.client.util.UtilString;
|
14 |
import org.tela_botanica.client.util.UtilString;
|
14 |
import org.tela_botanica.client.vues.Formulaire;
|
15 |
import org.tela_botanica.client.vues.Formulaire;
|
15 |
import org.tela_botanica.client.vues.structure.StructureForm;
|
16 |
import org.tela_botanica.client.vues.structure.StructureForm;
|
Line 71... |
Line 72... |
71 |
|
72 |
|
72 |
nomChp = new TextField<String>();
|
73 |
nomChp = new TextField<String>();
|
73 |
nomChp.setTabIndex(tabIndex++);
|
74 |
nomChp.setTabIndex(tabIndex++);
|
74 |
nomChp.setFieldLabel(i18nC.nomCollection());
|
75 |
nomChp.setFieldLabel(i18nC.nomCollection());
|
- |
|
76 |
nomChp.setAllowBlank(false);
|
- |
|
77 |
nomChp.addStyleName("obligatoire");
|
- |
|
78 |
nomChp.addListener(Events.Change, new Listener<BaseEvent>() {
|
- |
|
79 |
@Override
|
- |
|
80 |
public void handleEvent(BaseEvent be) {
|
- |
|
81 |
nomChp.removeStyleName("obligatoire");
|
- |
|
82 |
nomChp.removeStyleName("obligatoire-ok");
|
- |
|
83 |
if (nomChp.getRawValue().length() != 0) {
|
- |
|
84 |
nomChp.addStyleName("obligatoire-ok");
|
- |
|
85 |
} else if (nomChp.getRawValue().length() == 0) {
|
- |
|
86 |
nomChp.addStyleName("obligatoire");
|
- |
|
87 |
}
|
- |
|
88 |
}
|
75 |
nomChp.setAllowBlank(false);
|
89 |
});
|
76 |
nomChp.getMessages().setBlankText(i18nC.champObligatoire());
|
90 |
nomChp.getMessages().setBlankText(i18nC.champObligatoire());
|
Line 77... |
Line 91... |
77 |
principalFieldSet.add(nomChp, new FormData(450, 0));
|
91 |
principalFieldSet.add(nomChp, new FormData(450, 0));
|
78 |
|
92 |
|
- |
|
93 |
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++);
|
79 |
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++);
|
94 |
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER);
|
80 |
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER);
|
95 |
typesCollectionCombo.addStyleName("obligatoire");
|
81 |
typesCollectionCombo.addListener(Events.Select, new Listener<BaseEvent>() {
|
96 |
typesCollectionCombo.addListener(Events.Select, new Listener<BaseEvent>() {
|
82 |
@Override
|
97 |
@Override
|
- |
|
98 |
public void handleEvent(BaseEvent be) {
|
- |
|
99 |
Valeur valeur = typesCollectionCombo.getValue();
|
83 |
public void handleEvent(BaseEvent be) {
|
100 |
|
84 |
Valeur valeur = typesCollectionCombo.getValue();
|
101 |
// Gestion des onglets en fonction du type de collection
|
85 |
panneauFormulaire.remove(onglets);
|
102 |
panneauFormulaire.remove(onglets);
|
86 |
mediateur.activerChargement("");
|
103 |
mediateur.activerChargement("");
|
87 |
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) {
|
104 |
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) {
|
Line 91... |
Line 108... |
91 |
onglets = creerOngletsDefaut();
|
108 |
onglets = creerOngletsDefaut();
|
92 |
panneauFormulaire.add(onglets);
|
109 |
panneauFormulaire.add(onglets);
|
93 |
}
|
110 |
}
|
94 |
mediateur.desactiverChargement();
|
111 |
mediateur.desactiverChargement();
|
95 |
panneauFormulaire.layout();
|
112 |
panneauFormulaire.layout();
|
- |
|
113 |
|
- |
|
114 |
// Gestion du style obligatoire
|
- |
|
115 |
typesCollectionCombo.removeStyleName("obligatoire");
|
- |
|
116 |
typesCollectionCombo.removeStyleName("obligatoire-ok");
|
- |
|
117 |
if (valeur != null) {
|
- |
|
118 |
typesCollectionCombo.addStyleName("obligatoire-ok");
|
- |
|
119 |
} else {
|
- |
|
120 |
typesCollectionCombo.addStyleName("obligatoire");
|
- |
|
121 |
}
|
96 |
}
|
122 |
}
|
97 |
});
|
123 |
});
|
98 |
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0));
|
124 |
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0));
|
99 |
typesCollectionCombo.fireEvent(Events.Select);
|
125 |
typesCollectionCombo.fireEvent(Events.Select);
|
Line 204... |
Line 230... |
204 |
|
230 |
|
205 |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées
|
231 |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées
|
206 |
personneOnglet.rafraichir(info);
|
232 |
personneOnglet.rafraichir(info);
|
207 |
publicationOnglet.rafraichir(info);
|
233 |
publicationOnglet.rafraichir(info);
|
208 |
} else {
|
234 |
} else {
|
209 |
Info.display("Ajout d'une Institution", info.toString());
|
235 |
Info.display("Ajout d'une collection", info.toString());
|
210 |
}
|
236 |
}
|
211 |
} else if (info.getType().equals("liste_collection_a_personne")) {
|
237 |
} else if (info.getType().equals("liste_collection_a_personne")) {
|
212 |
personneOnglet.rafraichir(info);
|
238 |
personneOnglet.rafraichir(info);
|
213 |
} else if (info.getType().equals("liste_collection_a_publication")) {
|
239 |
} else if (info.getType().equals("liste_collection_a_publication")) {
|
Line 232... |
Line 258... |
232 |
}
|
258 |
}
|
Line 233... |
Line 259... |
233 |
|
259 |
|
234 |
private void actualiserTitrePanneau() {
|
260 |
private void actualiserTitrePanneau() {
|
235 |
String titre = i18nC.titreModifFormCollection();
|
261 |
String titre = i18nC.titreModifFormCollection();
|
236 |
// Composition du titre
|
262 |
// Composition du titre
|
237 |
titre += " - ID : "+collection.getId();
|
263 |
titre += " - "+i18nC.id()+" : "+collection.getId();
|
238 |
panneauFormulaire.setHeading(titre);
|
264 |
panneauFormulaire.setHeading(titre);
|
Line 239... |
Line 265... |
239 |
}
|
265 |
}
|
240 |
|
266 |
|
241 |
public boolean soumettreFormulaire() {
|
267 |
public boolean soumettreFormulaire() {
|
242 |
// Vérification de la validité des champs du formulaire
|
268 |
// Vérification de la validité des champs du formulaire
|
243 |
boolean formulaireValide = verifierFormulaire();
|
269 |
boolean formulaireValide = verifierFormulaire();
|
244 |
if (formulaireValide) {
|
270 |
if (formulaireValide) {
|
245 |
// Collecte des données du formulaire
|
- |
|
246 |
Collection collectionAEnregistrer = collecterCollection();
|
271 |
// Collecte des données du formulaire
|
247 |
|
272 |
Collection collectionAEnregistrer = collecterCollection();
|
- |
|
273 |
if (mode.equals(MODE_AJOUTER)) {
|
248 |
if (mode.equals(MODE_AJOUTER)) {
|
274 |
mediateur.ajouterCollection(this, collectionAEnregistrer);
|
249 |
mediateur.ajouterCollection(this, collectionAEnregistrer);
|
275 |
Debug.log("enfin");
|
250 |
} else if (mode.equals(MODE_MODIFIER)) {
|
276 |
} else if (mode.equals(MODE_MODIFIER)) {
|
251 |
if (collectionAEnregistrer == null) {
|
277 |
if (collectionAEnregistrer == null) {
|
252 |
Info.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
278 |
Info.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
Line 302... |
Line 328... |
302 |
|
328 |
|
303 |
public boolean verifierFormulaire() {
|
329 |
public boolean verifierFormulaire() {
|
Line 304... |
Line 330... |
304 |
ArrayList<String> messages = new ArrayList<String>();
|
330 |
ArrayList<String> messages = new ArrayList<String>();
|
- |
|
331 |
|
- |
|
332 |
// Vérification des infos sur le nom de la collection
|
305 |
|
333 |
if (nomChp.getValue() == null
|
306 |
// Vérification des infos sur le nom de la collection
|
334 |
|| nomChp.getValue().equals("")
|
307 |
if (nomChp.getValue() == null || nomChp.getValue().equals("") || collection.getNom().equals("")) {
|
335 |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
|
Line 308... |
Line 336... |
308 |
messages.add("Veuillez donner un nom à la collection.");
|
336 |
messages.add("Veuillez donner un nom à la collection.");
|
- |
|
337 |
}
|
- |
|
338 |
|
309 |
}
|
339 |
// Vérification des infos sur le type de collection
|
310 |
|
340 |
if (typesCollectionCombo.getValue() == null
|
311 |
// Vérification des infos sur le type de collection
|
341 |
|| typesCollectionCombo.getValue().equals("")
|
Line 312... |
Line 342... |
312 |
if (typesCollectionCombo.getValue() == null || typesCollectionCombo.getValue().equals("") || collection.getIdProjet().equals("")) {
|
342 |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
|