Subversion Repositories eFlore/Applications.coel

Rev

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

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