Subversion Repositories eFlore/Applications.coel

Rev

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