Subversion Repositories eFlore/Applications.coel

Rev

Rev 1255 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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