1 |
package org.tela_botanica.client.vues.collection;
|
1 |
package org.tela_botanica.client.vues.collection;
|
2 |
|
2 |
|
3 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
4 |
|
4 |
|
5 |
import org.tela_botanica.client.ComposantClass;
|
5 |
import org.tela_botanica.client.ComposantClass;
|
6 |
import org.tela_botanica.client.Mediateur;
|
6 |
import org.tela_botanica.client.Mediateur;
|
7 |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
|
7 |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
|
8 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
8 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
9 |
import org.tela_botanica.client.modeles.Information;
|
9 |
import org.tela_botanica.client.modeles.Information;
|
10 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
10 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
11 |
import org.tela_botanica.client.modeles.Valeur;
|
11 |
import org.tela_botanica.client.modeles.Valeur;
|
12 |
import org.tela_botanica.client.modeles.collection.Collection;
|
12 |
import org.tela_botanica.client.modeles.collection.Collection;
|
13 |
import org.tela_botanica.client.util.Debug;
|
13 |
import org.tela_botanica.client.util.Debug;
|
14 |
import org.tela_botanica.client.util.UtilArray;
|
14 |
import org.tela_botanica.client.util.UtilArray;
|
15 |
import org.tela_botanica.client.util.UtilString;
|
15 |
import org.tela_botanica.client.util.UtilString;
|
16 |
import org.tela_botanica.client.vues.Formulaire;
|
16 |
import org.tela_botanica.client.vues.Formulaire;
|
17 |
import org.tela_botanica.client.vues.structure.StructureForm;
|
17 |
import org.tela_botanica.client.vues.structure.StructureForm;
|
18 |
|
18 |
|
19 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
19 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
20 |
import com.extjs.gxt.ui.client.event.Events;
|
20 |
import com.extjs.gxt.ui.client.event.Events;
|
21 |
import com.extjs.gxt.ui.client.event.Listener;
|
21 |
import com.extjs.gxt.ui.client.event.Listener;
|
22 |
import com.extjs.gxt.ui.client.widget.Info;
|
22 |
import com.extjs.gxt.ui.client.widget.Info;
|
23 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
23 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
24 |
import com.extjs.gxt.ui.client.widget.TabItem;
|
24 |
import com.extjs.gxt.ui.client.widget.TabItem;
|
25 |
import com.extjs.gxt.ui.client.widget.TabPanel;
|
25 |
import com.extjs.gxt.ui.client.widget.TabPanel;
|
26 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
26 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
27 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
27 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
28 |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
|
28 |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
|
29 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
29 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
30 |
import com.google.gwt.core.client.GWT;
|
30 |
import com.google.gwt.core.client.GWT;
|
31 |
|
31 |
|
32 |
public class CollectionForm extends Formulaire implements Rafraichissable {
|
32 |
public class CollectionForm extends Formulaire implements Rafraichissable {
|
33 |
|
33 |
|
34 |
protected Collection collection = null;
|
34 |
protected Collection collection = null;
|
35 |
protected Collection collectionCollectee = null;
|
35 |
protected Collection collectionCollectee = null;
|
36 |
|
36 |
|
37 |
private ChampComboBoxListeValeurs typesCollectionCombo = null;
|
37 |
private ChampComboBoxListeValeurs typesCollectionCombo = null;
|
38 |
|
38 |
|
39 |
private TabPanel onglets = null;
|
39 |
private TabPanel onglets = null;
|
40 |
private CollectionFormGeneral generalOnglet = null;
|
40 |
private CollectionFormGeneral generalOnglet = null;
|
41 |
private CollectionFormPersonne personneOnglet = null;
|
41 |
private CollectionFormPersonne personneOnglet = null;
|
42 |
private CollectionFormPublication publicationOnglet = null;
|
42 |
private CollectionFormPublication publicationOnglet = null;
|
43 |
private CollectionFormDescription descriptionOnglet = null;
|
43 |
private CollectionFormDescription descriptionOnglet = null;
|
44 |
private CollectionFormContenu contenuOnglet = null;
|
44 |
private CollectionFormContenu contenuOnglet = null;
|
45 |
private CollectionFormInventaire inventaireOnglet = null;
|
45 |
private CollectionFormInventaire inventaireOnglet = null;
|
- |
|
46 |
private CollectionFormCommentaire commentaireOnglet = null;
|
46 |
private TextField<String> nomChp = null;
|
47 |
private TextField<String> nomChp = null;
|
47 |
|
48 |
|
48 |
public CollectionForm(Mediateur mediateurCourrant, String collectionId) {
|
49 |
public CollectionForm(Mediateur mediateurCourrant, String collectionId) {
|
49 |
initialiserCollectionForm(mediateurCourrant, collectionId);
|
50 |
initialiserCollectionForm(mediateurCourrant, collectionId);
|
50 |
}
|
51 |
}
|
51 |
|
52 |
|
52 |
private void initialiserCollectionForm(Mediateur mediateurCourrant, String collectionId) {
|
53 |
private void initialiserCollectionForm(Mediateur mediateurCourrant, String collectionId) {
|
53 |
collection = new Collection();
|
54 |
collection = new Collection();
|
54 |
collection.setId(collectionId);
|
55 |
collection.setId(collectionId);
|
55 |
|
56 |
|
56 |
String modeDeCreation = (UtilString.isEmpty(collection.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
57 |
String modeDeCreation = (UtilString.isEmpty(collection.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
57 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION);
|
58 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION);
|
58 |
|
59 |
|
59 |
creerFieldsetPrincipal();
|
60 |
creerFieldsetPrincipal();
|
60 |
|
61 |
|
61 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
62 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
62 |
mediateurCourrant.selectionnerCollection(this, collectionId);
|
63 |
mediateurCourrant.selectionnerCollection(this, collectionId);
|
63 |
mediateurCourrant.selectionnerCollectionAPersonne(this, collectionId, null);
|
64 |
mediateurCourrant.selectionnerCollectionAPersonne(this, collectionId, null);
|
64 |
mediateurCourrant.selectionnerCollectionAPublication(this, collectionId);
|
65 |
mediateurCourrant.selectionnerCollectionAPublication(this, collectionId);
|
- |
|
66 |
mediateurCourrant.selectionnerCollectionACommentaire(this, collectionId);
|
65 |
}
|
67 |
}
|
66 |
}
|
68 |
}
|
67 |
|
69 |
|
68 |
private void creerFieldsetPrincipal() {
|
70 |
private void creerFieldsetPrincipal() {
|
69 |
FieldSet principalFieldSet = new FieldSet();
|
71 |
FieldSet principalFieldSet = new FieldSet();
|
70 |
principalFieldSet.setHeading("Info");
|
72 |
principalFieldSet.setHeading("Info");
|
71 |
principalFieldSet.setCollapsible(true);
|
73 |
principalFieldSet.setCollapsible(true);
|
72 |
principalFieldSet.setLayout(Formulaire.creerFormLayout(150, LabelAlign.LEFT));
|
74 |
principalFieldSet.setLayout(Formulaire.creerFormLayout(150, LabelAlign.LEFT));
|
73 |
|
75 |
|
74 |
nomChp = new TextField<String>();
|
76 |
nomChp = new TextField<String>();
|
75 |
nomChp.setTabIndex(tabIndex++);
|
77 |
nomChp.setTabIndex(tabIndex++);
|
76 |
nomChp.setFieldLabel(i18nC.nomCollection());
|
78 |
nomChp.setFieldLabel(i18nC.nomCollection());
|
77 |
nomChp.setAllowBlank(false);
|
79 |
nomChp.setAllowBlank(false);
|
78 |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
80 |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
79 |
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
81 |
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
80 |
nomChp.getMessages().setBlankText(i18nC.champObligatoire());
|
82 |
nomChp.getMessages().setBlankText(i18nC.champObligatoire());
|
81 |
principalFieldSet.add(nomChp, new FormData(450, 0));
|
83 |
principalFieldSet.add(nomChp, new FormData(450, 0));
|
82 |
|
84 |
|
83 |
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++);
|
85 |
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++);
|
84 |
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER);
|
86 |
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER);
|
85 |
typesCollectionCombo.addStyleName(ComposantClass.OBLIGATOIRE);
|
87 |
typesCollectionCombo.addStyleName(ComposantClass.OBLIGATOIRE);
|
86 |
typesCollectionCombo.addListener(Events.Select, new Listener<BaseEvent>() {
|
88 |
typesCollectionCombo.addListener(Events.Select, new Listener<BaseEvent>() {
|
87 |
@Override
|
89 |
@Override
|
88 |
public void handleEvent(BaseEvent be) {
|
90 |
public void handleEvent(BaseEvent be) {
|
89 |
Valeur valeur = typesCollectionCombo.getValue();
|
91 |
Valeur valeur = typesCollectionCombo.getValue();
|
90 |
|
92 |
|
91 |
// Gestion des onglets en fonction du type de collection
|
93 |
// Gestion des onglets en fonction du type de collection
|
92 |
panneauFormulaire.remove(onglets);
|
94 |
panneauFormulaire.remove(onglets);
|
93 |
mediateur.activerChargement("");
|
95 |
mediateur.activerChargement("");
|
94 |
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) {
|
96 |
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) {
|
95 |
onglets = creerOngletsHerbier();
|
97 |
onglets = creerOngletsHerbier();
|
96 |
panneauFormulaire.add(onglets);
|
98 |
panneauFormulaire.add(onglets);
|
97 |
} else {
|
99 |
} else {
|
98 |
onglets = creerOngletsDefaut();
|
100 |
onglets = creerOngletsDefaut();
|
99 |
panneauFormulaire.add(onglets);
|
101 |
panneauFormulaire.add(onglets);
|
100 |
}
|
102 |
}
|
101 |
mediateur.desactiverChargement();
|
103 |
mediateur.desactiverChargement();
|
102 |
panneauFormulaire.layout();
|
104 |
panneauFormulaire.layout();
|
103 |
}
|
105 |
}
|
104 |
});
|
106 |
});
|
105 |
typesCollectionCombo.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
107 |
typesCollectionCombo.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
106 |
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0));
|
108 |
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0));
|
107 |
typesCollectionCombo.fireEvent(Events.Select);
|
109 |
typesCollectionCombo.fireEvent(Events.Select);
|
108 |
|
110 |
|
109 |
panneauFormulaire.setTopComponent(principalFieldSet);
|
111 |
panneauFormulaire.setTopComponent(principalFieldSet);
|
110 |
}
|
112 |
}
|
111 |
|
113 |
|
112 |
protected TabPanel creerOngletsDefaut() {
|
114 |
protected TabPanel creerOngletsDefaut() {
|
113 |
TabPanel ongletsCollectionDefaut = new TabPanel();
|
115 |
TabPanel ongletsCollectionDefaut = new TabPanel();
|
114 |
|
116 |
|
115 |
// Onlget formulaire GENERAL
|
117 |
// Onlget formulaire GENERAL
|
116 |
ongletsCollectionDefaut.add(creerOngletGeneral());
|
118 |
ongletsCollectionDefaut.add(creerOngletGeneral());
|
117 |
|
119 |
|
118 |
// Onlget formulaire AUTEUR
|
120 |
// Onlget formulaire AUTEUR
|
119 |
ongletsCollectionDefaut.add(creerOngletPersonne());
|
121 |
ongletsCollectionDefaut.add(creerOngletPersonne());
|
120 |
|
122 |
|
121 |
return ongletsCollectionDefaut;
|
123 |
return ongletsCollectionDefaut;
|
122 |
}
|
124 |
}
|
123 |
|
125 |
|
124 |
protected TabPanel creerOngletsHerbier() {
|
126 |
protected TabPanel creerOngletsHerbier() {
|
125 |
TabPanel ongletsCollectionHerbier = new TabPanel();
|
127 |
TabPanel ongletsCollectionHerbier = new TabPanel();
|
126 |
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner)
|
128 |
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner)
|
127 |
ongletsCollectionHerbier.setHeight("100%");
|
129 |
ongletsCollectionHerbier.setHeight("100%");
|
128 |
|
130 |
|
129 |
// Onlget formulaire GENERAL
|
131 |
// Onlget formulaire GENERAL
|
130 |
ongletsCollectionHerbier.add(creerOngletGeneral());
|
132 |
ongletsCollectionHerbier.add(creerOngletGeneral());
|
131 |
|
133 |
|
132 |
// Onlget formulaire AUTEUR
|
134 |
// Onlget formulaire AUTEUR
|
133 |
ongletsCollectionHerbier.add(creerOngletPersonne());
|
135 |
ongletsCollectionHerbier.add(creerOngletPersonne());
|
134 |
|
136 |
|
135 |
// Onlget formulaire PUBLICATION
|
137 |
// Onlget formulaire PUBLICATION
|
136 |
ongletsCollectionHerbier.add(creerOngletPublication());
|
138 |
ongletsCollectionHerbier.add(creerOngletPublication());
|
137 |
|
139 |
|
138 |
// Onlget formulaire DESCRIPTION
|
140 |
// Onlget formulaire DESCRIPTION
|
139 |
ongletsCollectionHerbier.add(creerOngletDescription());
|
141 |
ongletsCollectionHerbier.add(creerOngletDescription());
|
140 |
|
142 |
|
141 |
// Onlget formulaire CONTENU
|
143 |
// Onlget formulaire CONTENU
|
142 |
ongletsCollectionHerbier.add(creerOngletContenu());
|
144 |
ongletsCollectionHerbier.add(creerOngletContenu());
|
143 |
|
145 |
|
144 |
// Onlget formulaire INVENTAIRE
|
146 |
// Onlget formulaire INVENTAIRE
|
145 |
ongletsCollectionHerbier.add(creerOngletInventaire());
|
147 |
ongletsCollectionHerbier.add(creerOngletInventaire());
|
- |
|
148 |
|
- |
|
149 |
// Onlget formulaire COMMENTAIRE
|
- |
|
150 |
ongletsCollectionHerbier.add(creerOngletCommentaire());
|
146 |
|
151 |
|
147 |
// Sélection de l'onglet par défaut
|
152 |
// Sélection de l'onglet par défaut
|
148 |
ongletsCollectionHerbier.setSelection(generalOnglet);
|
153 |
ongletsCollectionHerbier.setSelection(generalOnglet);
|
149 |
|
154 |
|
150 |
return ongletsCollectionHerbier;
|
155 |
return ongletsCollectionHerbier;
|
151 |
}
|
156 |
}
|
152 |
|
157 |
|
153 |
private TabItem creerOngletGeneral() {
|
158 |
private TabItem creerOngletGeneral() {
|
154 |
generalOnglet = new CollectionFormGeneral(this);
|
159 |
generalOnglet = new CollectionFormGeneral(this);
|
155 |
return generalOnglet;
|
160 |
return generalOnglet;
|
156 |
}
|
161 |
}
|
157 |
|
162 |
|
158 |
private TabItem creerOngletPersonne() {
|
163 |
private TabItem creerOngletPersonne() {
|
159 |
personneOnglet = new CollectionFormPersonne(this);
|
164 |
personneOnglet = new CollectionFormPersonne(this);
|
160 |
return personneOnglet;
|
165 |
return personneOnglet;
|
161 |
}
|
166 |
}
|
162 |
|
167 |
|
163 |
private TabItem creerOngletPublication() {
|
168 |
private TabItem creerOngletPublication() {
|
164 |
publicationOnglet = new CollectionFormPublication(this);
|
169 |
publicationOnglet = new CollectionFormPublication(this);
|
165 |
return publicationOnglet;
|
170 |
return publicationOnglet;
|
166 |
}
|
171 |
}
|
167 |
|
172 |
|
168 |
private TabItem creerOngletDescription() {
|
173 |
private TabItem creerOngletDescription() {
|
169 |
descriptionOnglet = new CollectionFormDescription(this);
|
174 |
descriptionOnglet = new CollectionFormDescription(this);
|
170 |
return descriptionOnglet;
|
175 |
return descriptionOnglet;
|
171 |
}
|
176 |
}
|
172 |
|
177 |
|
173 |
private TabItem creerOngletContenu() {
|
178 |
private TabItem creerOngletContenu() {
|
174 |
contenuOnglet = new CollectionFormContenu(this);
|
179 |
contenuOnglet = new CollectionFormContenu(this);
|
175 |
return contenuOnglet;
|
180 |
return contenuOnglet;
|
176 |
}
|
181 |
}
|
177 |
|
182 |
|
178 |
private TabItem creerOngletInventaire() {
|
183 |
private TabItem creerOngletInventaire() {
|
179 |
inventaireOnglet = new CollectionFormInventaire(this);
|
184 |
inventaireOnglet = new CollectionFormInventaire(this);
|
180 |
return inventaireOnglet;
|
185 |
return inventaireOnglet;
|
181 |
}
|
186 |
}
|
- |
|
187 |
|
- |
|
188 |
private TabItem creerOngletCommentaire() {
|
- |
|
189 |
commentaireOnglet = new CollectionFormCommentaire(this);
|
- |
|
190 |
return commentaireOnglet;
|
- |
|
191 |
}
|
182 |
|
192 |
|
183 |
public void rafraichir(Object nouvellesDonnees) {
|
193 |
public void rafraichir(Object nouvellesDonnees) {
|
184 |
if (nouvellesDonnees instanceof Information) {
|
194 |
if (nouvellesDonnees instanceof Information) {
|
185 |
Information info = (Information) nouvellesDonnees;
|
195 |
Information info = (Information) nouvellesDonnees;
|
186 |
rafraichirInformation(info);
|
196 |
rafraichirInformation(info);
|
187 |
} else {
|
197 |
} else {
|
188 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
198 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
189 |
}
|
199 |
}
|
190 |
|
200 |
|
191 |
controlerFermetureApresRafraichissement();
|
201 |
controlerFermetureApresRafraichissement();
|
192 |
}
|
202 |
}
|
193 |
|
203 |
|
194 |
private void rafraichirInformation(Information info) {
|
204 |
private void rafraichirInformation(Information info) {
|
195 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
205 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
196 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
206 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
197 |
}
|
207 |
}
|
198 |
|
208 |
|
199 |
if (info.getType().equals("modif_collection")) {
|
209 |
if (info.getType().equals("modif_collection")) {
|
200 |
Info.display("Modification d'une collection", info.toString());
|
210 |
Info.display("Modification d'une collection", info.toString());
|
201 |
} else if (info.getType().equals("selection_collection")) {
|
211 |
} else if (info.getType().equals("selection_collection")) {
|
202 |
Info.display("Modification d'une collection", info.toString());
|
212 |
Info.display("Modification d'une collection", info.toString());
|
203 |
if (info.getDonnee(0) != null) {
|
213 |
if (info.getDonnee(0) != null) {
|
204 |
collection = (Collection) info.getDonnee(0);
|
214 |
collection = (Collection) info.getDonnee(0);
|
205 |
}
|
215 |
}
|
206 |
peupler();
|
216 |
peupler();
|
207 |
actualiserTitrePanneau();
|
217 |
actualiserTitrePanneau();
|
208 |
} else if (info.getType().equals("ajout_collection")) {
|
218 |
} else if (info.getType().equals("ajout_collection")) {
|
209 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
219 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
210 |
String collectionId = (String) info.getDonnee(0);
|
220 |
String collectionId = (String) info.getDonnee(0);
|
211 |
Info.display("Ajout d'une collection", "La collection '"+collectionId+"' a bien été ajoutée");
|
221 |
Info.display("Ajout d'une collection", "La collection '"+collectionId+"' a bien été ajoutée");
|
212 |
|
222 |
|
213 |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées
|
223 |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées
|
214 |
personneOnglet.rafraichir(info);
|
224 |
personneOnglet.rafraichir(info);
|
215 |
publicationOnglet.rafraichir(info);
|
225 |
publicationOnglet.rafraichir(info);
|
216 |
} else {
|
226 |
} else {
|
217 |
Info.display("Ajout d'une collection", info.toString());
|
227 |
Info.display("Ajout d'une collection", info.toString());
|
218 |
}
|
228 |
}
|
219 |
} else if (info.getType().equals("liste_collection_a_personne")) {
|
229 |
} else if (info.getType().equals("liste_collection_a_personne")) {
|
220 |
personneOnglet.rafraichir(info);
|
230 |
personneOnglet.rafraichir(info);
|
221 |
} else if (info.getType().equals("liste_collection_a_publication")) {
|
231 |
} else if (info.getType().equals("liste_collection_a_publication")) {
|
222 |
publicationOnglet.rafraichir(info);
|
232 |
publicationOnglet.rafraichir(info);
|
- |
|
233 |
} else if (info.getType().equals("liste_collection_a_commentaire")) {
|
- |
|
234 |
commentaireOnglet.rafraichir(info);
|
223 |
}
|
235 |
}
|
224 |
}
|
236 |
}
|
225 |
|
237 |
|
226 |
private void peupler() {
|
238 |
private void peupler() {
|
227 |
if (collection != null) {
|
239 |
if (collection != null) {
|
228 |
nomChp.setValue(collection.getNom());
|
240 |
nomChp.setValue(collection.getNom());
|
229 |
typesCollectionCombo.peupler(collection.getTypeNcd());
|
241 |
typesCollectionCombo.peupler(collection.getTypeNcd());
|
230 |
|
242 |
|
231 |
peuplerOnglets();
|
243 |
peuplerOnglets();
|
232 |
}
|
244 |
}
|
233 |
}
|
245 |
}
|
234 |
|
246 |
|
235 |
private void peuplerOnglets() {
|
247 |
private void peuplerOnglets() {
|
236 |
generalOnglet.peupler();
|
248 |
generalOnglet.peupler();
|
237 |
descriptionOnglet.peupler();
|
249 |
descriptionOnglet.peupler();
|
238 |
contenuOnglet.peupler();
|
250 |
contenuOnglet.peupler();
|
239 |
inventaireOnglet.peupler();
|
251 |
inventaireOnglet.peupler();
|
- |
|
252 |
commentaireOnglet.peupler();
|
240 |
}
|
253 |
}
|
241 |
|
254 |
|
242 |
private void actualiserTitrePanneau() {
|
255 |
private void actualiserTitrePanneau() {
|
243 |
String titre = i18nC.titreModifFormCollection();
|
256 |
String titre = i18nC.titreModifFormCollection();
|
244 |
// Composition du titre
|
257 |
// Composition du titre
|
245 |
titre += " - "+i18nC.id()+" : "+collection.getId();
|
258 |
titre += " - "+i18nC.id()+" : "+collection.getId();
|
246 |
panneauFormulaire.setHeading(titre);
|
259 |
panneauFormulaire.setHeading(titre);
|
247 |
}
|
260 |
}
|
248 |
|
261 |
|
249 |
public boolean soumettreFormulaire() {
|
262 |
public boolean soumettreFormulaire() {
|
250 |
// Vérification de la validité des champs du formulaire
|
263 |
// Vérification de la validité des champs du formulaire
|
251 |
boolean formulaireValide = verifierFormulaire();
|
264 |
boolean formulaireValide = verifierFormulaire();
|
252 |
if (formulaireValide) {
|
265 |
if (formulaireValide) {
|
253 |
// Collecte des données du formulaire
|
266 |
// Collecte des données du formulaire
|
254 |
Collection collectionAEnregistrer = collecterCollection();
|
267 |
Collection collectionAEnregistrer = collecterCollection();
|
255 |
if (mode.equals(MODE_AJOUTER)) {
|
268 |
if (mode.equals(MODE_AJOUTER)) {
|
256 |
mediateur.ajouterCollection(this, collectionAEnregistrer);
|
269 |
mediateur.ajouterCollection(this, collectionAEnregistrer);
|
257 |
Debug.log("enfin");
|
270 |
Debug.log("enfin");
|
258 |
} else if (mode.equals(MODE_MODIFIER)) {
|
271 |
} else if (mode.equals(MODE_MODIFIER)) {
|
259 |
if (collectionAEnregistrer == null) {
|
272 |
if (collectionAEnregistrer == null) {
|
260 |
Info.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
273 |
Info.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
261 |
} else {
|
274 |
} else {
|
262 |
mediateur.modifierCollection(this, collectionAEnregistrer);
|
275 |
mediateur.modifierCollection(this, collectionAEnregistrer);
|
263 |
}
|
276 |
}
|
264 |
}
|
277 |
}
|
265 |
|
278 |
|
266 |
soumettreOnglets();
|
279 |
soumettreOnglets();
|
267 |
}
|
280 |
}
|
268 |
return formulaireValide;
|
281 |
return formulaireValide;
|
269 |
}
|
282 |
}
|
270 |
|
283 |
|
271 |
private void soumettreOnglets() {
|
284 |
private void soumettreOnglets() {
|
272 |
personneOnglet.soumettre();
|
285 |
personneOnglet.soumettre();
|
273 |
publicationOnglet.soumettre();
|
286 |
publicationOnglet.soumettre();
|
- |
|
287 |
commentaireOnglet.soumettre();
|
274 |
}
|
288 |
}
|
275 |
|
289 |
|
276 |
public void reinitialiserFormulaire() {
|
290 |
public void reinitialiserFormulaire() {
|
277 |
if (mode.equals(StructureForm.MODE_MODIFIER)) {
|
291 |
if (mode.equals(StructureForm.MODE_MODIFIER)) {
|
278 |
mediateur.afficherFormCollection(collection.getId());
|
292 |
mediateur.afficherFormCollection(collection.getId());
|
279 |
} else {
|
293 |
} else {
|
280 |
mediateur.afficherFormCollection(null);
|
294 |
mediateur.afficherFormCollection(null);
|
281 |
}
|
295 |
}
|
282 |
}
|
296 |
}
|
283 |
|
297 |
|
284 |
private Collection collecterCollection() {
|
298 |
private Collection collecterCollection() {
|
285 |
collectionCollectee = (Collection) collection.cloner(new Collection());
|
299 |
collectionCollectee = (Collection) collection.cloner(new Collection());
|
286 |
|
300 |
|
287 |
this.collecter();
|
301 |
this.collecter();
|
288 |
collecterOnglets();
|
302 |
collecterOnglets();
|
289 |
|
303 |
|
290 |
Collection collectionARetourner = null;
|
304 |
Collection collectionARetourner = null;
|
291 |
if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) {
|
305 |
if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) {
|
292 |
collectionARetourner = collection = collectionCollectee;
|
306 |
collectionARetourner = collection = collectionCollectee;
|
293 |
}
|
307 |
}
|
294 |
return collectionARetourner;
|
308 |
return collectionARetourner;
|
295 |
}
|
309 |
}
|
296 |
|
310 |
|
297 |
private void collecter() {
|
311 |
private void collecter() {
|
298 |
collectionCollectee.setNom(nomChp.getValue());
|
312 |
collectionCollectee.setNom(nomChp.getValue());
|
299 |
collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
|
313 |
collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
|
300 |
}
|
314 |
}
|
301 |
|
315 |
|
302 |
private void collecterOnglets() {
|
316 |
private void collecterOnglets() {
|
303 |
generalOnglet.collecter();
|
317 |
generalOnglet.collecter();
|
304 |
personneOnglet.collecter();
|
318 |
personneOnglet.collecter();
|
305 |
publicationOnglet.collecter();
|
319 |
publicationOnglet.collecter();
|
306 |
descriptionOnglet.collecter();
|
320 |
descriptionOnglet.collecter();
|
307 |
contenuOnglet.collecter();
|
321 |
contenuOnglet.collecter();
|
308 |
inventaireOnglet.collecter();
|
322 |
inventaireOnglet.collecter();
|
- |
|
323 |
commentaireOnglet.collecter();
|
309 |
}
|
324 |
}
|
310 |
|
325 |
|
311 |
public boolean verifierFormulaire() {
|
326 |
public boolean verifierFormulaire() {
|
312 |
ArrayList<String> messages = new ArrayList<String>();
|
327 |
ArrayList<String> messages = new ArrayList<String>();
|
313 |
|
328 |
|
314 |
// Vérification des infos sur le nom de la collection
|
329 |
// Vérification des infos sur le nom de la collection
|
315 |
if (nomChp.getValue() == null
|
330 |
if (nomChp.getValue() == null
|
316 |
|| nomChp.getValue().equals("")
|
331 |
|| nomChp.getValue().equals("")
|
317 |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
|
332 |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
|
318 |
messages.add("Veuillez donner un nom à la collection.");
|
333 |
messages.add("Veuillez donner un nom à la collection.");
|
319 |
}
|
334 |
}
|
320 |
|
335 |
|
321 |
// Vérification des infos sur le type de collection
|
336 |
// Vérification des infos sur le type de collection
|
322 |
if (typesCollectionCombo.getValue() == null
|
337 |
if (typesCollectionCombo.getValue() == null
|
323 |
|| typesCollectionCombo.getValue().equals("")
|
338 |
|| typesCollectionCombo.getValue().equals("")
|
324 |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
|
339 |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
|
325 |
messages.add("Veuillez sélectionner un type pour la collection.");
|
340 |
messages.add("Veuillez sélectionner un type pour la collection.");
|
326 |
}
|
341 |
}
|
327 |
|
342 |
|
328 |
messages.addAll(verifierOnglets());
|
343 |
messages.addAll(verifierOnglets());
|
329 |
|
344 |
|
330 |
// Affichage des messages d'alerte
|
345 |
// Affichage des messages d'alerte
|
331 |
if (messages.size() != 0) {
|
346 |
if (messages.size() != 0) {
|
332 |
String[] tableauDesMessages = {};
|
347 |
String[] tableauDesMessages = {};
|
333 |
tableauDesMessages = messages.toArray(tableauDesMessages);
|
348 |
tableauDesMessages = messages.toArray(tableauDesMessages);
|
334 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null);
|
349 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null);
|
335 |
return false;
|
350 |
return false;
|
336 |
}
|
351 |
}
|
337 |
return true;
|
352 |
return true;
|
338 |
}
|
353 |
}
|
339 |
|
354 |
|
340 |
private ArrayList<String> verifierOnglets() {
|
355 |
private ArrayList<String> verifierOnglets() {
|
341 |
ArrayList<String> messages = new ArrayList<String>();
|
356 |
ArrayList<String> messages = new ArrayList<String>();
|
342 |
messages.addAll(generalOnglet.verifier());
|
357 |
messages.addAll(generalOnglet.verifier());
|
343 |
messages.addAll(personneOnglet.verifier());
|
358 |
messages.addAll(personneOnglet.verifier());
|
344 |
return messages;
|
359 |
return messages;
|
345 |
}
|
360 |
}
|
346 |
}
|
361 |
}
|