Subversion Repositories eFlore/Applications.coel

Rev

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