Subversion Repositories eFlore/Applications.coel

Rev

Rev 1215 | Rev 1233 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
935 jpm 1
package org.tela_botanica.client.vues.structure;
69 jpm 2
 
91 jpm 3
import java.util.ArrayList;
4
import java.util.Iterator;
69 jpm 5
import java.util.List;
6
 
981 jpm 7
import org.tela_botanica.client.ComposantClass;
119 jpm 8
import org.tela_botanica.client.Mediateur;
91 jpm 9
import org.tela_botanica.client.RegistreId;
1208 cyprien 10
import org.tela_botanica.client.composants.InfoLogger;
569 jp_milcent 11
import org.tela_botanica.client.images.Images;
69 jpm 12
import org.tela_botanica.client.interfaces.Rafraichissable;
153 jpm 13
import org.tela_botanica.client.modeles.Information;
100 jpm 14
import org.tela_botanica.client.modeles.InterneValeur;
15
import org.tela_botanica.client.modeles.InterneValeurListe;
330 jp_milcent 16
import org.tela_botanica.client.modeles.MenuApplicationId;
91 jpm 17
import org.tela_botanica.client.modeles.Valeur;
18
import org.tela_botanica.client.modeles.ValeurListe;
1215 cyprien 19
import org.tela_botanica.client.modeles.aDonnee;
20
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
935 jpm 21
import org.tela_botanica.client.modeles.personne.Personne;
22
import org.tela_botanica.client.modeles.personne.PersonneListe;
23
import org.tela_botanica.client.modeles.projet.Projet;
24
import org.tela_botanica.client.modeles.projet.ProjetListe;
25
import org.tela_botanica.client.modeles.structure.Structure;
26
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
27
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
28
import org.tela_botanica.client.modeles.structure.StructureConservation;
29
import org.tela_botanica.client.modeles.structure.StructureValorisation;
1208 cyprien 30
import org.tela_botanica.client.util.Debug;
1171 jpm 31
import org.tela_botanica.client.util.Pattern;
243 jp_milcent 32
import org.tela_botanica.client.util.UtilArray;
1043 gduche 33
import org.tela_botanica.client.util.UtilString;
935 jpm 34
import org.tela_botanica.client.vues.Formulaire;
69 jpm 35
 
491 gduche 36
import com.extjs.gxt.ui.client.event.Events;
91 jpm 37
import com.extjs.gxt.ui.client.Registry;
295 jp_milcent 38
import com.extjs.gxt.ui.client.event.BaseEvent;
491 gduche 39
import com.extjs.gxt.ui.client.event.ButtonEvent;
111 jpm 40
import com.extjs.gxt.ui.client.event.ComponentEvent;
1208 cyprien 41
import com.extjs.gxt.ui.client.event.EventType;
243 jp_milcent 42
import com.extjs.gxt.ui.client.event.KeyListener;
111 jpm 43
import com.extjs.gxt.ui.client.event.Listener;
100 jpm 44
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
45
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
103 jpm 46
import com.extjs.gxt.ui.client.event.SelectionListener;
69 jpm 47
import com.extjs.gxt.ui.client.store.ListStore;
245 jp_milcent 48
import com.extjs.gxt.ui.client.store.Record;
49
import com.extjs.gxt.ui.client.store.Store;
50
import com.extjs.gxt.ui.client.store.StoreEvent;
111 jpm 51
import com.extjs.gxt.ui.client.widget.Component;
102 jpm 52
import com.extjs.gxt.ui.client.widget.ContentPanel;
569 jp_milcent 53
import com.extjs.gxt.ui.client.widget.Html;
153 jpm 54
import com.extjs.gxt.ui.client.widget.Info;
69 jpm 55
import com.extjs.gxt.ui.client.widget.LayoutContainer;
320 gduche 56
import com.extjs.gxt.ui.client.widget.MessageBox;
100 jpm 57
import com.extjs.gxt.ui.client.widget.TabItem;
58
import com.extjs.gxt.ui.client.widget.TabPanel;
69 jpm 59
import com.extjs.gxt.ui.client.widget.button.Button;
108 jpm 60
import com.extjs.gxt.ui.client.widget.form.CheckBox;
61
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
69 jpm 62
import com.extjs.gxt.ui.client.widget.form.ComboBox;
100 jpm 63
import com.extjs.gxt.ui.client.widget.form.DateField;
119 jpm 64
import com.extjs.gxt.ui.client.widget.form.Field;
100 jpm 65
import com.extjs.gxt.ui.client.widget.form.FieldSet;
172 jp_milcent 66
import com.extjs.gxt.ui.client.widget.form.HiddenField;
103 jpm 67
import com.extjs.gxt.ui.client.widget.form.LabelField;
102 jpm 68
import com.extjs.gxt.ui.client.widget.form.NumberField;
109 jpm 69
import com.extjs.gxt.ui.client.widget.form.Radio;
70
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
164 jp_milcent 71
import com.extjs.gxt.ui.client.widget.form.TextArea;
69 jpm 72
import com.extjs.gxt.ui.client.widget.form.TextField;
73
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
74
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
102 jpm 75
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
76
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
77
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
78
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
79
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
231 jp_milcent 80
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
81
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
69 jpm 82
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
83
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
84
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
100 jpm 85
import com.extjs.gxt.ui.client.widget.layout.FormData;
110 jpm 86
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
102 jpm 87
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
88
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
91 jpm 89
import com.google.gwt.core.client.GWT;
100 jpm 90
import com.google.gwt.i18n.client.DateTimeFormat;
102 jpm 91
import com.google.gwt.i18n.client.NumberFormat;
1035 gduche 92
import com.google.gwt.user.client.Window;
69 jpm 93
 
634 jp_milcent 94
public class StructureForm extends Formulaire implements Rafraichissable {
115 jpm 95
 
615 jp_milcent 96
	private static int decompteRafraichissementPersonnel = 0;
634 jp_milcent 97
 
775 jpm 98
	private TabPanel onglets = null;
206 jp_milcent 99
	private TabItem identificationOnglet = null;
192 jp_milcent 100
	private TabItem personnelOnglet = null;
101
	private TabItem conservationOnglet = null;
102
	private TabItem valorisationOnglet = null;
206 jp_milcent 103
 
104
	private HiddenField<String> idStructureChp = null;
115 jpm 105
 
206 jp_milcent 106
	// Onglet IDENTIFICATION
602 jp_milcent 107
	private Structure identification = null;
91 jpm 108
	private ListStore<Valeur> magazinLstpr = null;
109
	private ComboBox<Valeur> comboLstpr = null;
110
	private ListStore<Valeur> magazinLstpu = null;
111
	private ComboBox<Valeur> comboLstpu = null;
103 jpm 112
	private ListStore<Valeur> magazinLiStatut = null;
113
	private ComboBox<Valeur> comboLiStatut = null;
295 jp_milcent 114
	private ListStore<Valeur> fonctionsMagazin = null;
115
	private ComboBox<Valeur> fonctionsCombo = null;
100 jpm 116
	private ComboBox<InterneValeur> comboAcronyme = null;
117
	private TextField<String> ihChp = null;
118
	private TextField<String> mnhnChp = null;
119
	private ComboBox<InterneValeur> comboTypeStructure = null;
602 jp_milcent 120
	private TextField<String> nomStructureChp = null;
121
	private DateField dateFondationChp = null;
1171 jpm 122
	private TextArea descriptionChp = null;
123
	private TextArea conditionAccesChp = null;
124
	private TextArea conditionUsageChp = null;
602 jp_milcent 125
	private TextArea adrChp = null;
1171 jpm 126
	private TextArea adrComplementChp = null;
602 jp_milcent 127
	private TextField<String> cpChp = null;
128
	private TextField<String> villeChp = null;
1171 jpm 129
	private ListStore<Valeur> magazinRegion = null;
1035 gduche 130
	private ComboBox<Valeur> comboRegion = null;
1171 jpm 131
	private ListStore<Valeur> magazinPays = null;
132
	private ComboBox<Valeur> comboPays = null;
133
	private TextField<String> latitudeChp = null;
134
	private TextField<String> longitudeChp = null;
602 jp_milcent 135
	private TextField<String> telChp = null;
136
	private TextField<String> faxChp = null;
137
	private TextField<String> emailChp = null;
138
	private TextField<String> urlChp = null;
192 jp_milcent 139
 
206 jp_milcent 140
	// Onglet PERSONNEL
602 jp_milcent 141
	private StructureAPersonneListe personnel = null;
231 jp_milcent 142
	private StructureAPersonneListe personnelAjoute = null;
143
	private StructureAPersonneListe personnelModifie = null;
144
	private StructureAPersonneListe personnelSupprime = null;
211 jp_milcent 145
	private NumberField nbreTotalPersonneStructureChp = null;
146
	private EditorGrid<StructureAPersonne> grillePersonnel = null;
147
	private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
148
 
206 jp_milcent 149
	// Onglet CONSERVATION
211 jp_milcent 150
	private StructureConservation conservation = null;
602 jp_milcent 151
	private RadioGroup formationMarkRGrpChp = null;
152
	private RadioGroup interetFormationMarkRGrpChp = null;
153
	private RadioGroup collectionCommuneMarkRGrpChp = null;
154
	private RadioGroup accesControleMarkRGrpChp = null;
155
	private RadioGroup restaurationMarkRGrpChp = null;
156
	private RadioGroup traitementMarkRGrpChp = null;
157
	private RadioGroup collectionAcquisitionMarkRGrpChp = null;
158
	private RadioGroup echantillonAcquisitionMarkRGrpChp = null;
159
	private TextField<String> localStockageAutreChp = null;
160
	private TextField<String> meubleStockageAutreChp = null;
161
	private TextField<String> parametreStockageAutreChp = null;
162
	private TextField<String> collectionAutreAutreChp = null;
163
	private TextField<String> autreCollectionAutreChp = null;
164
	private TextField<String> opRestauAutreChp = null;
165
	private TextField<String> autreMaterielAutreChp = null;
166
	private TextField<String> poisonTraitementAutreChp = null;
167
	private TextField<String> traitementAutreChp = null;
168
	private TextField<String> insecteTraitementAutreChp = null;
169
	private TextField<String> actionAutreChp = null;
170
	private TextField<String> provenanceRechercheAutreChp = null;
171
	private TextField<String> typeRechercheAutreChp = null;
115 jpm 172
	private CheckBoxGroup localStockageTrukCacGrpChp = null;
569 jp_milcent 173
	private LayoutContainer localStockageTrukCp = null;
115 jpm 174
	private CheckBoxGroup meubleStockageTrukCacGrpChp = null;
569 jp_milcent 175
	private LayoutContainer meubleStockageTrukCp = null;
115 jpm 176
	private CheckBoxGroup parametreStockageTrukCacGrpChp = null;
569 jp_milcent 177
	private LayoutContainer parametreStockageTrukCp = null;
178
	private LayoutContainer collectionAutreTrukCp = null;
111 jpm 179
	private CheckBoxGroup collectionAutreTrukCacGrpChp = null;
115 jpm 180
	private CheckBoxGroup opRestauTrukCacGrpChp = null;
569 jp_milcent 181
	private LayoutContainer opRestauTrukCp = null;
115 jpm 182
	private CheckBoxGroup autreMaterielTrukCacGrpChp = null;
569 jp_milcent 183
	private LayoutContainer autreMaterielTrukCp = null;
184
	private LayoutContainer traitementTrukCp = null;
111 jpm 185
	private CheckBoxGroup traitementTrukCacGrpChp = null;
569 jp_milcent 186
	private LayoutContainer poisonTraitementTrukCp = null;
187
	private LayoutContainer insecteTraitementTrukCp = null;
111 jpm 188
	private CheckBoxGroup insecteTraitementTrukCacGrpChp = null;
115 jpm 189
	private CheckBoxGroup poisonTraitementTrukCacGrpChp = null;
569 jp_milcent 190
	private LayoutContainer autreCollectionTrukCp = null;
119 jpm 191
	private CheckBoxGroup autreCollectionTrukCacGrpChp = null;
569 jp_milcent 192
	private LayoutContainer provenanceRechercheTrukCp = null;
115 jpm 193
	private CheckBoxGroup provenanceRechercheTrukCacGrpChp = null;
194
	private CheckBoxGroup typeRechercheTrukCacGrpChp = null;
569 jp_milcent 195
	private LayoutContainer typeRechercheTrukCp = null;
115 jpm 196
	private TextField<String> futureActionChp = null;
197
	private TextField<String> sansMotifAccesChp = null;
198
	private TextField<String> avecMotifAccesChp = null;
199
	private TextField<String> formationChp = null;
200
	private RadioGroup traitementAcquisitionMarkRGrpChp = null;
201
	private LabelField traitementAcquisitionMarkLabel = null;
202
	private RadioGroup materielConservationCeRGrpChp = null;
119 jpm 203
 
206 jp_milcent 204
	// Onglet VALORISATION
211 jp_milcent 205
	private StructureValorisation valorisation = null;
206 jp_milcent 206
	private RadioGroup actionMarkRGrpChp = null;
569 jp_milcent 207
	private LayoutContainer actionTrukCp = null;
206 jp_milcent 208
	private CheckBoxGroup actionTrukCacGrpChp = null;
602 jp_milcent 209
	private RadioGroup futureActionMarkRGrpChp = null;
210
	private RadioGroup rechercheMarkRGrpChp = null;
211
	private RadioGroup sansMotifAccesMarkRGrpChp = null;
212
	private RadioGroup avecMotifAccesMarkRGrpChp = null;
213
	private TextField<String> publicationChp = null;
214
	private LayoutContainer materielConservationCp = null;
215
	private ListStore<Personne> personneExistanteMagazin = null;
216
	private ComboBox<Personne> personneExistanteCombo = null;
217
	private Button supprimerPersonnelBtn = null;
218
	private ListStore<Projet> projetsMagazin = null;
219
	private ComboBox<Projet> projetsCombo = null;
220
	private CellEditor fonctionEditor = null;
221
	private List<Valeur> fonctionsListe = null;
192 jp_milcent 222
 
444 jp_milcent 223
	public StructureForm(Mediateur mediateurCourrant, String modeDeCreation) {
648 jp_milcent 224
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.STRUCTURE);
775 jpm 225
		// Ajout du titre
226
		panneauFormulaire.setHeading(i18nC.titreAjoutFormStructurePanneau());
227
		// Création des onglets
228
		onglets = creerOnglets();
229
		// Ajout des onglets au formulaire général
230
		panneauFormulaire.add(onglets);
609 jp_milcent 231
	}
232
 
775 jpm 233
	protected TabPanel creerOnglets() {
234
		TabPanel ongletsStructure = new TabPanel();
110 jpm 235
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner)
775 jpm 236
		ongletsStructure.setHeight("100%");
69 jpm 237
 
100 jpm 238
		// Onlget formulaire IDENTIFICATION
775 jpm 239
		ongletsStructure.add(creerOngletIdentification());
206 jp_milcent 240
 
100 jpm 241
		// Onlget formulaire PERSONNEL
775 jpm 242
		ongletsStructure.add(creerOngletPersonnel());
91 jpm 243
 
100 jpm 244
		// Onlget formulaire CONSERVATION
775 jpm 245
		ongletsStructure.add(creerOngletConservation());
100 jpm 246
 
247
		// Onlget formulaire VALORISATION
775 jpm 248
		ongletsStructure.add(creerOngletValorisation());
100 jpm 249
 
119 jpm 250
		// Sélection de l'onglet par défaut
775 jpm 251
		//ongletsStructure(personnelOnglet);
192 jp_milcent 252
 
775 jpm 253
		return ongletsStructure;
609 jp_milcent 254
	}
255
 
934 jpm 256
	public void reinitialiserFormulaire() {
257
		if (mode.equals(StructureForm.MODE_MODIFIER)) {
258
			mediateur.afficherFormStructure(identification.getId());
259
		} else {
260
			mediateur.afficherFormStructure(null);
261
		}
69 jpm 262
	}
781 jpm 263
 
934 jpm 264
	public boolean soumettreFormulaire() {
1208 cyprien 265
 
266
		Debug.log("===> BEGIN StructureForm.soumettreFormulaire()");
267
 
243 jp_milcent 268
		// Vérification de la validité des champs du formulaire
786 jpm 269
		boolean fomulaireValide = verifierFormulaire();
270
		if (fomulaireValide) {
243 jp_milcent 271
			// Collecte des données du formulaire
272
			Structure structure = collecterStructureIdentification();
273
			StructureConservation conservation = collecterStructureConservation();
274
			StructureValorisation valorisation = collecterStructureValorisation();
275
			collecterStructurePersonnel();
276
 
634 jp_milcent 277
			if (mode.equals(MODE_AJOUTER)) {
243 jp_milcent 278
				// Ajout des informations sur la Structure
782 jpm 279
				mediateur.ajouterStructure(this, structure, conservation, valorisation);
243 jp_milcent 280
				// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
281
				// Voir la méthode rafraichir().
634 jp_milcent 282
			} else if (mode.equals(MODE_MODIFIER)) {
1208 cyprien 283
 
284
				Debug.log("===> StructureForm.soumettreFormulaire(), mode="+mode);
285
 
243 jp_milcent 286
				// Modification des informations sur la Structure
306 jp_milcent 287
				if (structure == null && conservation == null && valorisation == null) {
1208 cyprien 288
					InfoLogger.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
306 jp_milcent 289
				} else {
290
					mediateur.modifierStructure(this, identification.getId(), structure, conservation, valorisation);
291
				}
1208 cyprien 292
 
293
				Debug.log("===> StructureForm.soumettreFormulaire(), personnelModifie.size="+personnelModifie.size() + ", personnelAjoute.size()="+personnelAjoute.size());
294
 
306 jp_milcent 295
				if (personnelModifie.size() == 0 && personnelAjoute.size() == 0 && personnelSupprime.size() == 0) {
1208 cyprien 296
					InfoLogger.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
306 jp_milcent 297
				} else {
298
					if (personnelModifie.size() != 0) {
609 jp_milcent 299
						decompteRafraichissementPersonnel++;
782 jpm 300
						mediateur.modifierStructureAPersonne(this, personnelModifie);
306 jp_milcent 301
					}
302
					// Ajout des relations StructureAPersonne
303
					if (personnelAjoute.size() != 0) {
609 jp_milcent 304
						decompteRafraichissementPersonnel++;
782 jpm 305
						mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute);
306 jp_milcent 306
					}
307
					// Suppression des relations StructureAPersonne
308
					if (personnelSupprime.size() != 0) {
609 jp_milcent 309
						decompteRafraichissementPersonnel++;
782 jpm 310
						mediateur.supprimerStructureAPersonne(this, personnelSupprime);
306 jp_milcent 311
					}
312
				}
243 jp_milcent 313
			}
314
		}
1208 cyprien 315
 
316
		Debug.log("===> END StructureForm.soumettreFormulaire()");
317
 
786 jpm 318
		return fomulaireValide;
243 jp_milcent 319
	}
320
 
934 jpm 321
	public boolean verifierFormulaire() {
243 jp_milcent 322
		ArrayList<String> messages = new ArrayList<String>();
231 jp_milcent 323
 
295 jp_milcent 324
		// Vérification des infos sur le nom de la structure
263 jp_milcent 325
		if (	(identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue() == null) ||
326
				(identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue().equals("")) ||
243 jp_milcent 327
				(identificationOnglet.getData("acces").equals(false) && identification.getNom().equals(""))) {
328
			messages.add("Veuillez indiquez un nom à l'institution.");
156 jp_milcent 329
		}
243 jp_milcent 330
 
295 jp_milcent 331
		// Vérification des infos sur le projet de la structure
332
		if (	(identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue() == null) ||
333
				(identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue().equals("")) ||
334
				(identificationOnglet.getData("acces").equals(false) && identification.getIdProjet().equals(""))) {
335
			messages.add("Veuillez sélectionner un projet pour l'institution.");
336
		}
337
 
243 jp_milcent 338
		// Vérification du Personnel
339
		if (personnelOnglet.getData("acces").equals(true)) {
340
			String personnelNumero = "";
341
			int nbrePersonne = personnelGrilleMagazin.getCount();
342
			for (int i = 0; i < nbrePersonne; i++) {
343
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
344
				if (personne.getNom().equals("") || personne.getPrenom().equals("")) {
345
					personnelNumero += (i != 0 ? ", " : "")+(i+1);
346
				}
347
			}
348
			if (!personnelNumero.equals("")) {
349
				messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero);
350
			}
351
		}
352
 
353
		// Affichage des messages d'alerte
354
		if (messages.size() != 0) {
355
			String[] a = {};
356
			a = messages.toArray(a);
320 gduche 357
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(a, "\n\n"), null);
243 jp_milcent 358
			return false;
359
		}
360
		return true;
119 jpm 361
	}
362
 
192 jp_milcent 363
	private StructureValorisation collecterStructureValorisation() {
306 jp_milcent 364
		StructureValorisation valorisationARetourner = null;
365
		if (valorisationOnglet.getData("acces").equals(true)) {
206 jp_milcent 366
			// Création de l'objet
306 jp_milcent 367
			StructureValorisation valorisationCollectee = (StructureValorisation) valorisation.cloner(new StructureValorisation());
206 jp_milcent 368
 
369
			// ACTION
370
			if (actionMarkRGrpChp.getValue() != null) {
306 jp_milcent 371
				valorisationCollectee.setAction(actionMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 372
			}
373
 
374
			// ACTION INFO
306 jp_milcent 375
			valorisationCollectee.setActionInfo(creerChaineDenormalisee(actionTrukCacGrpChp.getValues()));
376
			valorisationCollectee.setActionInfo("AUTRE", actionAutreChp.getValue());
206 jp_milcent 377
 
378
			// PUBLICATION
306 jp_milcent 379
			valorisationCollectee.setPublication(publicationChp.getValue());
206 jp_milcent 380
 
381
			// COLLECTION AUTRE
306 jp_milcent 382
			valorisationCollectee.setCollectionAutre(creerChaineDenormalisee(autreCollectionTrukCacGrpChp.getValues()));
383
			valorisationCollectee.setCollectionAutre("AUTRE", autreCollectionAutreChp.getValue());
206 jp_milcent 384
 
385
			// ACTION FUTURE
386
			if (futureActionMarkRGrpChp.getValue() != null) {
306 jp_milcent 387
				valorisationCollectee.setActionFuture(futureActionMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 388
			}
389
			// ACTION FUTURE INFO
306 jp_milcent 390
			valorisationCollectee.setActionFutureInfo(futureActionChp.getValue());
206 jp_milcent 391
 
392
			// RECHERCHE
393
			if (rechercheMarkRGrpChp.getValue() != null) {
306 jp_milcent 394
				valorisationCollectee.setRecherche(rechercheMarkRGrpChp.getValue().getValueAttribute());
602 jp_milcent 395
 
396
				// RECHERCHE PROVENANCE
397
				valorisationCollectee.setRechercheProvenance(creerChaineDenormalisee(provenanceRechercheTrukCacGrpChp.getValues()));
398
				valorisationCollectee.setRechercheProvenance("AUTRE", provenanceRechercheAutreChp.getValue());
399
 
400
				// RECHERCHE TYPE
401
				valorisationCollectee.setRechercheType(creerChaineDenormalisee(typeRechercheTrukCacGrpChp.getValues()));
402
				valorisationCollectee.setRechercheType("AUTRE", typeRechercheAutreChp.getValue());
206 jp_milcent 403
			}
404
 
405
			// ACCÈS SANS MOTIF
406
			if (sansMotifAccesMarkRGrpChp.getValue() != null) {
306 jp_milcent 407
				valorisationCollectee.setAccesSansMotif(sansMotifAccesMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 408
			}
409
			// ACCÈS SANS MOTIF INFO
306 jp_milcent 410
			valorisationCollectee.setAccesSansMotifInfo(sansMotifAccesChp.getValue());
206 jp_milcent 411
 
412
			// VISITE AVEC MOTIF
413
			if (avecMotifAccesMarkRGrpChp.getValue() != null) {
306 jp_milcent 414
				valorisationCollectee.setVisiteAvecMotif(avecMotifAccesMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 415
			}
416
			// VISITE AVEC MOTIF INFO
306 jp_milcent 417
			valorisationCollectee.setVisiteAvecMotifInfo(avecMotifAccesChp.getValue());
206 jp_milcent 418
 
306 jp_milcent 419
			// Retour de l'objet
420
			if (!valorisationCollectee.comparer(valorisation)) {
421
				valorisationARetourner = valorisation = valorisationCollectee;
422
			}
192 jp_milcent 423
		}
306 jp_milcent 424
		return valorisationARetourner;
192 jp_milcent 425
	}
426
 
427
	private void peuplerStructureValorisation() {
605 jp_milcent 428
		if (mode.equals(MODE_AJOUTER)) {
429
			// Indique que l'onglet a pu être modifié pour la méthode collecter...
430
			valorisationOnglet.setData("acces", true);
431
			// Initialisation de l'objet Structure
432
			valorisation = new StructureValorisation();
433
		}
434
		if (mode.equals(MODE_MODIFIER) && valorisation != null && valorisationOnglet.getData("acces").equals(false)) {
491 gduche 435
			// ACTION :
436
			//TODO : check below:
437
			((Radio) actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 438
 
439
			// ACTION INFO
440
			peuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp);
441
 
442
			// PUBLICATION
443
			publicationChp.setValue(valorisation.getPublication());
444
 
445
			// COLLECTION AUTRE
446
			peuplerCasesACocher(valorisation.getCollectionAutre(), autreCollectionTrukCacGrpChp, autreCollectionAutreChp);
447
 
448
			// ACTION FUTURE
491 gduche 449
			((Radio) futureActionMarkRGrpChp.get((valorisation.getActionFuture().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 450
 
451
			// ACTION FUTURE INFO
452
			futureActionChp.setValue(valorisation.getActionFutureInfo());
453
 
454
			// RECHERCHE
491 gduche 455
			((Radio) rechercheMarkRGrpChp.get((valorisation.getRecherche().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 456
			// RECHERCHE PROVENANCE
457
			peuplerCasesACocher(valorisation.getRechercheProvenance(), provenanceRechercheTrukCacGrpChp, provenanceRechercheAutreChp);
458
			// RECHERCHE TYPE
459
			peuplerCasesACocher(valorisation.getRechercheType(), typeRechercheTrukCacGrpChp, typeRechercheAutreChp);
460
 
461
			// ACCÈS SANS MOTIF
491 gduche 462
			((Radio) sansMotifAccesMarkRGrpChp.get((valorisation.getAccesSansMotif().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 463
			// ACCÈS SANS MOTIF INFO
464
			sansMotifAccesChp.setValue(valorisation.getAccesSansMotifInfo());
465
 
466
			// VISITE AVEC MOTIF
491 gduche 467
			((Radio) avecMotifAccesMarkRGrpChp.get((valorisation.getVisiteAvecMotif().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 468
			// VISITE AVEC MOTIF INFO
469
			avecMotifAccesChp.setValue(valorisation.getVisiteAvecMotifInfo());
211 jp_milcent 470
 
243 jp_milcent 471
			// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
472
			valorisationOnglet.setData("acces", true);
206 jp_milcent 473
		}
192 jp_milcent 474
	}
475
 
476
	private StructureConservation collecterStructureConservation() {
306 jp_milcent 477
		StructureConservation conservationARetourner = null;
478
		if (conservationOnglet.getData("acces").equals(true)) {
206 jp_milcent 479
			// Création de l'objet
306 jp_milcent 480
			StructureConservation conservationCollectee = (StructureConservation) conservation.cloner(new StructureConservation());
192 jp_milcent 481
 
206 jp_milcent 482
			// FORMATION
483
			if (formationMarkRGrpChp.getValue() != null) {
306 jp_milcent 484
				conservationCollectee.setFormation(formationMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 485
			}
486
			// FORMATION INFO
306 jp_milcent 487
			conservationCollectee.setFormationInfo(formationChp.getValue());
206 jp_milcent 488
			// FORMATION INTERET
489
			if (interetFormationMarkRGrpChp.getValue() != null) {
306 jp_milcent 490
				conservationCollectee.setFormationInteret(interetFormationMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 491
			}
492
 
493
			// STOCKAGE LOCAL
306 jp_milcent 494
			conservationCollectee.setStockageLocal(creerChaineDenormalisee(localStockageTrukCacGrpChp.getValues()));
495
			conservationCollectee.setStockageLocal("AUTRE", localStockageAutreChp.getValue());
206 jp_milcent 496
 
497
			// STOCKAGE MEUBLE
306 jp_milcent 498
			conservationCollectee.setStockageMeuble(creerChaineDenormalisee(meubleStockageTrukCacGrpChp.getValues()));
499
			conservationCollectee.setStockageMeuble("AUTRE", meubleStockageAutreChp.getValue());
206 jp_milcent 500
 
501
			// STOCKAGE PAREMETRE
306 jp_milcent 502
			conservationCollectee.setStockageParametre(creerChaineDenormalisee(parametreStockageTrukCacGrpChp.getValues()));
503
			conservationCollectee.setStockageParametre("AUTRE", parametreStockageAutreChp.getValue());
206 jp_milcent 504
 
505
			// COLLECTION COMMUNE
506
			if (collectionCommuneMarkRGrpChp.getValue() != null) {
306 jp_milcent 507
				conservationCollectee.setCollectionCommune(collectionCommuneMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 508
			}
509
			// COLLECTION AUTRE
306 jp_milcent 510
			conservationCollectee.setCollectionAutre(creerChaineDenormalisee(collectionAutreTrukCacGrpChp.getValues()));
511
			conservationCollectee.setCollectionAutre("AUTRE", collectionAutreAutreChp.getValue());
206 jp_milcent 512
 
513
			// ACCÈS CONTROLÉ
514
			if (accesControleMarkRGrpChp.getValue() != null) {
306 jp_milcent 515
				conservationCollectee.setAccesControle(accesControleMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 516
			}
517
 
518
			// RESTAURATION
519
			if (restaurationMarkRGrpChp.getValue() != null) {
306 jp_milcent 520
				conservationCollectee.setRestauration(restaurationMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 521
			}
522
			// RESTAURATION OPÉRATION
306 jp_milcent 523
			conservationCollectee.setRestaurationOperation(creerChaineDenormalisee(opRestauTrukCacGrpChp.getValues()));
524
			conservationCollectee.setRestaurationOperation("AUTRE", opRestauAutreChp.getValue());
206 jp_milcent 525
 
526
			// MATERIEL CONSERVATION
527
			if (materielConservationCeRGrpChp.getValue() != null) {
306 jp_milcent 528
				conservationCollectee.setMaterielConservation(materielConservationCeRGrpChp.getValue().getValueAttribute());
428 jp_milcent 529
 
530
				// MATERIEL AUTRE
531
				conservationCollectee.setMaterielAutre(creerChaineDenormalisee(autreMaterielTrukCacGrpChp.getValues()));
532
				conservationCollectee.setMaterielAutre("AUTRE", autreMaterielAutreChp.getValue());
206 jp_milcent 533
			}
534
 
535
			// TRAITEMENT
536
			if (traitementMarkRGrpChp.getValue() != null) {
306 jp_milcent 537
				conservationCollectee.setTraitement(traitementMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 538
			}
539
			// TRAIEMENTS
306 jp_milcent 540
			conservationCollectee.setTraitements(creerChaineDenormalisee(traitementTrukCacGrpChp.getValues()));
541
			conservationCollectee.setTraitements("AUTRE", traitementAutreChp.getValue());
206 jp_milcent 542
 
543
 
544
			// ACQUISITION COLLECTION
545
			if (collectionAcquisitionMarkRGrpChp.getValue() != null) {
306 jp_milcent 546
				conservationCollectee.setAcquisitionCollection(collectionAcquisitionMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 547
			}
548
 
549
			// ACQUISITION ECHANTILLON
550
			if (echantillonAcquisitionMarkRGrpChp.getValue() != null) {
306 jp_milcent 551
				conservationCollectee.setAcquisitionEchantillon(echantillonAcquisitionMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 552
			}
553
			// ACQUISITION TRAITEMENT
554
			if (traitementAcquisitionMarkRGrpChp.getValue() != null) {
306 jp_milcent 555
				conservationCollectee.setAcquisitionTraitement(traitementAcquisitionMarkRGrpChp.getValue().getValueAttribute());
206 jp_milcent 556
			}
557
			// ACQUISITION TRAITEMENT POISON
306 jp_milcent 558
			conservationCollectee.setAcquisitionTraitementPoison(creerChaineDenormalisee(poisonTraitementTrukCacGrpChp.getValues()));
559
			conservationCollectee.setAcquisitionTraitementPoison("AUTRE", poisonTraitementAutreChp.getValue());
206 jp_milcent 560
			// ACQUISITION TRAITEMENT INSECTE
306 jp_milcent 561
			conservationCollectee.setAcquisitionTraitementInsecte(creerChaineDenormalisee(insecteTraitementTrukCacGrpChp.getValues()));
562
			conservationCollectee.setAcquisitionTraitementInsecte("AUTRE", insecteTraitementAutreChp.getValue());
206 jp_milcent 563
 
564
			// Retour de l'objet
306 jp_milcent 565
			if (!conservationCollectee.comparer(conservation)) {
605 jp_milcent 566
				GWT.log("Collecte différent de Retour", null);
306 jp_milcent 567
				conservationARetourner = conservation = conservationCollectee;
568
			}
192 jp_milcent 569
		}
306 jp_milcent 570
		return conservationARetourner;
188 jp_milcent 571
	}
572
 
192 jp_milcent 573
	private void peuplerStructureConservation() {
605 jp_milcent 574
		if (mode.equals(MODE_AJOUTER)) {
575
			// Indique que l'onglet a pu être modifié pour la méthode collecter...
576
			conservationOnglet.setData("acces", true);
577
			// Initialisation de l'objet Structure
578
			conservation = new StructureConservation();
579
		}
580
		if (mode.equals(MODE_MODIFIER) && conservation != null && conservationOnglet.getData("acces").equals(false)) {
206 jp_milcent 581
			// FORMATION
582
			// Bouton oui, à toujours l'index 0 donc on teste en fonction...
491 gduche 583
			((Radio) formationMarkRGrpChp.get((conservation.getFormation().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 584
			// FORMATION INFO
585
			formationChp.setValue(conservation.getFormationInfo());
586
			// FORMATION INTERET
491 gduche 587
			((Radio) interetFormationMarkRGrpChp.get((conservation.getFormationInteret().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 588
 
589
			// STOCKAGE LOCAL
590
			peuplerCasesACocher(conservation.getStockageLocal(), localStockageTrukCacGrpChp,localStockageAutreChp);
591
 
592
			// STOCKAGE MEUBLE
593
			peuplerCasesACocher(conservation.getStockageMeuble(), meubleStockageTrukCacGrpChp, meubleStockageAutreChp);
594
 
595
			// STOCKAGE PAREMETRE
596
			peuplerCasesACocher(conservation.getStockageParametre(), parametreStockageTrukCacGrpChp, parametreStockageAutreChp);
597
 
598
			// COLLECTION COMMUNE
491 gduche 599
			((Radio) collectionCommuneMarkRGrpChp.get((conservation.getCollectionCommune().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 600
			// COLLECTION AUTRE
601
			peuplerCasesACocher(conservation.getCollectionAutre(), collectionAutreTrukCacGrpChp, collectionAutreAutreChp);
602
 
603
			// ACCÈS CONTROLÉ
491 gduche 604
			((Radio) accesControleMarkRGrpChp.get((conservation.getAccesControle().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 605
 
606
			// RESTAURATION
491 gduche 607
			((Radio) restaurationMarkRGrpChp.get((conservation.getRestauration().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 608
			// RESTAURATION OPÉRATION
609
			peuplerCasesACocher(conservation.getRestaurationOperation(), opRestauTrukCacGrpChp, opRestauAutreChp);
610
 
611
			// MATERIEL CONSERVATION
612
			peuplerBoutonsRadio(conservation.getMaterielConservation(), materielConservationCeRGrpChp);
613
 
614
			// MATERIEL AUTRE
615
			peuplerCasesACocher(conservation.getMaterielAutre(), autreMaterielTrukCacGrpChp, autreMaterielAutreChp);
616
 
617
			// TRAITEMENT
491 gduche 618
			((Radio) traitementMarkRGrpChp.get((conservation.getTraitement().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 619
			// TRAITEMENTS
620
			peuplerCasesACocher(conservation.getTraitements(), traitementTrukCacGrpChp, traitementAutreChp);
621
 
622
			// ACQUISITION COLLECTION
491 gduche 623
			((Radio) collectionAcquisitionMarkRGrpChp.get((conservation.getAcquisitionCollection().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 624
 
625
			// ACQUISITION ECHANTILLON
491 gduche 626
			((Radio) echantillonAcquisitionMarkRGrpChp.get((conservation.getAcquisitionEchantillon().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 627
 
628
			// ACQUISITION TRAITEMENT
491 gduche 629
			((Radio) traitementAcquisitionMarkRGrpChp.get((conservation.getAcquisitionTraitement().equals("1") ? 0 : 1))).setValue(true);
206 jp_milcent 630
			// ACQUISITION TRAITEMENT POISON
631
			peuplerCasesACocher(conservation.getAcquisitionTraitementPoison(), poisonTraitementTrukCacGrpChp, poisonTraitementAutreChp);
632
			// ACQUISITION TRAITEMENT INSECTE
633
			peuplerCasesACocher(conservation.getAcquisitionTraitementInsecte(), insecteTraitementTrukCacGrpChp, insecteTraitementAutreChp);
211 jp_milcent 634
 
243 jp_milcent 635
			// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
636
			conservationOnglet.setData("acces", true);
206 jp_milcent 637
		}
188 jp_milcent 638
	}
639
 
192 jp_milcent 640
	private Structure collecterStructureIdentification() {
306 jp_milcent 641
		Structure structureARetourner = null;
642
		if (identificationOnglet.getData("acces").equals(true)) {
643
 
644
			Structure structureCollectee = (Structure) identification.cloner(new Structure());
645
 
646
			structureCollectee.setId(idStructureChp.getValue());
647
			structureCollectee.setNom(nomStructureChp.getValue());
277 jp_milcent 648
			// Récupération de l'identifiant du projet
649
			if (projetsCombo.getValue() != null) {
306 jp_milcent 650
				structureCollectee.setIdProjet(projetsCombo.getValue().getId());
277 jp_milcent 651
			}
211 jp_milcent 652
			// Récupération de l'acronyme (= identifiant alternatif)
306 jp_milcent 653
			structureCollectee.setIdAlternatif(null);
211 jp_milcent 654
			if (comboAcronyme.getValue() != null) {
655
				String typeAcronyme = comboAcronyme.getValue().getAbr();
656
				if (typeAcronyme == "IH") {
306 jp_milcent 657
					structureCollectee.setIdAlternatif(typeAcronyme+"##"+ihChp.getValue());
211 jp_milcent 658
				} else if (typeAcronyme == "MNHN") {
306 jp_milcent 659
					structureCollectee.setIdAlternatif(typeAcronyme+"##"+mnhnChp.getValue());
211 jp_milcent 660
				}
164 jp_milcent 661
			}
211 jp_milcent 662
			// Récupération statut de la structure
306 jp_milcent 663
			structureCollectee.setTypePublic(null);
664
			structureCollectee.setTypePrive(null);
211 jp_milcent 665
			if (comboTypeStructure.getValue() != null) {
666
				String typeStructure = comboTypeStructure.getValue().getAbr();
667
				if (typeStructure == "stpu" && comboLstpu.getValue() != null) {
306 jp_milcent 668
					structureCollectee.setTypePublic(comboLstpu.getValue().getId());
211 jp_milcent 669
				} else if (typeStructure == "stpr" && comboLstpr.getValue() != null) {
306 jp_milcent 670
					structureCollectee.setTypePrive(comboLstpr.getValue().getId());
211 jp_milcent 671
				}
164 jp_milcent 672
			}
306 jp_milcent 673
			structureCollectee.setDateFondation(dateFondationChp.getValue());
211 jp_milcent 674
 
1171 jpm 675
			structureCollectee.setDescription(descriptionChp.getValue());
676
			structureCollectee.setConditionAcces(conditionAccesChp.getValue());
677
			structureCollectee.setConditionUsage(conditionUsageChp.getValue());
678
 
306 jp_milcent 679
			structureCollectee.setAdresse(adrChp.getValue());
1171 jpm 680
			structureCollectee.setAdresseComplement(adrComplementChp.getValue());
306 jp_milcent 681
			structureCollectee.setCodePostal(cpChp.getValue());
682
			structureCollectee.setVille(villeChp.getValue());
1035 gduche 683
 
684
			String strRegion = "";
685
			Valeur valeurRegion = comboRegion.getValue();
686
			if (valeurRegion == null)	{
687
				strRegion = "AUTRE##" + comboRegion.getRawValue();
688
			} else	{
689
				strRegion = valeurRegion.getId();
690
			}
691
 
692
			structureCollectee.setRegion(strRegion);
306 jp_milcent 693
			structureCollectee.setPays(null);
211 jp_milcent 694
			if (comboPays.getValue() != null) {
419 jp_milcent 695
				structureCollectee.setPays(comboPays.getValue().getId());
211 jp_milcent 696
			} else if (comboPays.getRawValue() != "") {
306 jp_milcent 697
				structureCollectee.setPays(comboPays.getRawValue());
211 jp_milcent 698
			}
1171 jpm 699
			structureCollectee.setLatitude(latitudeChp.getValue());
700
			structureCollectee.setLongitude(longitudeChp.getValue());
211 jp_milcent 701
 
602 jp_milcent 702
			structureCollectee.setTelephoneFixe(telChp.getValue());
306 jp_milcent 703
			structureCollectee.setFax(faxChp.getValue());
704
			structureCollectee.setCourriel(emailChp.getValue());
705
			structureCollectee.setUrl(Structure.URL_SITE, urlChp.getValue());
211 jp_milcent 706
 
263 jp_milcent 707
			if (nbreTotalPersonneStructureChp.getValue() != null) {
306 jp_milcent 708
				structureCollectee.setNbrePersonne(nbreTotalPersonneStructureChp.getValue().intValue());
263 jp_milcent 709
			}
231 jp_milcent 710
 
306 jp_milcent 711
			if (!structureCollectee.comparer(identification)) {
712
				structureARetourner = identification = structureCollectee;
713
			}
714
 
164 jp_milcent 715
		}
1040 gduche 716
 
717
 
718
		System.out.println(structureARetourner);
306 jp_milcent 719
		return structureARetourner;
119 jpm 720
	}
721
 
211 jp_milcent 722
	private void peuplerStructureIdentification() {
295 jp_milcent 723
		if (mode.equals(MODE_AJOUTER)) {
263 jp_milcent 724
			// Indique que l'ongleta pu être modifié pour la méthode collecter...
725
			identificationOnglet.setData("acces", true);
306 jp_milcent 726
			// Initialisation de l'objet Structure
727
			identification = new Structure();
279 jp_milcent 728
			// Indication du projet sélectionné par défaut
729
			String projetCourantId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getProjetId();
295 jp_milcent 730
			if (projetCourantId != null && !projetCourantId.equals("0")) {
279 jp_milcent 731
				projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", projetCourantId));
732
			}
263 jp_milcent 733
		}
295 jp_milcent 734
		if (mode.equals(MODE_MODIFIER) && identification != null && identificationOnglet.getData("acces").equals(false)) {
211 jp_milcent 735
			idStructureChp.setValue(identification.getId());
736
			nomStructureChp.setValue(identification.getNom());
277 jp_milcent 737
			if (!identification.getIdProjet().equals("0")) {
738
				projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", identification.getIdProjet()));
739
			}
740
 
211 jp_milcent 741
			if (!identification.getIdAlternatif().isEmpty()) {
742
				String[] acronyme = identification.getIdAlternatif().split("##");
1043 gduche 743
				//#436 : Ne pas afficher "null"
744
				if (UtilString.isEmpty(acronyme[1]) || acronyme[1].equals("null"))	{
745
					acronyme[1] = "";
746
				}
747
 
211 jp_milcent 748
				if (acronyme[0].matches("^IH$")) {
749
					comboAcronyme.setValue(InterneValeurListe.getTypeAcronymeIH());
750
					ihChp.setValue(acronyme[1]);
751
				} else if (acronyme[0].matches("^MNHN$")) {
752
					comboAcronyme.setValue(InterneValeurListe.getTypeAcronymeMNHN());
753
					mnhnChp.setValue(acronyme[1]);
754
				}
188 jp_milcent 755
			}
211 jp_milcent 756
			if (!identification.getTypePrive().isEmpty()) {
757
				if (identification.getTypePrive().matches("^[0-9]+$")) {
758
					comboTypeStructure.setValue(InterneValeurListe.getTypePrivee());
759
					comboLstpr.setValue(comboLstpr.getStore().findModel("id_valeur", identification.getTypePrive()));
760
				}
761
			} else if (!identification.getTypePublic().isEmpty()) {
762
				if (identification.getTypePublic().matches("^[0-9]+$")) {
763
					comboTypeStructure.setValue(InterneValeurListe.getTypePublique());
764
					comboLstpu.setValue(comboLstpu.getStore().findModel("id_valeur", identification.getTypePublic()));
765
				}
172 jp_milcent 766
			}
211 jp_milcent 767
			dateFondationChp.setValue(identification.getDateFondation());
768
 
1171 jpm 769
			descriptionChp.setValue(identification.getDescription());
770
			conditionAccesChp.setValue(identification.getConditionAcces());
771
			conditionUsageChp.setValue(identification.getConditionUsage());
772
 
211 jp_milcent 773
			adrChp.setValue(identification.getAdresse());
1171 jpm 774
			adrComplementChp.setValue(identification.getAdresseComplement());
211 jp_milcent 775
			cpChp.setValue(identification.getCodePostal());
776
			villeChp.setValue(identification.getVille());
1035 gduche 777
			mettreAJourRegion();
778
			//(identification.getRegion());
419 jp_milcent 779
			if (identification.getPays().matches("^[0-9]+$")) {
780
				comboPays.setValue(comboPays.getStore().findModel("id_valeur", identification.getPays()));
211 jp_milcent 781
			} else {
782
				comboPays.setRawValue(identification.getPays());
172 jp_milcent 783
			}
1171 jpm 784
			latitudeChp.setValue(identification.getLatitude());
785
			longitudeChp.setValue(identification.getLongitude());
211 jp_milcent 786
 
602 jp_milcent 787
			telChp.setValue(identification.getTelephoneFixe());
211 jp_milcent 788
			faxChp.setValue(identification.getFax());
789
			emailChp.setValue(identification.getCourriel());
790
			urlChp.setValue(identification.getUrl("WEB"));
791
 
231 jp_milcent 792
			nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne());
793
 
243 jp_milcent 794
			// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
795
			identificationOnglet.setData("acces", true);
172 jp_milcent 796
		}
156 jp_milcent 797
	}
798
 
111 jpm 799
	private TabItem creerOngletValorisation() {
634 jp_milcent 800
		valorisationOnglet = creerOnglet("Valorisation", "valorisation");
569 jp_milcent 801
		valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP));
634 jp_milcent 802
		Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() {
803
			public void handleEvent(ComponentEvent be) {
192 jp_milcent 804
				peuplerStructureValorisation();
634 jp_milcent 805
				valorisationOnglet.layout();
806
			}
807
		};
808
		valorisationOnglet.addListener(Events.Select, ecouteurSelection);
111 jpm 809
 
119 jpm 810
		actionMarkRGrpChp = creerChoixUniqueRadioGroupe("action_mark", "ouiNon");
111 jpm 811
		actionMarkRGrpChp.setFieldLabel("Avez-vous réalisé des actions de valorisation de vos collections botaniques ou avez-vous été sollicités pour la valorisation de ces collections ?");
812
		valorisationOnglet.add(actionMarkRGrpChp);
813
 
119 jpm 814
 
569 jp_milcent 815
		actionTrukCp = creerChoixMultipleCp();
111 jpm 816
		actionTrukCp.hide();
115 jpm 817
		actionTrukCacGrpChp = new CheckBoxGroup();
818
		actionTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");
111 jpm 819
		valorisationOnglet.add(actionTrukCp);
569 jp_milcent 820
		mediateur.obtenirListeValeurEtRafraichir(this, "actionValorisation");
111 jpm 821
 
206 jp_milcent 822
		publicationChp = new TextArea();
111 jpm 823
		publicationChp.setFieldLabel("Quelques titres des ouvrages, articles scientifiques, ...");
206 jp_milcent 824
		valorisationOnglet.add(publicationChp, new FormData(550, 0));
111 jpm 825
 
569 jp_milcent 826
		autreCollectionTrukCp = creerChoixMultipleCp();
119 jpm 827
		autreCollectionTrukCacGrpChp = new CheckBoxGroup();
828
		autreCollectionTrukCacGrpChp.setFieldLabel("L'organisme dispose-t-il d'autres collections (permettant une valorisation pluridisciplinaire) ?");
111 jpm 829
		valorisationOnglet.add(autreCollectionTrukCp);
569 jp_milcent 830
		mediateur.obtenirListeValeurEtRafraichir(this, "autreCollection");
111 jpm 831
 
188 jp_milcent 832
		futureActionMarkRGrpChp = creerChoixUniqueRadioGroupe("future_action_mark", "ouiNon");
111 jpm 833
		futureActionMarkRGrpChp.setFieldLabel("Envisagez vous des actions de valorisation dans le cadre de votre politique culturelle ?");
834
		valorisationOnglet.add(futureActionMarkRGrpChp);
835
 
206 jp_milcent 836
		futureActionChp = new TextArea();
111 jpm 837
		futureActionChp.setFieldLabel("Si oui, lesquelles ?");
838
		futureActionChp.hide();
306 jp_milcent 839
		futureActionChp.addListener(Events.Hide, new Listener<BaseEvent>() {
840
 
841
			public void handleEvent(BaseEvent be) {
491 gduche 842
				((TextArea) be.getSource()).setValue("");
306 jp_milcent 843
			}
844
 
845
		});
206 jp_milcent 846
		valorisationOnglet.add(futureActionChp, new FormData(550, 0));
111 jpm 847
 
188 jp_milcent 848
		rechercheMarkRGrpChp = creerChoixUniqueRadioGroupe("recherche_mark", "ouiNon");
111 jpm 849
		rechercheMarkRGrpChp.setFieldLabel("Vos collections botaniques sont-elles utilisées pour des recherches scientifiques ?");
850
		valorisationOnglet.add(rechercheMarkRGrpChp);
851
 
569 jp_milcent 852
		provenanceRechercheTrukCp = creerChoixMultipleCp();
111 jpm 853
		provenanceRechercheTrukCp.hide();
115 jpm 854
		provenanceRechercheTrukCacGrpChp = new CheckBoxGroup();
855
		provenanceRechercheTrukCacGrpChp.setFieldLabel("Si oui, par des chercheurs (professionnels ou amateurs) de quelle provenance ?");
111 jpm 856
		valorisationOnglet.add(provenanceRechercheTrukCp);
614 jp_milcent 857
		mediateur.obtenirListeValeurEtRafraichir(this, "continentEtFr");
111 jpm 858
 
569 jp_milcent 859
		typeRechercheTrukCp = creerChoixMultipleCp();
119 jpm 860
		typeRechercheTrukCp.hide();
115 jpm 861
		typeRechercheTrukCacGrpChp = new CheckBoxGroup();
862
		typeRechercheTrukCacGrpChp.setFieldLabel("Et pour quelles recherches ?");
119 jpm 863
		valorisationOnglet.add(typeRechercheTrukCp);
569 jp_milcent 864
		mediateur.obtenirListeValeurEtRafraichir(this, "typeRecherche");
111 jpm 865
 
188 jp_milcent 866
		sansMotifAccesMarkRGrpChp = creerChoixUniqueRadioGroupe("sans_motif_acces_mark", "ouiNon");
111 jpm 867
		sansMotifAccesMarkRGrpChp.setFieldLabel("Peut-on consulter vos collections botaniques sans motif de recherches scientifiques ?");
868
		valorisationOnglet.add(sansMotifAccesMarkRGrpChp);
869
 
206 jp_milcent 870
		valorisationOnglet.add(sansMotifAccesChp = new TextArea(), new FormData(550, 0));
111 jpm 871
		sansMotifAccesChp.hide();
306 jp_milcent 872
		sansMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() {
873
 
874
			public void handleEvent(BaseEvent be) {
491 gduche 875
				((TextArea) be.getSource()).setValue("");
306 jp_milcent 876
			}
877
 
878
		});
111 jpm 879
		sansMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les consulter ?");
880
 
188 jp_milcent 881
		avecMotifAccesMarkRGrpChp = creerChoixUniqueRadioGroupe("avec_motif_acces_mark", "ouiNon");
111 jpm 882
		avecMotifAccesMarkRGrpChp.setFieldLabel("Peut-on visiter vos collections botaniques avec des objectifs de recherches scientifiques ?");
883
		valorisationOnglet.add(avecMotifAccesMarkRGrpChp);
884
 
206 jp_milcent 885
		valorisationOnglet.add(avecMotifAccesChp = new TextArea(), new FormData(550, 0));
111 jpm 886
		avecMotifAccesChp.hide();
306 jp_milcent 887
		avecMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() {
888
 
889
			public void handleEvent(BaseEvent be) {
491 gduche 890
				((TextArea) be.getSource()).setValue("");
306 jp_milcent 891
			}
892
 
893
		});
111 jpm 894
		avecMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les visiter ?");
895
 
896
		return valorisationOnglet;
897
	}
898
 
108 jpm 899
	private TabItem creerOngletConservation() {
634 jp_milcent 900
		conservationOnglet = creerOnglet("Conservation", "conservation");
569 jp_milcent 901
		conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP));
634 jp_milcent 902
		Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() {
903
			public void handleEvent(ComponentEvent be) {
206 jp_milcent 904
				peuplerStructureConservation();
279 jp_milcent 905
				conservationOnglet.layout();
192 jp_milcent 906
			}
634 jp_milcent 907
		};
908
		conservationOnglet.addListener(Events.Select, ecouteurSelection);
108 jpm 909
 
188 jp_milcent 910
		formationMarkRGrpChp = creerChoixUniqueRadioGroupe("formation_mark", "ouiNon");
911
		formationMarkRGrpChp.setFieldLabel("Le personnel s'occupant des collections a-t-il suivi des formations en conservations ?");
912
		conservationOnglet.add(formationMarkRGrpChp);
108 jpm 913
 
401 jp_milcent 914
		formationChp = new TextArea();
111 jpm 915
		formationChp.hide();
306 jp_milcent 916
		formationChp.addListener(Events.Hide, new Listener<BaseEvent>() {
917
 
918
			public void handleEvent(BaseEvent be) {
491 gduche 919
				((TextArea) be.getSource()).setValue("");
306 jp_milcent 920
			}
921
 
922
		});
111 jpm 923
		formationChp.setFieldLabel("Si oui, lesquelles ?");
108 jpm 924
		conservationOnglet.add(formationChp);
925
 
188 jp_milcent 926
		interetFormationMarkRGrpChp = creerChoixUniqueRadioGroupe("interet_formation_mark", "ouiNon");
927
		interetFormationMarkRGrpChp.setFieldLabel("Seriez vous intéressé par une formation à la conservation et à la restauration d'herbier ?");
928
		conservationOnglet.add(interetFormationMarkRGrpChp);
108 jpm 929
 
115 jpm 930
		localStockageTrukCacGrpChp = new CheckBoxGroup();
931
		localStockageTrukCacGrpChp.setFieldLabel("Avez vous des locaux spécifiques de stockage des collections botaniques ?");
569 jp_milcent 932
		localStockageTrukCp = creerChoixMultipleCp();
115 jpm 933
		conservationOnglet.add(localStockageTrukCp);
569 jp_milcent 934
		mediateur.obtenirListeValeurEtRafraichir(this, "localStockage");
108 jpm 935
 
569 jp_milcent 936
		meubleStockageTrukCp = creerChoixMultipleCp();
115 jpm 937
		meubleStockageTrukCacGrpChp = new CheckBoxGroup();
938
		meubleStockageTrukCacGrpChp.setFieldLabel("Avez vous des meubles spécifiques au stockage des collections botaniques ?");
939
		conservationOnglet.add(meubleStockageTrukCp);
569 jp_milcent 940
		mediateur.obtenirListeValeurEtRafraichir(this, "meubleStockage");
108 jpm 941
 
569 jp_milcent 942
		parametreStockageTrukCp = creerChoixMultipleCp();
115 jpm 943
		parametreStockageTrukCacGrpChp = new CheckBoxGroup();
944
		parametreStockageTrukCacGrpChp.setFieldLabel("Quels paramètres maîtrisez vous ?");
945
		conservationOnglet.add(parametreStockageTrukCp);
569 jp_milcent 946
		mediateur.obtenirListeValeurEtRafraichir(this, "parametreStockage");
109 jpm 947
 
188 jp_milcent 948
		collectionCommuneMarkRGrpChp = creerChoixUniqueRadioGroupe("collection_commune_mark", "ouiNon");
111 jpm 949
		collectionCommuneMarkRGrpChp.setFieldLabel("Les collections botaniques sont-elles conservées avec d'autres collections  dans les mêmes locaux (problème de conservation en commun) ?");
950
		conservationOnglet.add(collectionCommuneMarkRGrpChp);
109 jpm 951
 
569 jp_milcent 952
		collectionAutreTrukCp = creerChoixMultipleCp();
115 jpm 953
		collectionAutreTrukCacGrpChp = new CheckBoxGroup();
954
		collectionAutreTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");
111 jpm 955
		collectionAutreTrukCp.hide();
956
		conservationOnglet.add(collectionAutreTrukCp);
569 jp_milcent 957
		mediateur.obtenirListeValeurEtRafraichir(this, "autreCollection");
110 jpm 958
 
188 jp_milcent 959
		accesControleMarkRGrpChp = creerChoixUniqueRadioGroupe("mark_acces_controle", "ouiNon");
115 jpm 960
		accesControleMarkRGrpChp.setFieldLabel("L'accès à vos collections botanique est-il contrôlé (ex. : manipulation réservées à des personnes compétentes) ?");
961
		conservationOnglet.add(accesControleMarkRGrpChp);
110 jpm 962
 
188 jp_milcent 963
		restaurationMarkRGrpChp = creerChoixUniqueRadioGroupe("restauration_mark", "ouiNon");
115 jpm 964
		restaurationMarkRGrpChp.setFieldLabel("Effectuez vous des opérations de restauration ou de remise en état de vos collections botaniques ?");
965
		conservationOnglet.add(restaurationMarkRGrpChp);
110 jpm 966
 
569 jp_milcent 967
		opRestauTrukCp = creerChoixMultipleCp();
115 jpm 968
		opRestauTrukCacGrpChp = new CheckBoxGroup();
969
		opRestauTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");
111 jpm 970
		opRestauTrukCp.hide();
971
		conservationOnglet.add(opRestauTrukCp);
569 jp_milcent 972
		mediateur.obtenirListeValeurEtRafraichir(this, "opRestau");
110 jpm 973
 
188 jp_milcent 974
		// Création d'un ContentPanel vide et du groupe de bouton radio
975
		// Le groupe de bouton radio recevra les boutons au moment de la réception des données (rafraichir()) et ser à ce moment là ajouter au ContenetPanel
569 jp_milcent 976
		materielConservationCp = creerChoixMultipleCp();
188 jp_milcent 977
		conservationOnglet.add(materielConservationCp);
115 jpm 978
		materielConservationCeRGrpChp = creerChoixUniqueRadioGroupe("materiel_conservation_ce", "onep");
979
		materielConservationCeRGrpChp.setFieldLabel("Utilisez vous du matériel de conservation ?");
980
		materielConservationCeRGrpChp.setToolTip(new ToolTipConfig("Matériel de conservation", "matériel spécialisé pour la conservation des archives ou du patrimoine fragile. Ce matériel possède des propriétés mécaniques et chimiques qui font qu'il résiste dans le temps et que sa dégradation n'entraîne pas de dommages sur le matériel qu'il aide à conserver. Exemples : papier neutre, papier gommé, etc..."));
569 jp_milcent 981
		mediateur.obtenirListeValeurEtRafraichir(this, "onep");
110 jpm 982
 
569 jp_milcent 983
		autreMaterielTrukCp = creerChoixMultipleCp();
115 jpm 984
		autreMaterielTrukCacGrpChp = new CheckBoxGroup();
985
		autreMaterielTrukCacGrpChp.setFieldLabel("Si non, qu'utilisez vous comme matériel ?");
428 jp_milcent 986
		autreMaterielTrukCp.hide();
115 jpm 987
		conservationOnglet.add(autreMaterielTrukCp);
569 jp_milcent 988
		mediateur.obtenirListeValeurEtRafraichir(this, "autreMateriel");
110 jpm 989
 
188 jp_milcent 990
		traitementMarkRGrpChp = creerChoixUniqueRadioGroupe("traitement_mark", "ouiNon");
991
		traitementMarkRGrpChp.setFieldLabel("Réalisez vous actuellement des traitements globaux contre les insectes ?");
992
		conservationOnglet.add(traitementMarkRGrpChp);
110 jpm 993
 
569 jp_milcent 994
		traitementTrukCp = creerChoixMultipleCp();
115 jpm 995
		traitementTrukCp.hide();
996
		traitementTrukCacGrpChp = new CheckBoxGroup();
997
		traitementTrukCacGrpChp.setFieldLabel("Si oui, lesquels ?");
111 jpm 998
		conservationOnglet.add(traitementTrukCp);
569 jp_milcent 999
		mediateur.obtenirListeValeurEtRafraichir(this, "insecteTraitement");
110 jpm 1000
 
188 jp_milcent 1001
		collectionAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("collection_acquisition_mark", "ouiNon");
1002
		collectionAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, vos collections botaniques s'accroissent-elles de nouvelles acquisitions ?");
1003
		conservationOnglet.add(collectionAcquisitionMarkRGrpChp);
110 jpm 1004
 
188 jp_milcent 1005
		echantillonAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("echantillon_acquisition_mark", "ouiNon");
1006
		echantillonAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, mettez vous en herbier de nouveaux échantillons ?");
1007
		conservationOnglet.add(echantillonAcquisitionMarkRGrpChp);
110 jpm 1008
 
115 jpm 1009
		traitementAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("traitement_acquisition_mark", "ouiNon");
1010
		traitementAcquisitionMarkRGrpChp.hide();
1011
		traitementAcquisitionMarkRGrpChp.setFieldLabel("Si oui, faites-vous un traitement contre les insectes avant l'intégration dans vos collections ?");
1012
		conservationOnglet.add(traitementAcquisitionMarkRGrpChp);
110 jpm 1013
 
115 jpm 1014
		traitementAcquisitionMarkLabel = new LabelField();
1015
		traitementAcquisitionMarkLabel.hide();
1016
		traitementAcquisitionMarkLabel.setFieldLabel("Si oui, lesquels ?");
1017
		conservationOnglet.add(traitementAcquisitionMarkLabel);
110 jpm 1018
 
569 jp_milcent 1019
		poisonTraitementTrukCp = creerChoixMultipleCp();
115 jpm 1020
		poisonTraitementTrukCp.hide();
1021
		poisonTraitementTrukCacGrpChp = new CheckBoxGroup();
1022
		poisonTraitementTrukCacGrpChp.setFieldLabel("Empoisonnement");
1023
		poisonTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;");
1024
		poisonTraitementTrukCacGrpChp.setLabelSeparator("");
1025
		conservationOnglet.add(poisonTraitementTrukCp);
569 jp_milcent 1026
		mediateur.obtenirListeValeurEtRafraichir(this, "poisonTraitement");
110 jpm 1027
 
569 jp_milcent 1028
		insecteTraitementTrukCp = creerChoixMultipleCp();
115 jpm 1029
		insecteTraitementTrukCp.hide();
1030
		insecteTraitementTrukCacGrpChp = new CheckBoxGroup();
1031
		insecteTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;");
1032
		insecteTraitementTrukCacGrpChp.setLabelSeparator("");
1033
		insecteTraitementTrukCacGrpChp.setFieldLabel("Désinsectisation");
111 jpm 1034
		conservationOnglet.add(insecteTraitementTrukCp);
569 jp_milcent 1035
		mediateur.obtenirListeValeurEtRafraichir(this, "insecteTraitement");
110 jpm 1036
 
579 jp_milcent 1037
		conservationOnglet.add(new Html("<br />"));
108 jpm 1038
		return conservationOnglet;
1039
	}
1040
 
231 jp_milcent 1041
	private void collecterStructurePersonnel() {
1042
		if (personnelOnglet.getData("acces").equals(true)) {
771 jpm 1043
			personnelGrilleMagazin.commitChanges();
231 jp_milcent 1044
			int nbrePersonne = personnelGrilleMagazin.getCount();
1045
			for (int i = 0; i < nbrePersonne; i++) {
1046
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
1208 cyprien 1047
 
1048
Debug.log(":::> StructureForm.collecterStructurePersonnel()");
1049
Debug.log(":::> etat="+personne.get("etat"));
771 jpm 1050
 
231 jp_milcent 1051
				// Seules les lignes ajoutées ou modifiées sont prises en compte.
771 jpm 1052
				Record record = personnelGrilleMagazin.getRecord(personne);
1053
				if (personnelGrilleMagazin.getModifiedRecords().contains(record) == true
1208 cyprien 1054
						|| (personne.get("etat") != null && (personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE) || personne.get("etat").equals(StructureAPersonne.ETAT_MODIFIE)) )) {
245 jp_milcent 1055
 
1056
					// Gestion de l'id de la structure
1057
					if (mode.equals("MODIF")) {
1058
						personne.setIdStructure(identification.getId());
1059
					}
609 jp_milcent 1060
 
1061
					// Récupération de l'id du projet de la structure qui servira aussi pour les Personnes crées dans ce formulaire
1062
					if (personne.getIdPersonne().equals("") && projetsCombo.getValue() != null) {
1063
						personne.setIdProjetPersonne(projetsCombo.getValue().getId());
1064
					}
1065
 
231 jp_milcent 1066
					// Gestion de la fonction
1067
					String fonction = personne.get("fonction");
1068
					if (fonction != null && !fonction.equals("")) {
295 jp_milcent 1069
						Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction);
231 jp_milcent 1070
						if (valeurRecherche != null) {
1071
							personne.setFonction(valeurRecherche.getId());
1072
						} else {
1073
							personne.setFonction("AUTRE", fonction);
1074
						}
602 jp_milcent 1075
					} else {
1076
						personne.setFonction("");
231 jp_milcent 1077
					}
1208 cyprien 1078
 
1079
					// Gestion du nom complet
1080
					String nomComplet = personne.getPrenom()+" "+personne.getNom();
1081
					personne.setNomComplet(nomComplet);
231 jp_milcent 1082
 
1083
					// Gestion de la notion de "contact"
1084
					personne.setContact(false);
1085
					if (personne.get("contact").equals(true)) {
1086
						personne.setContact(true);
1087
					}
1088
 
1089
					// Gestion du statut
1090
					String statut = personne.get("statut");
1091
					if (statut != null && !statut.equals("")) {
1092
						Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut);
1093
						if (valeurRecherche != null) {
1094
							personne.setStatut(valeurRecherche.getId());
1095
						} else {
1096
							personne.setStatut("AUTRE", statut);
1097
						}
602 jp_milcent 1098
					} else {
1099
						personne.setStatut("");
231 jp_milcent 1100
					}
1101
 
1102
					// Gestion du temps de travail
602 jp_milcent 1103
					personne.setBotaTravailHebdoTps(personne.get("travail").toString());
231 jp_milcent 1104
 
1105
					// Gestion du téléphone
602 jp_milcent 1106
					String telephoneFixe = personne.get("tel_fix");
1107
					personne.setTelephoneFixe(telephoneFixe);
231 jp_milcent 1108
 
1109
					// Gestion du fax
602 jp_milcent 1110
					String fax = personne.get("tel_fax");
1111
					personne.setFax(fax);
1112
 
231 jp_milcent 1113
					// Gestion du courriel
1114
					String courriel = personne.get("courriel");
602 jp_milcent 1115
					personne.setCourriel(courriel);
231 jp_milcent 1116
 
602 jp_milcent 1117
					// Gestion de la spécialité
231 jp_milcent 1118
					String specialite = personne.get("specialite");
602 jp_milcent 1119
					personne.setSpecialite(specialite);
231 jp_milcent 1120
 
1121
					// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)
771 jpm 1122
					if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) {// Une personne ajoutée
231 jp_milcent 1123
						personnelAjoute.put(""+i, personne);
1124
					} else {// Une personne modifiée
1125
						personnelModifie.put(personne.getId(), personne);
1126
					}
245 jp_milcent 1127
				} else {
1128
					GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null);
231 jp_milcent 1129
				}
1130
			}
1131
		}
1132
	}
211 jp_milcent 1133
 
1134
	private void peuplerStructurePersonnel() {
295 jp_milcent 1135
		if (mode.equals(MODE_MODIFIER) && personnel != null) {
213 jp_milcent 1136
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
1137
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
1138
				String index = it.next();
231 jp_milcent 1139
 
1140
				// Gestion de la fonction
295 jp_milcent 1141
				if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {
1142
					if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) {
1143
						personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
243 jp_milcent 1144
					}
213 jp_milcent 1145
				} else {
214 jp_milcent 1146
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
213 jp_milcent 1147
				}
231 jp_milcent 1148
 
1149
				// Gestion de la notion de "contact"
1150
				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
1151
 
1152
				// Gestion du statut
1153
				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
1154
					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
1155
				} else {
1156
					personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", ""));
1157
				}
1158
 
1208 cyprien 1159
				// Gestion de la specialite
1160
				if (((String) personnel.get(index).getSpecialite()).matches("^[0-9]+$")) {
1161
					// Author : Cyprien
1162
					// TODO
1163
					// Ici faire un combobox ?
1164
					// ...
1165
				} else {
1166
					personnel.get(index).set("specialite", personnel.get(index).getSpecialite().replaceFirst("AUTRE##", ""));
1167
				}
1168
 
231 jp_milcent 1169
				// Gestion du temps de travail
1170
				String tps = personnel.get(index).getBotaTravailHebdoTps();
1171
				personnel.get(index).set("travail", (tps.matches("^[0-9]+$")  ? Integer.parseInt(tps) : 0));
1172
 
213 jp_milcent 1173
				personnes.add(personnel.get(index));
1174
			}
211 jp_milcent 1175
			personnelGrilleMagazin.removeAll();
213 jp_milcent 1176
			personnelGrilleMagazin.add(personnes);
231 jp_milcent 1177
 
214 jp_milcent 1178
			// Nous vidons la variable personnel une fois qu'elle a remplie la grille
1179
			personnel = null;
211 jp_milcent 1180
		}
1181
	}
1182
 
103 jpm 1183
	private TabItem creerOngletPersonnel() {
306 jp_milcent 1184
		// Création des objets contenant les manipulations de la grille
1185
		personnelModifie = new StructureAPersonneListe();
1186
		personnelAjoute = new StructureAPersonneListe();
1187
		personnelSupprime = new StructureAPersonneListe();
1188
 
634 jp_milcent 1189
		personnelOnglet = creerOnglet("Personnel", "personnel");
569 jp_milcent 1190
		personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT));
739 jpm 1191
		personnelOnglet.setStyleAttribute("padding", "0");
634 jp_milcent 1192
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
1193
			public void handleEvent(ComponentEvent be) {
1208 cyprien 1194
 
1195
Debug.log(":::> StructureForm.creerOngletPersonnel.HandleEvent()");
1196
 
211 jp_milcent 1197
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
1198
				personnelOnglet.setData("acces", true);
306 jp_milcent 1199
 
609 jp_milcent 1200
				// Rafraichissement du contenu de la grille du personnel
1201
				if (mode.equals(MODE_AJOUTER)) {
1202
					rafraichirPersonnel();
1203
				}
1215 cyprien 1204
				/*
1208 cyprien 1205
				else {
1206
					initialiserGrillePersonnelEnModification();
1207
				}
1215 cyprien 1208
				*/
211 jp_milcent 1209
			}
1210
		});
103 jpm 1211
 
211 jp_milcent 1212
		ContentPanel cp = new ContentPanel();
231 jp_milcent 1213
		cp.setHeading("Personnes travaillant sur les collections");
569 jp_milcent 1214
		cp.setIcon(Images.ICONES.table());
231 jp_milcent 1215
		//cp.setScrollMode(Scroll.AUTO);
1216
		cp.setLayout(new FitLayout());
559 jp_milcent 1217
		//cp.setWidth(1250);
1218
		//cp.setHeight("100%");
231 jp_milcent 1219
		cp.setFrame(true);
103 jpm 1220
 
231 jp_milcent 1221
		personnelGrilleMagazin = new ListStore<StructureAPersonne>();
1208 cyprien 1222
		personnelGrilleMagazin.setMonitorChanges(true);
1223
 
245 jp_milcent 1224
		personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() {
1225
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
1226
				// Activation du bouton supprimer si la grille contient un élément
1227
				if (grillePersonnel.getStore().getCount() > 0) {
1228
					supprimerPersonnelBtn.enable();
1229
				}
1230
 
1231
			}
1232
		});
231 jp_milcent 1233
 
1208 cyprien 1234
		/* TODELETE
1235
		personnelGrilleMagazin.addListener(Store.Update, new Listener<StoreEvent<StructureAPersonne>>() {
1236
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
1237
 
1238
				personnelGrilleMagazin.getAt(ce.getIndex()).set("etat", StructureAPersonne.ETAT_MODIFIE);
1239
				Debug.log("Modification de : "+personnelGrilleMagazin.getAt(ce.getIndex()).getNom());
1240
			}
1241
		});
1242
		*/
1243
 
1244
 
231 jp_milcent 1245
		RowNumberer r = new RowNumberer();
1246
 
102 jpm 1247
		List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
1248
 
231 jp_milcent 1249
		GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>();
1250
		configs.add(r);
103 jpm 1251
 
214 jp_milcent 1252
		ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150);
295 jp_milcent 1253
		fonctionsMagazin = new ListStore<Valeur>();
103 jpm 1254
 
295 jp_milcent 1255
		fonctionsCombo = new ComboBox<Valeur>();
1256
		fonctionsCombo.setTriggerAction(TriggerAction.ALL);
1257
		fonctionsCombo.setEditable(true);
1258
		fonctionsCombo.setDisplayField("nom");
1259
		fonctionsCombo.setStore(fonctionsMagazin);
569 jp_milcent 1260
		mediateur.obtenirListeValeurEtRafraichir(this, "fonction");
103 jpm 1261
 
295 jp_milcent 1262
		fonctionEditor = new CellEditor(fonctionsCombo) {
103 jpm 1263
			@Override
211 jp_milcent 1264
			public Object preProcessValue(Object valeur) {
295 jp_milcent 1265
				Valeur retour = null;
1266
 
1267
				if (valeur != null) {
1268
					String chaineTransmise = (String) valeur;
1269
					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
1270
						fonctionsMagazin.add(fonctionsListe);
1271
					}
1272
					if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) {
1273
						retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise);
1274
					} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) {
1275
						retour = fonctionsMagazin.findModel("nom", chaineTransmise);
213 jp_milcent 1276
					} else {
295 jp_milcent 1277
						retour = new Valeur("", chaineTransmise, "", "");
213 jp_milcent 1278
					}
211 jp_milcent 1279
				}
213 jp_milcent 1280
 
211 jp_milcent 1281
				return retour;
103 jpm 1282
			}
1283
 
1284
			@Override
211 jp_milcent 1285
			public Object postProcessValue(Object valeur) {
295 jp_milcent 1286
				String retour = "";
1287
				Valeur fonctionTrouvee = null;
211 jp_milcent 1288
				if (valeur == null) {
295 jp_milcent 1289
					String valeurBrute = this.getField().getRawValue();
1290
					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
1291
						fonctionsMagazin.add(fonctionsListe);
213 jp_milcent 1292
					}
295 jp_milcent 1293
					if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) {
1294
						fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute);
1295
					} else {
1296
						retour = valeurBrute;
211 jp_milcent 1297
					}
295 jp_milcent 1298
				} else if (valeur instanceof Valeur) {
1299
					fonctionTrouvee = (Valeur) valeur;
103 jpm 1300
				}
295 jp_milcent 1301
 
1302
				if (fonctionTrouvee != null) {
1303
					retour = fonctionTrouvee.getNom();
1304
				}
1305
 
1306
				return retour;
211 jp_milcent 1307
			}
103 jpm 1308
		};
1309
		column.setEditor(fonctionEditor);
102 jpm 1310
		configs.add(column);
1311
 
243 jp_milcent 1312
		column = new ColumnConfig("prenom", "Prénom", 100);
103 jpm 1313
		TextField<String> prenomChp = new TextField<String>();
1314
		prenomChp.setAllowBlank(false);
1315
		prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");
980 jpm 1316
		prenomChp.setAutoValidate(true);
981 jpm 1317
		prenomChp.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 1318
		prenomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
103 jpm 1319
		column.setEditor(new CellEditor(prenomChp));
102 jpm 1320
		configs.add(column);
1321
 
243 jp_milcent 1322
		column = new ColumnConfig("nom", "Nom", 100);
103 jpm 1323
		TextField<String> nomChp = new TextField<String>();
1324
		nomChp.setAllowBlank(false);
1325
		nomChp.getMessages().setBlankText("Ce champ est obligatoire.");
980 jpm 1326
		nomChp.setAutoValidate(true);
981 jpm 1327
		nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 1328
		nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
103 jpm 1329
		column.setEditor(new CellEditor(nomChp));
102 jpm 1330
		configs.add(column);
1331
 
602 jp_milcent 1332
		column = new ColumnConfig("tel_fix", "Téléphone fixe", 100);
103 jpm 1333
		TextField<String> telChp = new TextField<String>();
1334
		column.setEditor(new CellEditor(telChp));
102 jpm 1335
		configs.add(column);
1336
 
602 jp_milcent 1337
		column = new ColumnConfig("tel_fax", "Fax", 100);
103 jpm 1338
		TextField<String> faxChp = new TextField<String>();
1339
		column.setEditor(new CellEditor(faxChp));
102 jpm 1340
		configs.add(column);
1341
 
214 jp_milcent 1342
		column = new ColumnConfig("courriel", "Courriel principal", 200);
103 jpm 1343
		TextField<String> emailChp = new TextField<String>();
1344
		column.setEditor(new CellEditor(emailChp));
102 jpm 1345
		configs.add(column);
1346
 
103 jpm 1347
		magazinLiStatut = new ListStore<Valeur>();
1348
		magazinLiStatut.add(new ArrayList<Valeur>());
1349
 
1350
		comboLiStatut = new ComboBox<Valeur>();
1351
		comboLiStatut.setTriggerAction(TriggerAction.ALL);
1352
		comboLiStatut.setEditable(false);
214 jp_milcent 1353
		comboLiStatut.disableTextSelection(true);
103 jpm 1354
		comboLiStatut.setDisplayField("nom");
1355
		comboLiStatut.setStore(magazinLiStatut);
569 jp_milcent 1356
		mediateur.obtenirListeValeurEtRafraichir(this, "statut");
103 jpm 1357
 
1358
		CellEditor statutEditor = new CellEditor(comboLiStatut) {
1359
			@Override
1360
			public Object preProcessValue(Object value) {
1361
				if (value == null) {
1362
					return value;
1363
				}
1364
				return comboLiStatut.getStore().findModel("nom", (String) value);
1365
			}
1366
 
1367
			@Override
1368
			public Object postProcessValue(Object value) {
1369
				if (value == null) {
1370
					return value;
1371
				}
1372
				return ((Valeur) value).get("nom");
1373
			}
214 jp_milcent 1374
		};
103 jpm 1375
		column = new ColumnConfig("statut", "Statut", 100);
1376
		column.setEditor(statutEditor);
102 jpm 1377
		configs.add(column);
1378
 
211 jp_milcent 1379
		column = new ColumnConfig("travail", "Temps travail", 100);
103 jpm 1380
		column.setNumberFormat(NumberFormat.getFormat("##"));
1381
		NumberField tpsWChp = new NumberField();
1382
		tpsWChp.setFormat(NumberFormat.getFormat("##"));
1383
		tpsWChp.setToolTip("Ce champ doit contenir un nombre");
1384
		column.setEditor(new CellEditor(tpsWChp));
1385
		configs.add(column);
1386
 
211 jp_milcent 1387
		column = new ColumnConfig("specialite", "Spécialité principale", 150);
103 jpm 1388
		TextField<String> speChp = new TextField<String>();
1389
		column.setEditor(new CellEditor(speChp));
1390
		configs.add(column);
1391
 
211 jp_milcent 1392
		CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
102 jpm 1393
		configs.add(checkColumn);
1394
 
1395
		ToolBar toolBar = new ToolBar();
103 jpm 1396
 
491 gduche 1397
		Button ajouterPersonnelBtn = new Button("Ajouter");
569 jp_milcent 1398
		ajouterPersonnelBtn.setIcon(Images.ICONES.vcardAjouter());
491 gduche 1399
		ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
103 jpm 1400
			@Override
491 gduche 1401
			public void componentSelected(ButtonEvent ce) {
295 jp_milcent 1402
				StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
1403
				ajouterMembreAGrillePersonnel(membreDuPersonnel);
103 jpm 1404
			}
1405
		});
1406
		toolBar.add(ajouterPersonnelBtn);
243 jp_milcent 1407
 
103 jpm 1408
		toolBar.add(new SeparatorToolItem());
243 jp_milcent 1409
 
491 gduche 1410
		supprimerPersonnelBtn = new Button("Supprimer");
569 jp_milcent 1411
		supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer());
491 gduche 1412
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
103 jpm 1413
			@Override
491 gduche 1414
			public void componentSelected(ButtonEvent ce) {
231 jp_milcent 1415
				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
1416
				if (personne != null) {
1417
					// Ajout de la personne supprimée à la liste
243 jp_milcent 1418
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
231 jp_milcent 1419
						personnelSupprime.put(personne.getId(), personne);
1420
					}
1421
 
1422
					// Suppression de l'enregistrement de la grille
1423
					grillePersonnel.getStore().remove(personne);
1424
 
1425
					// Désactivation du bouton supprimer si la grille contient plus d'élément
1426
					if (grillePersonnel.getStore().getCount() == 0) {
491 gduche 1427
						//TODO : check : Item -> component
1428
						ce.getComponent().disable();
231 jp_milcent 1429
					}
1430
				}
103 jpm 1431
			}
1432
		});
243 jp_milcent 1433
		toolBar.add(supprimerPersonnelBtn);
1434
 
1435
		toolBar.add(new SeparatorToolItem());
1436
 
491 gduche 1437
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
569 jp_milcent 1438
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
491 gduche 1439
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
243 jp_milcent 1440
			@Override
491 gduche 1441
			public void componentSelected(ButtonEvent ce) {
243 jp_milcent 1442
				rafraichirPersonnel();
1443
			}
1444
		});
1445
		toolBar.add(rafraichirPersonnelBtn);
1446
 
1447
		toolBar.add(new SeparatorToolItem());
1448
 
1449
		personneExistanteMagazin = new ListStore<Personne>();
1450
		personneExistanteMagazin.add(new ArrayList<Personne>());
1451
 
245 jp_milcent 1452
		personneExistanteCombo = new ComboBox<Personne>();
243 jp_milcent 1453
		personneExistanteCombo.setWidth(200);
1454
		personneExistanteCombo.setEmptyText("Chercher une personne existante...");
1455
		personneExistanteCombo.setTriggerAction(TriggerAction.ALL);
1456
		personneExistanteCombo.setEditable(true);
1457
		personneExistanteCombo.setDisplayField("fmt_nom_complet");
1458
		personneExistanteCombo.setStore(personneExistanteMagazin);
1459
		personneExistanteCombo.addKeyListener(new KeyListener() {
1460
 
1461
			public void componentKeyUp(ComponentEvent ce) {
1462
				if (!ce.isNavKeyPress() && personneExistanteCombo.getRawValue() != null && personneExistanteCombo.getRawValue().length() > 0) {
1463
					rafraichirPersonneExistante(personneExistanteCombo.getRawValue());
1464
				}
1465
			}
1466
 
1467
		});
1468
 
1469
		// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar
491 gduche 1470
			//> CHECK
1471
		toolBar.add(personneExistanteCombo);
243 jp_milcent 1472
 
491 gduche 1473
		Button ajouterPersonneExistanteBtn = new Button("Ajouter");
1474
		ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
243 jp_milcent 1475
			@Override
491 gduche 1476
			public void componentSelected(ButtonEvent ce) {
243 jp_milcent 1477
				Personne personneExistante = personneExistanteCombo.getValue();
1478
 
295 jp_milcent 1479
				if (personneExistante != null) {
1480
					StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
1481
					membreDuPersonnel.setIdPersonne(personneExistante.getId());
609 jp_milcent 1482
					membreDuPersonnel.setIdProjetPersonne(personneExistante.getIdProjet());
295 jp_milcent 1483
					membreDuPersonnel.setNom(personneExistante.getNom());
1484
					membreDuPersonnel.setPrenom(personneExistante.getPrenom());
1485
					membreDuPersonnel.setTelephone(personneExistante.getTelephone());
603 jp_milcent 1486
					membreDuPersonnel.setCourriel(personneExistante.selectionnerCourriel(1));
1487
					membreDuPersonnel.setSpecialite(personneExistante.afficherSpecialite());
295 jp_milcent 1488
 
1489
					ajouterMembreAGrillePersonnel(membreDuPersonnel);
1490
				}
243 jp_milcent 1491
			}
1492
		});
1493
		toolBar.add(ajouterPersonneExistanteBtn);
1494
 
102 jpm 1495
		cp.setTopComponent(toolBar);
1496
 
1497
		ColumnModel cm = new ColumnModel(configs);
1498
 
559 jp_milcent 1499
		grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);
1500
		grillePersonnel.setHeight("100%");
103 jpm 1501
		grillePersonnel.setBorders(true);
1502
		grillePersonnel.setSelectionModel(sm);
1503
		grillePersonnel.addPlugin(checkColumn);
231 jp_milcent 1504
		grillePersonnel.addPlugin(r);
1505
		grillePersonnel.getView().setForceFit(true);
211 jp_milcent 1506
  		grillePersonnel.setAutoExpandColumn("specialite");
1507
  		grillePersonnel.setStripeRows(true);
1508
  		grillePersonnel.setTrackMouseOver(true);
1208 cyprien 1509
 
1510
 
1215 cyprien 1511
		personnelGrilleMagazin.addListener(Store.Update, new Listener<StoreEvent<StructureAPersonne>>() {
1512
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
1513
				ce.getModel().set("etat", aDonnee.ETAT_MODIFIE);
1514
			}
1515
		});
1516
 
295 jp_milcent 1517
  		cp.add(grillePersonnel);
231 jp_milcent 1518
		personnelOnglet.add(cp);
306 jp_milcent 1519
 
231 jp_milcent 1520
		return personnelOnglet;
1521
	}
102 jpm 1522
 
110 jpm 1523
	private TabItem creerOngletIdentification() {
1524
		//+-----------------------------------------------------------------------------------------------------------+
1525
		// Onlget formulaire IDENTIFICATION
634 jp_milcent 1526
		identificationOnglet = creerOnglet("Identification", "identification");
211 jp_milcent 1527
		identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
1528
			public void handleEvent(ComponentEvent be) {
1529
				peuplerStructureIdentification();
279 jp_milcent 1530
				identificationOnglet.layout();
211 jp_milcent 1531
			}
1532
		});
1533
 
110 jpm 1534
		//+-----------------------------------------------------------------------------------------------------------+
172 jp_milcent 1535
		// Champs cachés
1536
		idStructureChp = new HiddenField<String>();
1537
 
1538
		//+-----------------------------------------------------------------------------------------------------------+
110 jpm 1539
		// Fieldset IDENTITÉ
1540
		FieldSet fieldSetIdentite = new FieldSet();
1541
		fieldSetIdentite.setHeading("Identité");
1542
		fieldSetIdentite.setCollapsible(true);
569 jp_milcent 1543
		fieldSetIdentite.setLayout(creerFormLayout(120, LabelAlign.LEFT));
110 jpm 1544
 
119 jpm 1545
		nomStructureChp = new TextField<String>();
277 jp_milcent 1546
		nomStructureChp.setTabIndex(tabIndex++);
110 jpm 1547
		nomStructureChp.setFieldLabel("Nom de la structure");
1548
		nomStructureChp.setAllowBlank(false);
1549
		nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire.");
981 jpm 1550
		nomStructureChp.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 1551
		nomStructureChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
110 jpm 1552
		fieldSetIdentite.add(nomStructureChp, new FormData(450, 0));
1553
 
634 jp_milcent 1554
 
1555
		projetsMagazin = new ListStore<Projet>();
928 jpm 1556
		mediateur.selectionnerProjet(this, null);
277 jp_milcent 1557
		projetsCombo = new ComboBox<Projet>();
1558
		projetsCombo.setTabIndex(tabIndex++);
1559
		projetsCombo.setFieldLabel("Projet");
1560
		projetsCombo.setLabelSeparator("");
1561
		projetsCombo.setDisplayField("nom");
1562
		projetsCombo.setEditable(false);
1563
		projetsCombo.setTriggerAction(TriggerAction.ALL);
1564
		projetsCombo.setStore(projetsMagazin);
981 jpm 1565
		projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 1566
		projetsCombo.addListener(Events.Valid, creerEcouteurChampObligatoire());
277 jp_milcent 1567
		fieldSetIdentite.add(projetsCombo, new FormData(450, 0));
1568
 
110 jpm 1569
		// Création du sous-formulaire : Acronyme
1570
		LayoutContainer ligne = new LayoutContainer();
1571
		ligne.setLayout(new ColumnLayout());
564 jp_milcent 1572
		ligne.setSize(600, -1);
1573
 
110 jpm 1574
		LayoutContainer gauche = new LayoutContainer();
569 jp_milcent 1575
		gauche.setLayout(creerFormLayout(120, LabelAlign.LEFT));
110 jpm 1576
		LayoutContainer droite = new LayoutContainer();
569 jp_milcent 1577
		droite.setLayout(creerFormLayout(10, LabelAlign.LEFT));
110 jpm 1578
 
1579
		ListStore<InterneValeur> acronymes = new ListStore<InterneValeur>();
1580
		acronymes.add(InterneValeurListe.getTypeAcronyme());
1581
 
133 jpm 1582
		comboAcronyme = new ComboBox<InterneValeur>();
277 jp_milcent 1583
		comboAcronyme.setTabIndex(tabIndex++);
110 jpm 1584
		comboAcronyme.setEmptyText("Sélectioner un type d'acronyme...");
564 jp_milcent 1585
		comboAcronyme.setFieldLabel("Type d'acronyme");
110 jpm 1586
		comboAcronyme.setDisplayField("nom");
1587
		comboAcronyme.setStore(acronymes);
1588
		comboAcronyme.setEditable(false);
1589
		comboAcronyme.setTypeAhead(true);
1590
		comboAcronyme.setTriggerAction(TriggerAction.ALL);
1591
		comboAcronyme.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {
1592
			@Override
1593
			public void selectionChanged(SelectionChangedEvent<InterneValeur> se) {
1594
				String acronymeAbr = se.getSelectedItem().getAbr();
1595
				if (acronymeAbr.equals("IH")) {
1596
					mnhnChp.hide();
1597
					ihChp.show();
1598
				} else if (acronymeAbr.equals("MNHN")) {
1599
					ihChp.hide();
1600
					mnhnChp.show();
1601
				} else if (acronymeAbr.equals("")) {
1602
					ihChp.hide();
1603
					mnhnChp.hide();
1604
					comboAcronyme.clearSelections();
1605
				}
1606
			}
1607
        });
564 jp_milcent 1608
		gauche.add(comboAcronyme, new FormData("95%"));
110 jpm 1609
 
1610
		ihChp = new TextField<String>();
277 jp_milcent 1611
		ihChp.setTabIndex(tabIndex++);
110 jpm 1612
		ihChp.setLabelSeparator("");
1613
		ihChp.setToolTip("Index Herbariorum : herbier de plus de 5000 échantillons");
1614
		ihChp.hide();
564 jp_milcent 1615
		droite.add(ihChp, new FormData("95%"));
110 jpm 1616
 
133 jpm 1617
		mnhnChp = new TextField<String>();
277 jp_milcent 1618
		mnhnChp.setTabIndex(tabIndex++);
110 jpm 1619
		mnhnChp.setLabelSeparator("");
1620
		mnhnChp.setToolTip("Acronyme MNHN : herbier de moins de 5000 échantillons");
1621
		mnhnChp.hide();
564 jp_milcent 1622
		droite.add(mnhnChp, new FormData("95%"));
110 jpm 1623
 
564 jp_milcent 1624
		ligne.add(gauche, new ColumnData(.5));
1625
		ligne.add(droite, new ColumnData(.5));
110 jpm 1626
		fieldSetIdentite.add(ligne);
1627
 
1628
		// Création du sous-formulaire : Type de Structure
1629
		LayoutContainer ligneTs = new LayoutContainer();
1630
		ligneTs.setLayout(new ColumnLayout());
564 jp_milcent 1631
		ligneTs.setSize(600, -1);
110 jpm 1632
 
1633
		LayoutContainer gaucheTs = new LayoutContainer();
569 jp_milcent 1634
		gaucheTs.setLayout(creerFormLayout(120, LabelAlign.LEFT));
110 jpm 1635
 
1636
		LayoutContainer droiteTs = new LayoutContainer();
569 jp_milcent 1637
		droiteTs.setLayout(creerFormLayout(10, LabelAlign.LEFT));
110 jpm 1638
 
1639
		ListStore<InterneValeur> typesStructure = new ListStore<InterneValeur>();
1640
		typesStructure.add(InterneValeurListe.getTypeStructure());
1641
 
133 jpm 1642
		comboTypeStructure = new ComboBox<InterneValeur>();
277 jp_milcent 1643
		comboTypeStructure.setTabIndex(tabIndex++);
110 jpm 1644
		comboTypeStructure.setEmptyText("Sélectioner un type de structure...");
1645
		comboTypeStructure.setFieldLabel("Statut des structures");
1646
		comboTypeStructure.setDisplayField("nom");
1647
		comboTypeStructure.setStore(typesStructure);
1648
		comboTypeStructure.setEditable(false);
1649
		comboTypeStructure.setTypeAhead(true);
1650
		comboTypeStructure.setTriggerAction(TriggerAction.ALL);
1651
		comboTypeStructure.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {
1652
			@Override
1653
			public void selectionChanged(SelectionChangedEvent<InterneValeur> se) {
1654
				String typeAbr = se.getSelectedItem().getAbr();
1655
				if (typeAbr.equals("stpu")) {
1656
					comboLstpr.hide();
1657
					comboLstpu.show();
1658
				} else if (typeAbr.equals("stpr")) {
1659
					comboLstpu.hide();
1660
					comboLstpr.show();
1661
				} else if (typeAbr.equals("")) {
1662
					comboLstpr.hide();
1663
					comboLstpu.hide();
1664
					comboTypeStructure.clearSelections();
1665
				}
1666
			}
1667
        });
564 jp_milcent 1668
		gaucheTs.add(comboTypeStructure, new FormData("95%"));
110 jpm 1669
 
1670
		magazinLstpu = new ListStore<Valeur>();
133 jpm 1671
		comboLstpu = new ComboBox<Valeur>();
277 jp_milcent 1672
		comboLstpu.setTabIndex(tabIndex++);
110 jpm 1673
		//comboLstpu.setFieldLabel("Statut des structures publiques");
1674
		comboLstpu.setLabelSeparator("");
1675
		comboLstpu.setDisplayField("nom");
1676
		comboLstpu.setEditable(false);
1677
		comboLstpu.setTriggerAction(TriggerAction.ALL);
1678
		comboLstpu.setStore(magazinLstpu);
1679
		comboLstpu.hide();
564 jp_milcent 1680
		droiteTs.add(comboLstpu, new FormData("95%"));
569 jp_milcent 1681
		mediateur.obtenirListeValeurEtRafraichir(this, "stpu");
110 jpm 1682
 
1683
		magazinLstpr = new ListStore<Valeur>();
133 jpm 1684
		comboLstpr = new ComboBox<Valeur>();
277 jp_milcent 1685
		comboLstpr.setTabIndex(tabIndex++);
110 jpm 1686
		//comboLstpr.setFieldLabel("Statut des structures privées");
1687
		comboLstpr.setLabelSeparator("");
1688
		comboLstpr.setDisplayField("nom");
1689
		comboLstpr.setEditable(false);
1690
		comboLstpr.setTriggerAction(TriggerAction.ALL);
1691
		comboLstpr.setStore(magazinLstpr);
1692
		comboLstpr.hide();
564 jp_milcent 1693
		droiteTs.add(comboLstpr, new FormData("95%"));
569 jp_milcent 1694
		mediateur.obtenirListeValeurEtRafraichir(this, "stpr");
110 jpm 1695
 
1696
		ligneTs.add(gaucheTs, new ColumnData(0.5));
1697
		ligneTs.add(droiteTs, new ColumnData(0.5));
1698
		fieldSetIdentite.add(ligneTs);
1699
 
119 jpm 1700
		dateFondationChp = new DateField();
277 jp_milcent 1701
		dateFondationChp.setTabIndex(tabIndex++);
110 jpm 1702
		dateFondationChp.setFieldLabel("Date de fondation");
1703
		dateFondationChp.getPropertyEditor().getFormat();
1704
		dateFondationChp.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
1705
		dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
1706
		fieldSetIdentite.add(dateFondationChp);
1707
 
564 jp_milcent 1708
		nbreTotalPersonneStructureChp = new NumberField();
231 jp_milcent 1709
		nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution");
1710
		nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#"));
686 jp_milcent 1711
		nbreTotalPersonneStructureChp.setToolTip(i18nC.champNumerique());
231 jp_milcent 1712
		fieldSetIdentite.add(nbreTotalPersonneStructureChp);
1713
 
279 jp_milcent 1714
		identificationOnglet.add(fieldSetIdentite);
231 jp_milcent 1715
 
110 jpm 1716
		//+-----------------------------------------------------------------------------------------------------------+
1171 jpm 1717
		// Fieldset DESCRIPTION
1718
		FieldSet fieldSetDescription = new FieldSet();
1719
		fieldSetDescription.setHeading("Description");
1720
		fieldSetDescription.setCollapsible(true);
1721
		fieldSetDescription.setLayout(creerFormLayout(120, LabelAlign.LEFT));
1722
 
1723
		descriptionChp = new TextArea();
1724
		descriptionChp.setTabIndex(tabIndex++);
1725
		descriptionChp.setFieldLabel("Description");
1726
		fieldSetDescription.add(descriptionChp, new FormData(550, 0));
1727
 
1728
		conditionAccesChp = new TextArea();
1729
		conditionAccesChp.setTabIndex(tabIndex++);
1730
		conditionAccesChp.setFieldLabel("Conditions d'accès");
1731
		fieldSetDescription.add(conditionAccesChp, new FormData(550, 0));
1732
 
1733
		conditionUsageChp = new TextArea();
1734
		conditionUsageChp.setTabIndex(tabIndex++);
1735
		conditionUsageChp.setFieldLabel("Conditions d'usage");
1736
		fieldSetDescription.add(conditionUsageChp, new FormData(550, 0));
1737
 
1738
		identificationOnglet.add(fieldSetDescription);
1739
 
1740
		//+-----------------------------------------------------------------------------------------------------------+
110 jpm 1741
		// Fieldset ADRESSE
1742
		LayoutContainer principalFdAdresse = new LayoutContainer();
1743
		principalFdAdresse.setLayout(new ColumnLayout());
564 jp_milcent 1744
		principalFdAdresse.setSize(600, -1);
110 jpm 1745
 
1746
		LayoutContainer gaucheFdAdresse = new LayoutContainer();
569 jp_milcent 1747
		gaucheFdAdresse.setLayout(creerFormLayout(null, LabelAlign.LEFT));
110 jpm 1748
 
1749
		LayoutContainer droiteFdAdresse = new LayoutContainer();
569 jp_milcent 1750
		droiteFdAdresse.setLayout(creerFormLayout(null, LabelAlign.LEFT));
110 jpm 1751
 
1752
		FieldSet fieldSetAdresse = new FieldSet();
1753
		fieldSetAdresse.setHeading("Adresse");
1754
		fieldSetAdresse.setCollapsible(true);
1755
 
569 jp_milcent 1756
		fieldSetAdresse.setLayout(creerFormLayout(null, LabelAlign.LEFT));
110 jpm 1757
 
164 jp_milcent 1758
		adrChp = new TextArea();
277 jp_milcent 1759
		adrChp.setTabIndex(tabIndex++);
1171 jpm 1760
		adrChp.setFieldLabel("Adresse (Nom du batiment, rue...)");
110 jpm 1761
		fieldSetAdresse.add(adrChp, new FormData(550, 0));
1762
 
1171 jpm 1763
		adrComplementChp = new TextArea();
1764
		adrComplementChp.setTabIndex(tabIndex++);
1765
		adrComplementChp.setFieldLabel("Complément d'adresse (BP, étage...)");
1766
		fieldSetAdresse.add(adrComplementChp, new FormData(550, 0));
1767
 
133 jpm 1768
		cpChp = new TextField<String>();
277 jp_milcent 1769
		cpChp.setTabIndex(tabIndex++);
110 jpm 1770
		cpChp.setFieldLabel("Code postal");
564 jp_milcent 1771
		gaucheFdAdresse.add(cpChp, new FormData("95%"));
110 jpm 1772
 
133 jpm 1773
		villeChp = new TextField<String>();
277 jp_milcent 1774
		villeChp.setTabIndex(tabIndex++);
110 jpm 1775
		villeChp.setFieldLabel("Ville");
1035 gduche 1776
		gaucheFdAdresse.add(villeChp, new FormData("95%"));
110 jpm 1777
 
1035 gduche 1778
		magazinPays = new ListStore<Valeur>();
164 jp_milcent 1779
		comboPays = new ComboBox<Valeur>();
277 jp_milcent 1780
		comboPays.setTabIndex(tabIndex++);
164 jp_milcent 1781
		comboPays.setFieldLabel("Pays");
1035 gduche 1782
		comboPays.setEmptyText("Sélectionner un pays...");
164 jp_milcent 1783
		comboPays.setEditable(true);
1784
		comboPays.setLabelSeparator("");
1785
		comboPays.setDisplayField("nom");
172 jp_milcent 1786
		comboPays.setTemplate(getTemplatePays());
1787
		comboPays.setTypeAhead(true);
164 jp_milcent 1788
		comboPays.setTriggerAction(TriggerAction.ALL);
1789
		comboPays.setStore(magazinPays);
1035 gduche 1790
 
1791
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
1792
			public void selectionChanged(SelectionChangedEvent se) {
1793
				// Rafraichir avec le pays sélectionné
1794
				obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
1795
			}
1796
		};
1797
 
1798
		comboPays.addSelectionChangedListener(selectionChange);
1799
 
1800
 
564 jp_milcent 1801
		droiteFdAdresse.add(comboPays, new FormData("95%"));
569 jp_milcent 1802
		mediateur.obtenirListeValeurEtRafraichir(this, "pays");
110 jpm 1803
 
1035 gduche 1804
		magazinRegion = new ListStore<Valeur>();
1805
		comboRegion = new ComboBox<Valeur>();
1806
		comboRegion.setTabIndex(tabIndex++);
1807
		comboRegion.setFieldLabel("Région");
1808
		comboRegion.setEmptyText("Sélectionner une région...");
1809
		comboRegion.setDisplayField("nom");
1810
		comboRegion.setTypeAhead(true);
1811
		comboRegion.setTriggerAction(TriggerAction.ALL);
1812
		comboRegion.setStore(magazinRegion);
1813
 
1814
		droiteFdAdresse.add(comboRegion, new FormData("95%"));
1815
 
1171 jpm 1816
		latitudeChp = new TextField<String>();
1817
		latitudeChp.setRegex(Pattern.latitude);
1818
		latitudeChp.setToolTip("Format : nombre décimal positif ou négatif de 0 à 90.");
1819
		latitudeChp.getMessages().setRegexText("La valeur saisie n'est pas une latitude valide. Exemples de latitude : -45,302010 ou 45.252423 ou 25,16.");
1820
		latitudeChp.setTabIndex(tabIndex++);
1821
		latitudeChp.setFieldLabel("Latitude (Nord)");
1822
		gaucheFdAdresse.add(latitudeChp, new FormData("95%"));
1035 gduche 1823
 
1171 jpm 1824
		longitudeChp = new TextField<String>();
1825
		longitudeChp.setRegex(Pattern.longitude);
1826
		longitudeChp.setToolTip("Format : nombre décimal positif ou négatif de 0 à 180.");
1827
		longitudeChp.getMessages().setRegexText("La valeur saisie n'est pas une longitude valide. Exemples de longitude : -150,302010 ou 150.252423 ou 25,16.");
1828
		longitudeChp.setTabIndex(tabIndex++);
1829
		longitudeChp.setFieldLabel("Longitude (Est)");
1830
		droiteFdAdresse.add(longitudeChp, new FormData("95%"));
1831
 
110 jpm 1832
		principalFdAdresse.add(gaucheFdAdresse, new ColumnData(.5));
1833
		principalFdAdresse.add(droiteFdAdresse, new ColumnData(.5));
1834
		fieldSetAdresse.add(principalFdAdresse);
279 jp_milcent 1835
 
110 jpm 1836
		identificationOnglet.add(fieldSetAdresse);
279 jp_milcent 1837
 
110 jpm 1838
		//+-----------------------------------------------------------------------------------------------------------+
1839
		// Fieldset TÉLÉPHONE et EMAIL
1840
		LayoutContainer principalFdTelMail = new LayoutContainer();
1841
		principalFdTelMail.setLayout(new ColumnLayout());
569 jp_milcent 1842
		principalFdTelMail.setSize(700, -1);
110 jpm 1843
 
1844
		LayoutContainer gaucheFdTelMail = new LayoutContainer();
569 jp_milcent 1845
		gaucheFdTelMail.setLayout(creerFormLayout(60, LabelAlign.LEFT));
110 jpm 1846
 
1847
		LayoutContainer droiteFdTelMail = new LayoutContainer();
569 jp_milcent 1848
		droiteFdTelMail.setLayout(creerFormLayout(60, LabelAlign.LEFT));
110 jpm 1849
 
1850
		FieldSet fieldSetTelMail = new FieldSet();
1851
		fieldSetTelMail.setHeading("Communication");
1852
		fieldSetTelMail.setCollapsible(true);
1853
 
569 jp_milcent 1854
		fieldSetTelMail.setLayout(creerFormLayout(null, LabelAlign.LEFT));
110 jpm 1855
 
133 jpm 1856
		telChp = new TextField<String>();
277 jp_milcent 1857
		telChp.setTabIndex(tabIndex++);
602 jp_milcent 1858
		telChp.setFieldLabel("Téléphone fixe");
564 jp_milcent 1859
		gaucheFdTelMail.add(telChp, new FormData("95%"));
110 jpm 1860
 
133 jpm 1861
		faxChp = new TextField<String>();
277 jp_milcent 1862
		faxChp.setTabIndex(tabIndex++);
110 jpm 1863
		faxChp.setFieldLabel("Fax");
564 jp_milcent 1864
		droiteFdTelMail.add(faxChp, new FormData("95%"));
110 jpm 1865
 
133 jpm 1866
		emailChp = new TextField<String>();
277 jp_milcent 1867
		emailChp.setTabIndex(tabIndex++);
110 jpm 1868
		emailChp.setFieldLabel("Courriel");
1869
		emailChp.setToolTip("Saisir le courriel de l'organisation, pas de courriel individuel. Ex. : accueil@organisation.org");
564 jp_milcent 1870
		gaucheFdTelMail.add(emailChp, new FormData("95%"));
110 jpm 1871
 
133 jpm 1872
		urlChp = new TextField<String>();
277 jp_milcent 1873
		urlChp.setTabIndex(tabIndex++);
110 jpm 1874
		urlChp.setFieldLabel("Site web");
564 jp_milcent 1875
		droiteFdTelMail.add(urlChp, new FormData("95%"));
110 jpm 1876
 
1877
		principalFdTelMail.add(gaucheFdTelMail, new ColumnData(.5));
1878
		principalFdTelMail.add(droiteFdTelMail, new ColumnData(.5));
1879
		fieldSetTelMail.add(principalFdTelMail);
279 jp_milcent 1880
 
110 jpm 1881
		identificationOnglet.add(fieldSetTelMail);
1882
 
1883
		return identificationOnglet;
1884
	}
1885
 
1035 gduche 1886
	public void obtenirListeRegionParPays(String strPays)	{
1887
		mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
1888
	}
1889
 
1890
	private void mettreAJourRegion()	{
1891
		//Met à jour la combo box en sélectionnant la valeur enregistrée pour la personne
1892
		if (identification.get("ce_truk_region") != null && comboRegion.getStore().getCount() > 0)	{
1893
			Valeur valeurRegion = comboRegion.getStore().findModel("id_valeur", identification.get("ce_truk_region"));
1894
			if (valeurRegion!=null)	{
1895
				comboRegion.setValue(valeurRegion);
1896
			} else if (identification.get("ce_truk_region").toString().startsWith("AUTRE##")) {
1897
				comboRegion.setRawValue(identification.get("ce_truk_region").toString().replaceFirst("^AUTRE##", ""));
1898
			}
1899
		}
1900
	}
1901
 
172 jp_milcent 1902
	private native String getTemplatePays() /*-{
1903
		return  [
1904
		'<tpl for=".">',
1905
		'<div class="x-combo-list-item">{nom} ({abreviation})</div>',
1906
		'</tpl>'
1907
		].join("");
1908
		}-*/;
1909
 
192 jp_milcent 1910
	private void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) {
1911
		String[] valeurs = donnees.split(";;");
1912
		for (int i = 0; i < valeurs.length; i++) {
1913
			if (valeurs[i].startsWith("AUTRE##")) {
1914
				champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", ""));
1915
			} else {
491 gduche 1916
				//TODO : check : List<CheckBox> cases = groupeCac.getAll();
1917
				List<Field<?>> cases = groupeCac.getAll();
192 jp_milcent 1918
				for (int j = 0; j < cases.size(); j++) {
1919
					if (cases.get(j).getId().equals("val-"+valeurs[i])) {
491 gduche 1920
						((CheckBox) cases.get(j)).setValue(true);
192 jp_milcent 1921
					}
1922
				}
1923
			}
1924
		}
1925
	}
1926
 
1927
	private void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) {
491 gduche 1928
		//List<Radio> boutons = groupeBr.getAll();
1929
		List<Field<?>> boutons = groupeBr.getAll();
192 jp_milcent 1930
		String id = valeur+"_"+groupeBr.getName().replace("_grp", "");
1931
		for (int i = 0; i < boutons.size(); i++) {
1932
			if (boutons.get(i).getId().equals(id)) {
491 gduche 1933
				((Radio) boutons.get(i)).setValue(true);
192 jp_milcent 1934
			}
1935
		}
1936
	}
1937
 
1938
	private String creerChaineDenormalisee(List<CheckBox> liste) {
1939
		String identifiants = "";
306 jp_milcent 1940
		if (liste != null) {
1941
			int taille = liste.size();
1942
			for (int i = 0; i < taille; i++) {
1943
				CheckBox cac = liste.get(i);
1944
				if (cac.isEnabled()) {
1945
					identifiants = identifiants.concat(";;"+cac.getData("id"));
1946
				}
192 jp_milcent 1947
			}
306 jp_milcent 1948
			identifiants.replaceFirst("^;;", "");
192 jp_milcent 1949
		}
306 jp_milcent 1950
		return identifiants;
192 jp_milcent 1951
	}
1952
 
934 jpm 1953
	public void afficherChampSupplementaire(Radio radioBtn) {
119 jpm 1954
		//GWT.log("Nom btn : "+radioBtn.getName()+" - Nom group : "+radioBtn.getGroup().getName(), null);
115 jpm 1955
		// Valeur du bouton radio déclenchant l'affichage des composants cachés
1956
		String valeurPourAfficher = "oui";
111 jpm 1957
 
115 jpm 1958
		// Construction de la liste des composants à afficher/cacher
1959
		String radioGroupeNom = radioBtn.getGroup().getName();
1960
		ArrayList<Object> composants = new ArrayList<Object>();
1961
		if (radioGroupeNom.equals("action_mark_grp")) {
1962
			composants.add(actionTrukCp);
1963
		} else if (radioGroupeNom.equals("future_action_mark_grp")) {
1964
			composants.add(futureActionChp);
1965
		} else if (radioGroupeNom.equals("sans_motif_acces_mark_grp")) {
1966
			composants.add(sansMotifAccesChp);
1967
		} else if (radioGroupeNom.equals("avec_motif_acces_mark_grp")) {
1968
			composants.add(avecMotifAccesChp);
1969
		} else if (radioGroupeNom.equals("recherche_mark_grp")) {
1970
			composants.add(provenanceRechercheTrukCp);
119 jpm 1971
			composants.add(typeRechercheTrukCp);
115 jpm 1972
		} else if (radioGroupeNom.equals("formation_mark_grp")) {
1973
			composants.add(formationChp);
1974
		} else if (radioGroupeNom.equals("collection_commune_mark_grp")) {
1975
			composants.add(collectionAutreTrukCp);
1976
		} else if (radioGroupeNom.equals("restauration_mark_grp")) {
1977
			composants.add(opRestauTrukCp);
1978
		} else if (radioGroupeNom.equals("traitement_mark_grp")) {
1979
			composants.add(traitementTrukCp);
1980
		} else if (radioGroupeNom.equals("echantillon_acquisition_mark_grp")) {
1981
			composants.add(traitementAcquisitionMarkRGrpChp);
1982
		} else if (radioGroupeNom.equals("traitement_acquisition_mark_grp")) {
1983
			composants.add(traitementAcquisitionMarkLabel);
1984
			composants.add(poisonTraitementTrukCp);
1985
			composants.add(insecteTraitementTrukCp);
1986
		} else if (radioGroupeNom.equals("materiel_conservation_ce_grp")) {
1987
			composants.add(autreMaterielTrukCp);
1988
			valeurPourAfficher = "non";
1989
		}
111 jpm 1990
 
115 jpm 1991
		// Nous affichons/cachons les composant de la liste
211 jp_milcent 1992
		final int nbreComposants = composants.size();
115 jpm 1993
		//GWT.log("Id : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax, null);
119 jpm 1994
		//Window.alert("Radio grp nom : "+radioGroupeNom+" - Id btn : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax);
211 jp_milcent 1995
		for (int i = 0; i < nbreComposants; i++) {
111 jpm 1996
			// En fonction du type de bouton cliquer, on affiche ou cache les champs
115 jpm 1997
			String type = radioBtn.getBoxLabel().toLowerCase();
119 jpm 1998
			//GWT.log(type, null);
115 jpm 1999
			if (radioBtn.getValue() == true) {
2000
				if (type.equals(valeurPourAfficher)) {
2001
					((Component) composants.get(i)).show();
2002
				} else {
2003
					((Component) composants.get(i)).hide();
2004
				}
111 jpm 2005
			}
2006
			// Si on a à faire à un ContentPanel, on l'actualise pour déclencher l'affichage
115 jpm 2007
			if (composants.get(i) instanceof ContentPanel) {
2008
				((ContentPanel) composants.get(i)).layout();
111 jpm 2009
			}
2010
		}
2011
 
2012
	}
2013
 
639 jp_milcent 2014
	public void rafraichir(Object nouvellesDonnees) {
1208 cyprien 2015
 
2016
Debug.log("|0> StructureForm.rafraichir, nouvellesDonnees.getClass() = "+nouvellesDonnees.getClass());
2017
 
639 jp_milcent 2018
		try {
2019
			if (nouvellesDonnees instanceof Information) {
2020
				Information info = (Information) nouvellesDonnees;
2021
				rafraichirInformation(info);
2022
			} else if (nouvellesDonnees instanceof ValeurListe) {
2023
				ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
2024
				rafraichirValeurListe(listeValeurs);
2025
			} else if (nouvellesDonnees instanceof ProjetListe) {
2026
				ProjetListe projets = (ProjetListe) nouvellesDonnees;
2027
				rafraichirProjetListe(projets);
2028
			} else {
2029
				GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
295 jp_milcent 2030
			}
639 jp_milcent 2031
		} catch (Exception e) {
875 jpm 2032
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e);
109 jpm 2033
		}
2034
 
1218 cyprien 2035
		controlerFermeture();
109 jpm 2036
	}
2037
 
639 jp_milcent 2038
	public void rafraichirInformation(Information info) {
2039
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
2040
			GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
2041
		}
1208 cyprien 2042
 
2043
Debug.log("|0> StructureForm.rafraichirInformation, info.getType() = "+info.getType());
639 jp_milcent 2044
 
2045
		if (info.getType().equals("modif_structure")) {
1208 cyprien 2046
			InfoLogger.display("Modification d'une institution", info.toString());
639 jp_milcent 2047
		} else if (info.getType().equals("ajout_structure")) {
770 jpm 2048
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
2049
				String structureId = (String) info.getDonnee(0);
1208 cyprien 2050
				InfoLogger.display("Ajout d'une Institution", "L'intitution '"+structureId+"' a bien été ajoutée");
770 jpm 2051
 
639 jp_milcent 2052
				// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel
770 jpm 2053
				mediateur.ajouterStructureAPersonne(this, structureId, personnelAjoute);
639 jp_milcent 2054
			} else {
1208 cyprien 2055
				InfoLogger.display("Ajout d'une Institution", info.toString());
639 jp_milcent 2056
			}
2057
		} else if (info.getType().equals("modif_structure_a_personne")) {
1208 cyprien 2058
			InfoLogger.display("Modification du Personnel", info.toString());
639 jp_milcent 2059
			GWT.log("Decompte:"+decompteRafraichissementPersonnel, null);
2060
			testerLancementRafraichirPersonnel();
2061
		} else if (info.getType().equals("suppression_structure_a_personne")) {
1208 cyprien 2062
			InfoLogger.display("Suppression du Personnel", info.toString());
639 jp_milcent 2063
			GWT.log("Decompte:"+decompteRafraichissementPersonnel, null);
2064
			testerLancementRafraichirPersonnel();
2065
		} else if (info.getType().equals("ajout_structure_a_personne")) {
1208 cyprien 2066
			InfoLogger.display("Ajout du Personnel", info.toString());
639 jp_milcent 2067
			GWT.log("Decompte:"+decompteRafraichissementPersonnel, null);
2068
			testerLancementRafraichirPersonnel();
2069
		} else if (info.getType().equals("selection_structure")) {
1208 cyprien 2070
			InfoLogger.display("Modification d'une institution", info.toString());
639 jp_milcent 2071
			String titre = i18nC.titreModifFormStructurePanneau();
2072
			if (info.getDonnee(0) != null) {
2073
				identification = (Structure) info.getDonnee(0);
2074
				if (onglets.getSelectedItem().equals(identificationOnglet)) {
2075
					peuplerStructureIdentification();
188 jp_milcent 2076
				}
639 jp_milcent 2077
				// Composition du titre
2078
				titre += " - ID : "+identification.getId();
2079
			}
2080
			if (info.getDonnee(1) != null) {
2081
				conservation = (StructureConservation) info.getDonnee(1);
2082
				if (onglets.getSelectedItem().equals(conservationOnglet)) {
2083
					peuplerStructureConservation();
2084
				}
2085
			}
2086
			if (info.getDonnee(2) != null) {
2087
				valorisation = (StructureValorisation) info.getDonnee(2);
2088
				if (valorisation != null) {
2089
					if (onglets.getSelectedItem().equals(valorisationOnglet)) {
2090
						peuplerStructureValorisation();
231 jp_milcent 2091
					}
639 jp_milcent 2092
				}
2093
			}
2094
		} else if (info.getType().equals("liste_structure_a_personne")) {
1208 cyprien 2095
			Debug.log("==> StructureForm.rafraichirInformation, typeInfo=liste_structure_a_personne");
639 jp_milcent 2096
			if (info.getDonnee(0) != null) {
2097
				personnel = (StructureAPersonneListe) info.getDonnee(0);
1208 cyprien 2098
 
639 jp_milcent 2099
				peuplerStructurePersonnel();
1208 cyprien 2100
 
2101
	/*	TODELETE
2102
				int nbPersonnel = this.personnelGrilleMagazin.getCount();
2103
				for (int i=0; i<nbPersonnel; i++){
2104
					Debug.log("==> setEtat(ETAT_MODIFIE) : personne="+this.personnelGrilleMagazin.getAt(i).getId());
2105
					this.personnelGrilleMagazin.getAt(i).set("etat", StructureAPersonne.ETAT_MODIFIE);
2106
				}
2107
	*/
2108
 
639 jp_milcent 2109
				personnelOnglet.layout();
1208 cyprien 2110
				InfoLogger.display("Chargement du Personnel", "ok");
609 jp_milcent 2111
 
639 jp_milcent 2112
				// Remise à zéro des modification dans la liste du personnel
2113
				personnelModifie = new StructureAPersonneListe();
2114
				personnelAjoute = new StructureAPersonneListe();
2115
				personnelSupprime = new StructureAPersonneListe();
2116
			}
2117
		} else if (info.getType().equals("liste_personne")) {
2118
			if (info.getDonnee(0) != null) {
2119
				PersonneListe personnes = (PersonneListe) info.getDonnee(0);
704 jp_milcent 2120
				List<Personne> liste = personnes.toList();
639 jp_milcent 2121
 
2122
				personneExistanteMagazin.removeAll();
2123
				personneExistanteMagazin.add(liste);
2124
				personneExistanteCombo.setStore(personneExistanteMagazin);
2125
				personneExistanteCombo.expand();
2126
			}
2127
		}
2128
	}
2129
 
2130
	public void rafraichirValeurListe(ValeurListe listeValeurs) {
2131
		List<Valeur> liste = listeValeurs.toList();
407 jp_milcent 2132
 
639 jp_milcent 2133
		// Test pour savoir si la liste contient des éléments
2134
		if (liste.size() > 0) {
2135
			if (listeValeurs.getId().equals(config.getListeId("stpr"))) {
2136
				magazinLstpr.removeAll();
2137
				magazinLstpr.add(liste);
2138
				comboLstpr.setStore(magazinLstpr);
2139
			}
2140
			if (listeValeurs.getId().equals(config.getListeId("stpu"))) {
2141
				magazinLstpu.removeAll();
2142
				magazinLstpu.add(liste);
2143
				comboLstpu.setStore(magazinLstpu);
2144
			}
2145
			if (listeValeurs.getId().equals(config.getListeId("statut"))) {
2146
				magazinLiStatut.removeAll();
2147
				magazinLiStatut.add(liste);
2148
				comboLiStatut.setStore(magazinLiStatut);
2149
			}
2150
			if (listeValeurs.getId().equals(config.getListeId("fonction"))) {
2151
				// FIXME : le store ne contient pas tout le temps les données, chose étrange.
2152
				// On stocke donc les données dans une variables de la classe pour recharger le store si besoin.
2153
				fonctionsListe = liste;
2154
				fonctionsMagazin.removeAll();
2155
				fonctionsMagazin.add(liste);
2156
				fonctionsCombo.setStore(fonctionsMagazin);
2157
			}
2158
			if (listeValeurs.getId().equals(config.getListeId("pays"))) {
2159
				magazinPays.removeAll();
2160
				magazinPays.add(liste);
2161
				comboPays.setStore(magazinPays);
2162
			}
1035 gduche 2163
 
2164
			if (listeValeurs.getId().equals(config.getListeId("region"))) {
2165
				magazinRegion.removeAll();
2166
				magazinRegion.add(liste);
2167
				comboRegion.setStore(magazinRegion);
2168
 
2169
				mettreAJourRegion();
2170
			}
2171
 
2172
 
639 jp_milcent 2173
			if (listeValeurs.getId().equals(config.getListeId("localStockage"))) {
2174
				localStockageAutreChp = new TextField<String>();
2175
				creerChoixMultipleCac(localStockageTrukCp, localStockageTrukCacGrpChp, listeValeurs, localStockageAutreChp);
2176
			}
2177
			if (listeValeurs.getId().equals(config.getListeId("meubleStockage"))) {
2178
				meubleStockageAutreChp = new TextField<String>();
2179
				creerChoixMultipleCac(meubleStockageTrukCp, meubleStockageTrukCacGrpChp, listeValeurs, meubleStockageAutreChp);
2180
			}
2181
			if (listeValeurs.getId().equals(config.getListeId("parametreStockage"))) {
2182
				parametreStockageAutreChp = new TextField<String>();
2183
				creerChoixMultipleCac(parametreStockageTrukCp, parametreStockageTrukCacGrpChp, listeValeurs, parametreStockageAutreChp);
2184
			}
2185
			if (listeValeurs.getId().equals(config.getListeId("autreCollection"))) {
2186
				if (collectionAutreTrukCp != null && collectionAutreTrukCp.getItemByItemId("collectionAutreTrukCacGrpChp") == null) {
2187
					collectionAutreTrukCacGrpChp.setId("collectionAutreTrukCacGrpChp");
2188
					collectionAutreAutreChp = new TextField<String>();
2189
					creerChoixMultipleCac(collectionAutreTrukCp, collectionAutreTrukCacGrpChp, listeValeurs, collectionAutreAutreChp);
110 jpm 2190
				}
639 jp_milcent 2191
				if (autreCollectionTrukCp != null && autreCollectionTrukCp.getItemByItemId("autreCollectionTrukCacGrpChp") == null) {
2192
					autreCollectionTrukCacGrpChp.setId("autreCollectionTrukCacGrpChp");
2193
					autreCollectionAutreChp = new TextField<String>();
2194
					creerChoixMultipleCac(autreCollectionTrukCp, autreCollectionTrukCacGrpChp, listeValeurs, autreCollectionAutreChp);
277 jp_milcent 2195
				}
91 jpm 2196
			}
639 jp_milcent 2197
			if (listeValeurs.getId().equals(config.getListeId("opRestau"))) {
2198
				opRestauAutreChp = new TextField<String>();
2199
				creerChoixMultipleCac(opRestauTrukCp, opRestauTrukCacGrpChp, listeValeurs, opRestauAutreChp);
2200
			}
2201
			if (listeValeurs.getId().equals(config.getListeId("onep"))) {
2202
				creerChoixUniqueBoutonRadio(materielConservationCeRGrpChp, listeValeurs);
2203
				materielConservationCp.add(materielConservationCeRGrpChp);
2204
				materielConservationCp.layout();
2205
			}
2206
			if (listeValeurs.getId().equals(config.getListeId("autreMateriel"))) {
2207
				autreMaterielAutreChp = new TextField<String>();
2208
				creerChoixMultipleCac(autreMaterielTrukCp, autreMaterielTrukCacGrpChp, listeValeurs, autreMaterielAutreChp);
2209
			}
2210
			if (listeValeurs.getId().equals(config.getListeId("poisonTraitement"))) {
2211
				poisonTraitementAutreChp = new TextField<String>();
2212
				creerChoixMultipleCac(poisonTraitementTrukCp, poisonTraitementTrukCacGrpChp, listeValeurs, poisonTraitementAutreChp);
2213
			}
2214
			if (listeValeurs.getId().equals(config.getListeId("insecteTraitement"))) {
2215
				if (traitementTrukCp != null && traitementTrukCp.getItemByItemId("traitementTrukCacGrpChp") == null) {
2216
					traitementTrukCacGrpChp.setId("traitementTrukCacGrpChp");
2217
					traitementAutreChp = new TextField<String>();
2218
					creerChoixMultipleCac(traitementTrukCp, traitementTrukCacGrpChp, listeValeurs, traitementAutreChp);
2219
				}
2220
				if (insecteTraitementTrukCp != null && insecteTraitementTrukCp.getItemByItemId("insecteTraitementTrukCacGrpChp") == null) {
2221
					insecteTraitementTrukCacGrpChp.setId("insecteTraitementTrukCacGrpChp");
2222
					insecteTraitementAutreChp = new TextField<String>();
2223
					creerChoixMultipleCac(insecteTraitementTrukCp, insecteTraitementTrukCacGrpChp, listeValeurs, insecteTraitementAutreChp);
2224
				}
2225
			}
2226
			if (listeValeurs.getId().equals(config.getListeId("actionValorisation"))) {
2227
				actionAutreChp = new TextField<String>();
2228
				creerChoixMultipleCac(actionTrukCp, actionTrukCacGrpChp, listeValeurs, actionAutreChp);
2229
			}
2230
			if (listeValeurs.getId().equals(config.getListeId("continentEtFr"))) {
2231
				provenanceRechercheAutreChp = new TextField<String>();
2232
				creerChoixMultipleCac(provenanceRechercheTrukCp, provenanceRechercheTrukCacGrpChp, listeValeurs, provenanceRechercheAutreChp);
2233
			}
2234
			if (listeValeurs.getId().equals(config.getListeId("typeRecherche"))) {
2235
				typeRechercheAutreChp = new TextField<String>();
2236
				creerChoixMultipleCac(typeRechercheTrukCp, typeRechercheTrukCacGrpChp, listeValeurs, typeRechercheAutreChp);
2237
			}
2238
			//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
2239
		} else {
2240
			GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
91 jpm 2241
		}
639 jp_milcent 2242
	}
2243
 
2244
	private void rafraichirProjetListe(ProjetListe projets) {
686 jp_milcent 2245
		List<Projet> liste = projets.toList();
639 jp_milcent 2246
		projetsMagazin.removeAll();
2247
		projetsMagazin.add(liste);
2248
		projetsCombo.setStore(projetsMagazin);
69 jpm 2249
	}
243 jp_milcent 2250
 
609 jp_milcent 2251
	private void testerLancementRafraichirPersonnel() {
1208 cyprien 2252
Debug.log("==> BEGIN StructureForm.testerLancementRafraichirPersonnel()");
2253
 
609 jp_milcent 2254
		decompteRafraichissementPersonnel--;
2255
		if (decompteRafraichissementPersonnel == 0) {
2256
			// Nous rechargeons la liste du Personnel
2257
			rafraichirPersonnel();
1208 cyprien 2258
		}
2259
Debug.log("==> END StructureForm.testerLancementRafraichirPersonnel()");
609 jp_milcent 2260
	}
2261
 
243 jp_milcent 2262
	private void rafraichirPersonnel() {
1208 cyprien 2263
Debug.log("==> BEGIN StructureForm.rafraichirPersonnel()");
2264
 
609 jp_milcent 2265
		decompteRafraichissementPersonnel = 0;
295 jp_milcent 2266
		if (mode.equals(MODE_MODIFIER)) {
609 jp_milcent 2267
			initialiserGrillePersonnelEnModification();
295 jp_milcent 2268
		} else if (mode.equals(MODE_AJOUTER)) {
2269
			initialiserGrillePersonnelEnAjout();
2270
		}
1208 cyprien 2271
Debug.log("==> END StructureForm.rafraichirPersonnel()");
243 jp_milcent 2272
	}
2273
 
2274
	private void rafraichirPersonneExistante(String nom) {
245 jp_milcent 2275
		mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%");
243 jp_milcent 2276
	}
295 jp_milcent 2277
 
2278
	private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) {
2279
		grillePersonnel.stopEditing();
306 jp_milcent 2280
		personnelGrilleMagazin.insert(personnel, 0);
295 jp_milcent 2281
		grillePersonnel.startEditing(0, 0);
2282
	}
2283
 
2284
	private void initialiserGrillePersonnelEnAjout() {
2285
		personnelGrilleMagazin.removeAll();
2286
		StructureAPersonne conservateurDesCollections = new StructureAPersonne(StructureAPersonne.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
2287
		ajouterMembreAGrillePersonnel(conservateurDesCollections);
2288
		StructureAPersonne directeurDuPersonnel = new StructureAPersonne(StructureAPersonne.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
2289
		ajouterMembreAGrillePersonnel(directeurDuPersonnel);
609 jp_milcent 2290
		personnelOnglet.layout();
295 jp_milcent 2291
	}
2292
 
1208 cyprien 2293
	private void initialiserGrillePersonnelEnModification() {
2294
		mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE);
295 jp_milcent 2295
	}
1208 cyprien 2296
}