Subversion Repositories eFlore/Applications.coel

Rev

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

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