Subversion Repositories eFlore/Applications.coel

Rev

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