Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1245 Rev 1262
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
		
-
 
252
		controlerFermeture();
251
		controlerFermeture();
253
	}
252
	}
254
 
253
 
255
	private void rafraichirInformation(Information info) {
254
	private void rafraichirInformation(Information info) {
256
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
255
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
257
			Debug.log("MESSAGES:\n"+info.getMessages().toString());
256
			Debug.log("MESSAGES:\n"+info.getMessages().toString());
258
		}
257
		}
259
		String infoType = info.getType();
258
		String infoType = info.getType();
260
		
259
		
261
		if (infoType.equals("modif_collection")) {
260
		if (infoType.equals("modif_collection")) {
262
			InfoLogger.display("Modification d'une collection", info.toString());
261
			InfoLogger.display("Modification d'une collection", info.toString());
263
		} else if (infoType.equals("selection_collection")) {
262
		} else if (infoType.equals("selection_collection")) {
264
			InfoLogger.display("Modification d'une collection", info.toString());
263
			InfoLogger.display("Modification d'une collection", info.toString());
265
			if (info.getDonnee(0) != null) {
264
			if (info.getDonnee(0) != null) {
266
				collection = (Collection) info.getDonnee(0);
265
				collection = (Collection) info.getDonnee(0);
267
			}
266
			}
268
			peupler();
267
			peupler();
269
			genererTitreFormulaire();
268
			genererTitreFormulaire();
270
		} else if (infoType.equals("ajout_collection")) {
269
		} else if (infoType.equals("ajout_collection")) {
271
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
270
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
272
				String collectionId = (String) info.getDonnee(0);
271
				String collectionId = (String) info.getDonnee(0);
273
				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");
274
			
273
			
275
				// 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
276
				personneOnglet.rafraichir(info);
275
				personneOnglet.rafraichir(info);
277
				publicationOnglet.rafraichir(info);
276
				publicationOnglet.rafraichir(info);
278
				commentaireOnglet.rafraichir(info);
277
				commentaireOnglet.rafraichir(info);
279
			} else {
278
			} else {
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
		// Vérification de la validité des champs du formulaire
308
		// Vérification de la validité des champs du formulaire
310
		boolean formulaireValide = verifierFormulaire();
309
		boolean formulaireValide = verifierFormulaire();
311
		if (formulaireValide) {
310
		if (formulaireValide) {
312
			// Collecte des données du formulaire
311
			// Collecte des données du formulaire
313
			Collection collectionAEnregistrer = collecterCollection();
312
			Collection collectionAEnregistrer = collecterCollection();
314
			if (mode.equals(MODE_AJOUTER)) {
313
			if (mode.equals(MODE_AJOUTER)) {
315
				mediateur.ajouterCollection(this, collectionAEnregistrer);
314
				mediateur.ajouterCollection(this, collectionAEnregistrer);
316
			} else if (mode.equals(MODE_MODIFIER)) {
315
			} else if (mode.equals(MODE_MODIFIER)) {
317
				if (collectionAEnregistrer == null) {
316
				if (collectionAEnregistrer == null) {
318
					InfoLogger.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
317
					InfoLogger.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
-
 
318
					this.controlerFermeture();
319
				} else {
319
				} else {
320
					mediateur.modifierCollection(this, collectionAEnregistrer);
320
					mediateur.modifierCollection(this, collectionAEnregistrer);
321
				}
321
				}
322
			}
322
			}
323
			
323
			
324
			soumettreOnglets();
324
			soumettreOnglets();
325
		}
325
		}
326
		return formulaireValide;
326
		return formulaireValide;
327
	}
327
	}
328
	
328
	
329
	private void soumettreOnglets() {
329
	private void soumettreOnglets() {
330
		personneOnglet.soumettre();
330
		personneOnglet.soumettre();
331
		publicationOnglet.soumettre();
331
		publicationOnglet.soumettre();
332
		commentaireOnglet.soumettre();
332
		commentaireOnglet.soumettre();
333
	}
333
	}
334
	
334
	
335
	public void reinitialiserFormulaire() {
335
	public void reinitialiserFormulaire() {
336
		if (mode.equals(StructureForm.MODE_MODIFIER)) {
336
		if (mode.equals(StructureForm.MODE_MODIFIER)) {
337
			mediateur.afficherFormCollection(collection.getId());
337
			mediateur.afficherFormCollection(collection.getId());
338
		} else {
338
		} else {
339
			mediateur.afficherFormCollection(null);
339
			mediateur.afficherFormCollection(null);
340
		}
340
		}
341
	}
341
	}
342
	
342
	
343
	private Collection collecterCollection() {
343
	private Collection collecterCollection() {
344
		collectionCollectee = (Collection) collection.cloner(new Collection());
344
		collectionCollectee = (Collection) collection.cloner(new Collection());
345
		
-
 
346
		this.collecter();
345
		this.collecter();
347
		collecterOnglets();
346
		collecterOnglets();
348
		
347
		
349
		Collection collectionARetourner = null;
348
		Collection collectionARetourner = null;
350
		if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) {
349
		if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) {
351
			collectionARetourner = collection = collectionCollectee;
350
			collectionARetourner = collection = collectionCollectee;
352
		}
351
		}
353
		return collectionARetourner;
352
		return collectionARetourner;
354
	}
353
	}
355
	
354
	
356
	private void collecter() {
355
	private void collecter() {
357
		collectionCollectee.setNom(nomChp.getValue());
356
		collectionCollectee.setNom(nomChp.getValue());
358
		collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
357
		collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
359
	}
358
	}
360
	
359
	
361
	private void collecterOnglets() {
360
	private void collecterOnglets() {
362
		generalOnglet.collecter();
361
		generalOnglet.collecter();
363
		personneOnglet.collecter();
362
		personneOnglet.collecter();
364
		publicationOnglet.collecter();
363
		publicationOnglet.collecter();
365
		descriptionOnglet.collecter();
364
		descriptionOnglet.collecter();
366
		contenuOnglet.collecter();
365
		contenuOnglet.collecter();
367
		inventaireOnglet.collecter();
366
		inventaireOnglet.collecter();
368
		commentaireOnglet.collecter();
367
		commentaireOnglet.collecter();
369
	}
368
	}
370
	
369
	
371
	public boolean verifierFormulaire() {
370
	public boolean verifierFormulaire() {
372
		ArrayList<String> messages = new ArrayList<String>();
371
		ArrayList<String> messages = new ArrayList<String>();
373
		
372
		
374
		// Vérification des infos sur le nom de la collection
373
		// Vérification des infos sur le nom de la collection
375
		if (nomChp.getValue() == null 
374
		if (nomChp.getValue() == null 
376
				|| nomChp.getValue().equals("") 
375
				|| nomChp.getValue().equals("") 
377
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
376
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) {
378
			messages.add("Veuillez donner un nom à la collection.");
377
			messages.add("Veuillez donner un nom à la collection.");
379
		}
378
		}
380
		
379
		
381
		// Vérification des infos sur le type de collection
380
		// Vérification des infos sur le type de collection
382
		if (typesCollectionCombo.getValue() == null 
381
		if (typesCollectionCombo.getValue() == null 
383
				|| typesCollectionCombo.getValue().equals("") 
382
				|| typesCollectionCombo.getValue().equals("") 
384
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
383
				|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) {
385
			messages.add("Veuillez sélectionner un type pour la collection.");
384
			messages.add("Veuillez sélectionner un type pour la collection.");
386
		}
385
		}
387
		
386
		
388
		messages.addAll(verifierOnglets());
387
		messages.addAll(verifierOnglets());
389
				
388
				
390
		// Affichage des messages d'alerte
389
		// Affichage des messages d'alerte
391
		if (messages.size() != 0) {
390
		if (messages.size() != 0) {
392
			String[] tableauDesMessages = {};
391
			String[] tableauDesMessages = {};
393
			tableauDesMessages = messages.toArray(tableauDesMessages);
392
			tableauDesMessages = messages.toArray(tableauDesMessages);
394
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null);
393
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null);
395
			return false;
394
			return false;
396
		}
395
		}
397
		return true;
396
		return true;
398
	}
397
	}
399
	
398
	
400
	private ArrayList<String> verifierOnglets() {
399
	private ArrayList<String> verifierOnglets() {
401
		ArrayList<String> messages = new ArrayList<String>();
400
		ArrayList<String> messages = new ArrayList<String>();
402
		messages.addAll(generalOnglet.verifier());
401
		messages.addAll(generalOnglet.verifier());
403
		messages.addAll(personneOnglet.verifier());
402
		messages.addAll(personneOnglet.verifier());
404
		return messages;
403
		return messages;
405
	}
404
	}
406
}
405
}