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