Subversion Repositories eFlore/Applications.coel

Rev

Rev 975 | Rev 997 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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