Subversion Repositories eFlore/Applications.coel

Rev

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

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