Subversion Repositories eFlore/Applications.coel

Rev

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

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