Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1249 Rev 1255
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 {
278
			} else {
-
 
279
				Debug.log("CollectionForm.rafraichirInformation() > ICI étrange");
279
				InfoLogger.display("Ajout d'une collection", info.toString());
280
				InfoLogger.display("Ajout d'une collection", info.toString());
280
			}
281
			}
281
		} else if (infoType.equals("liste_collection_a_personne")) {
282
		} else if (infoType.equals("liste_collection_a_personne")) {
282
			personneOnglet.rafraichir(info);
283
			personneOnglet.rafraichir(info);
283
		} else if (infoType.equals("liste_collection_a_publication")) {
284
		} else if (infoType.equals("liste_collection_a_publication")) {
284
			publicationOnglet.rafraichir(info);
285
			publicationOnglet.rafraichir(info);
285
		} else if (infoType.equals("liste_collection_a_commentaire")) {
286
		} else if (infoType.equals("liste_collection_a_commentaire")) {
286
			commentaireOnglet.rafraichir(info);
287
			commentaireOnglet.rafraichir(info);
287
		}
288
		}
288
	}
289
	}
289
		
290
		
290
	private void peupler() {
291
	private void peupler() {
291
		if (collection != null) {
292
		if (collection != null) {
292
			nomChp.setValue(collection.getNom());
293
			nomChp.setValue(collection.getNom());
293
			typesCollectionCombo.peupler(collection.getTypeNcd());
294
			typesCollectionCombo.peupler(collection.getTypeNcd());
294
			
295
			
295
			peuplerOnglets();
296
			peuplerOnglets();
296
		}
297
		}
297
	}
298
	}
298
 
299
 
299
	private void peuplerOnglets() {
300
	private void peuplerOnglets() {
300
		generalOnglet.peupler();
301
		generalOnglet.peupler();
301
		descriptionOnglet.peupler();
302
		descriptionOnglet.peupler();
302
		contenuOnglet.peupler();
303
		contenuOnglet.peupler();
303
		inventaireOnglet.peupler();
304
		inventaireOnglet.peupler();
304
		commentaireOnglet.peupler();
305
		commentaireOnglet.peupler();
305
	}
306
	}
306
 
307
 
307
	public boolean soumettreFormulaire() {
308
	public boolean soumettreFormulaire() {
308
		
-
 
309
Debug.log("<$$$> BEGIN CollectionForm.soumettreFormulaire()");		
-
 
310
		
309
		
311
		// Vérification de la validité des champs du formulaire
310
		// Vérification de la validité des champs du formulaire
-
 
311
		boolean formulaireValide = verifierFormulaire();
312
		boolean formulaireValide = verifierFormulaire();
312
 
313
		if (formulaireValide) {
313
		if (formulaireValide) {
314
			// Collecte des données du formulaire
314
			// Collecte des données du formulaire
315
			Collection collectionAEnregistrer = collecterCollection();
315
			Collection collectionAEnregistrer = collecterCollection();
316
			
-
 
317
Debug.log("<$$$> CollectionForm.soumettreFormulaire(), collectionAEnregistrer.getProperties()="+collectionAEnregistrer.getProperties().toString());
-
 
318
			
316
			
319
			if (mode.equals(MODE_AJOUTER)) {
317
			if (mode.equals(MODE_AJOUTER)) {
320
				mediateur.ajouterCollection(this, collectionAEnregistrer);
318
				mediateur.ajouterCollection(this, collectionAEnregistrer);
321
			} else if (mode.equals(MODE_MODIFIER)) {
319
			} else if (mode.equals(MODE_MODIFIER)) {
322
				if (collectionAEnregistrer == null) {
320
				if (collectionAEnregistrer == null) {
323
					InfoLogger.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
321
					InfoLogger.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
324
					this.controlerFermeture();
322
					this.controlerFermeture();
325
				} else {
323
				} else {
326
					mediateur.modifierCollection(this, collectionAEnregistrer);
324
					mediateur.modifierCollection(this, collectionAEnregistrer);
327
				}
325
				}
328
			}
326
			}
329
			
327
			
330
			soumettreOnglets();
328
			soumettreOnglets();
331
		}
329
		}
332
		
-
 
333
Debug.log("<$$$> END CollectionForm.soumettreFormulaire()");		
-
 
334
		
-
 
335
		return formulaireValide;
330
		return formulaireValide;
336
	}
331
	}
337
	
332
	
338
	private void soumettreOnglets() {
333
	private void soumettreOnglets() {
339
		personneOnglet.soumettre();
334
		personneOnglet.soumettre();
340
		publicationOnglet.soumettre();
335
		publicationOnglet.soumettre();
341
		commentaireOnglet.soumettre();
336
		commentaireOnglet.soumettre();
342
	}
337
	}
343
	
338
	
344
	public void reinitialiserFormulaire() {
339
	public void reinitialiserFormulaire() {
345
		if (mode.equals(StructureForm.MODE_MODIFIER)) {
340
		if (mode.equals(StructureForm.MODE_MODIFIER)) {
346
			mediateur.afficherFormCollection(collection.getId());
341
			mediateur.afficherFormCollection(collection.getId());
347
		} else {
342
		} else {
348
			mediateur.afficherFormCollection(null);
343
			mediateur.afficherFormCollection(null);
349
		}
344
		}
350
	}
345
	}
351
	
346
	
352
	private Collection collecterCollection() {
347
	private Collection collecterCollection() {
353
		collectionCollectee = (Collection) collection.cloner(new Collection());
348
		collectionCollectee = (Collection) collection.cloner(new Collection());
354
		
-
 
355
		this.collecter();
349
		this.collecter();
356
		collecterOnglets();
350
		collecterOnglets();
357
		
351
		
358
		Collection collectionARetourner = null;
352
		Collection collectionARetourner = null;
359
		if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) {
353
		if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) {
360
			collectionARetourner = collection = collectionCollectee;
354
			collectionARetourner = collection = collectionCollectee;
361
		}
355
		}
362
		return collectionARetourner;
356
		return collectionARetourner;
363
	}
357
	}
364
	
358
	
365
	private void collecter() {
359
	private void collecter() {
366
		collectionCollectee.setNom(nomChp.getValue());
360
		collectionCollectee.setNom(nomChp.getValue());
367
		collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
361
		collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
368
	}
362
	}
369
	
363
 
370
	private void collecterOnglets() {
364
	private void collecterOnglets() {
371
		generalOnglet.collecter();
365
		generalOnglet.collecter();
372
		personneOnglet.collecter();
366
		personneOnglet.collecter();
373
		publicationOnglet.collecter();
367
		publicationOnglet.collecter();
374
		descriptionOnglet.collecter();
368
		descriptionOnglet.collecter();
375
		contenuOnglet.collecter();
369
		contenuOnglet.collecter();
376
		inventaireOnglet.collecter();
370
		inventaireOnglet.collecter();
377
		commentaireOnglet.collecter();
371
		commentaireOnglet.collecter();
378
	}
372
	}
379
	
373
 
380
	public boolean verifierFormulaire() {
374
	public boolean verifierFormulaire() {
381
		ArrayList<String> messages = new ArrayList<String>();
375
		ArrayList<String> messages = new ArrayList<String>();
382
		
376
		
383
		// Vérification des infos sur le nom de la collection
377
		// Vérification des infos sur le nom de la collection
384
		if (nomChp.getValue() == null 
378
		if (nomChp.getValue() == null 
385
				|| nomChp.getValue().equals("") 
379
				|| nomChp.getValue().equals("") 
386
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
380
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
387
			messages.add("Veuillez donner un nom à la collection.");
381
			messages.add("Veuillez donner un nom à la collection.");
388
		}
382
		}
389
		
383
		
390
		// Vérification des infos sur le type de collection
384
		// Vérification des infos sur le type de collection
391
		if (typesCollectionCombo.getValue() == null 
385
		if (typesCollectionCombo.getValue() == null 
392
				|| typesCollectionCombo.getValue().equals("") 
386
				|| typesCollectionCombo.getValue().equals("") 
393
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
387
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
394
			messages.add("Veuillez sélectionner un type pour la collection.");
388
			messages.add("Veuillez sélectionner un type pour la collection.");
395
		}
389
		}
396
		
390
		
397
		messages.addAll(verifierOnglets());
391
		messages.addAll(verifierOnglets());
398
				
392
				
399
		// Affichage des messages d'alerte
393
		// Affichage des messages d'alerte
400
		if (messages.size() != 0) {
394
		if (messages.size() != 0) {
401
			String[] tableauDesMessages = {};
395
			String[] tableauDesMessages = {};
402
			tableauDesMessages = messages.toArray(tableauDesMessages);
396
			tableauDesMessages = messages.toArray(tableauDesMessages);
403
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null);
397
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null);
404
			return false;
398
			return false;
405
		}
399
		}
406
		return true;
400
		return true;
407
	}
401
	}
408
	
402
	
409
	private ArrayList<String> verifierOnglets() {
403
	private ArrayList<String> verifierOnglets() {
410
		ArrayList<String> messages = new ArrayList<String>();
404
		ArrayList<String> messages = new ArrayList<String>();
411
		messages.addAll(generalOnglet.verifier());
405
		messages.addAll(generalOnglet.verifier());
412
		messages.addAll(personneOnglet.verifier());
406
		messages.addAll(personneOnglet.verifier());
413
		return messages;
407
		return messages;
414
	}
408
	}
415
}
409
}