Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
69 jpm 1
package org.tela_botanica.client.vues;
2
 
91 jpm 3
import java.util.ArrayList;
4
import java.util.Iterator;
69 jpm 5
import java.util.List;
6
 
91 jpm 7
import org.tela_botanica.client.Modele;
8
import org.tela_botanica.client.RegistreId;
69 jpm 9
import org.tela_botanica.client.interfaces.Rafraichissable;
91 jpm 10
import org.tela_botanica.client.modeles.Configuration;
100 jpm 11
import org.tela_botanica.client.modeles.InterneValeur;
12
import org.tela_botanica.client.modeles.InterneValeurListe;
102 jpm 13
import org.tela_botanica.client.modeles.Personne;
91 jpm 14
import org.tela_botanica.client.modeles.Valeur;
15
import org.tela_botanica.client.modeles.ValeurListe;
69 jpm 16
 
91 jpm 17
import com.extjs.gxt.ui.client.Registry;
69 jpm 18
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
100 jpm 19
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
20
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
103 jpm 21
import com.extjs.gxt.ui.client.event.SelectionListener;
22
import com.extjs.gxt.ui.client.event.ToolBarEvent;
69 jpm 23
import com.extjs.gxt.ui.client.store.ListStore;
102 jpm 24
import com.extjs.gxt.ui.client.widget.ContentPanel;
69 jpm 25
import com.extjs.gxt.ui.client.widget.LayoutContainer;
100 jpm 26
import com.extjs.gxt.ui.client.widget.TabItem;
27
import com.extjs.gxt.ui.client.widget.TabPanel;
69 jpm 28
import com.extjs.gxt.ui.client.widget.button.Button;
108 jpm 29
import com.extjs.gxt.ui.client.widget.form.CheckBox;
30
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
69 jpm 31
import com.extjs.gxt.ui.client.widget.form.ComboBox;
100 jpm 32
import com.extjs.gxt.ui.client.widget.form.DateField;
33
import com.extjs.gxt.ui.client.widget.form.FieldSet;
69 jpm 34
import com.extjs.gxt.ui.client.widget.form.FormPanel;
103 jpm 35
import com.extjs.gxt.ui.client.widget.form.LabelField;
102 jpm 36
import com.extjs.gxt.ui.client.widget.form.NumberField;
109 jpm 37
import com.extjs.gxt.ui.client.widget.form.Radio;
38
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
69 jpm 39
import com.extjs.gxt.ui.client.widget.form.TextField;
40
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
41
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
102 jpm 42
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
43
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
44
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
45
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
46
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
47
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
69 jpm 48
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
49
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
50
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
51
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
100 jpm 52
import com.extjs.gxt.ui.client.widget.layout.FormData;
69 jpm 53
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
102 jpm 54
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
55
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
56
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
91 jpm 57
import com.google.gwt.core.client.GWT;
100 jpm 58
import com.google.gwt.i18n.client.DateTimeFormat;
102 jpm 59
import com.google.gwt.i18n.client.NumberFormat;
69 jpm 60
 
61
public class FormStructureVue extends LayoutContainer implements Rafraichissable {
62
 
91 jpm 63
	private Modele coelModele = null ;
64
	private ListStore<Valeur> magazinLstpr = null;
65
	private ComboBox<Valeur> comboLstpr = null;
66
	private ListStore<Valeur> magazinLstpu = null;
67
	private ComboBox<Valeur> comboLstpu = null;
103 jpm 68
	private ListStore<Valeur> magazinLiStatut = null;
69
	private ComboBox<Valeur> comboLiStatut = null;
70
	private ListStore<Valeur> magazinLiFonction = null;
71
	private ComboBox<Valeur> comboLiFonction = null;
100 jpm 72
	private ComboBox<InterneValeur> comboAcronyme = null;
73
	private TextField<String> ihChp = null;
74
	private TextField<String> mnhnChp = null;
75
	private ComboBox<InterneValeur> comboTypeStructure = null;
108 jpm 76
	private TabItem personnelOnglet = null;
103 jpm 77
	private EditorGrid<Personne> grillePersonnel = null;
78
	private ListStore<Personne> personnelGrilleMagazin = null;
79
	private LabelField nbreTotalPersonnelChp = null;
108 jpm 80
	private TabItem conservationOnglet = null;
81
	private CheckBoxGroup trukLocalStockageCacGrpChp = null;
82
	private ContentPanel trukLocalStockageCp = null;
83
	private CheckBoxGroup trukMeubleStockageCacGrpChp = null;
84
	private ContentPanel trukMeubleStockageCp = null;
109 jpm 85
	private CheckBoxGroup trukParametreStockageCacGrpChp = null;
86
	private ContentPanel trukParametreStockageCp = null;
91 jpm 87
 
69 jpm 88
	public FormStructureVue() {
100 jpm 89
		//+-----------------------------------------------------------------------------------------------------------+
90
		// Initialisation de variables
69 jpm 91
		setLayout(new FitLayout());
91 jpm 92
		coelModele = Registry.get(RegistreId.MODELE);
93
 
100 jpm 94
		// Création de la disposition : FIELDSET
95
		FormLayout layoutFieldset = new FormLayout();
96
		layoutFieldset.setLabelWidth(200);
97
		layoutFieldset.setPadding(4);
98
 
99
		//+-----------------------------------------------------------------------------------------------------------+
69 jpm 100
		// Création du panneau Formulaire
101
		FormPanel panel = new FormPanel();
100 jpm 102
		panel.setFrame(true);
69 jpm 103
		panel.setIconStyle("icone-form-ajouter");
104
		panel.setCollapsible(false);
105
		panel.setHeading("Ajout d'une institution");
106
		panel.setButtonAlign(HorizontalAlignment.CENTER);
100 jpm 107
		panel.setLayout(new FlowLayout());
108
 
109
		// Création des onglets
102 jpm 110
		TabPanel onglets = new TabPanel();
111
		onglets.setAutoHeight(true);
100 jpm 112
		//tabs.setDeferredRender(false);
69 jpm 113
 
100 jpm 114
		//+-----------------------------------------------------------------------------------------------------------+
115
		// Onlget formulaire IDENTIFICATION
116
		TabItem identificationOnglet = new TabItem();
117
		identificationOnglet.setText("Identification");
118
		identificationOnglet.setLayout(new FormLayout());
69 jpm 119
 
100 jpm 120
		// Fieldset IDENTITÉ
121
		FieldSet fieldSetIdentite = new FieldSet();
122
		fieldSetIdentite.setHeading("Identité");
123
		fieldSetIdentite.setCollapsible(true);
124
		fieldSetIdentite.setLayout(layoutFieldset);
125
 
69 jpm 126
		TextField<String> nomStructureChp = new TextField<String>();
127
		nomStructureChp.setFieldLabel("Nom de la structure");
128
		nomStructureChp.setAllowBlank(false);
100 jpm 129
		nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire.");
130
		fieldSetIdentite.add(nomStructureChp, new FormData(450, 0));
69 jpm 131
 
100 jpm 132
		// Création du sous-formulaire : Acronyme
133
		LayoutContainer ligne = new LayoutContainer();
134
		ligne.setLayout(new ColumnLayout());
135
		LayoutContainer gauche = new LayoutContainer();
136
		FormLayout layoutGauche = new FormLayout();
137
		layoutGauche.setLabelAlign(LabelAlign.LEFT);
138
		layoutGauche.setLabelWidth(200);
139
		layoutGauche.setPadding(0);
140
		gauche.setLayout(layoutGauche);
141
		LayoutContainer droite = new LayoutContainer();
142
		FormLayout layoutDroite = new FormLayout();
143
		layoutDroite.setLabelWidth(0);
144
		layoutDroite.setPadding(0);
145
		droite.setLayout(layoutDroite);
69 jpm 146
 
100 jpm 147
		ListStore<InterneValeur> acronymes = new ListStore<InterneValeur>();
148
		acronymes.add(InterneValeurListe.getTypeAcronyme());
69 jpm 149
 
100 jpm 150
		comboAcronyme = new ComboBox<InterneValeur>();
151
		comboAcronyme.setEmptyText("Sélectioner un type d'acronyme...");
152
		comboAcronyme.setFieldLabel("Acronymes");
153
		comboAcronyme.setDisplayField("nom");
154
		comboAcronyme.setStore(acronymes);
155
		comboAcronyme.setEditable(false);
156
		comboAcronyme.setTypeAhead(true);
157
		comboAcronyme.setTriggerAction(TriggerAction.ALL);
158
		comboAcronyme.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {
102 jpm 159
			@Override
100 jpm 160
			public void selectionChanged(SelectionChangedEvent<InterneValeur> se) {
161
				String acronymeAbr = se.getSelectedItem().getAbr();
162
				if (acronymeAbr.equals("IH")) {
163
					mnhnChp.hide();
164
					ihChp.show();
165
				} else if (acronymeAbr.equals("MNHN")) {
166
					ihChp.hide();
167
					mnhnChp.show();
168
				} else if (acronymeAbr.equals("")) {
169
					ihChp.hide();
170
					mnhnChp.hide();
171
					comboAcronyme.clearSelections();
172
				}
173
			}
174
        });
175
		gauche.add(comboAcronyme);
176
 
177
		ihChp = new TextField<String>();
178
		//ihChp.setEmptyText("Index Herbariorum");
179
		ihChp.setLabelSeparator("");
180
		ihChp.setToolTip("Index Herbariorum : herbier de plus de 5000 échantillons");
181
		ihChp.hide();
182
		droite.add(ihChp);
183
 
184
		mnhnChp = new TextField<String>();
185
		//mnhnChp.setEmptyText("MNHN");
186
		mnhnChp.setLabelSeparator("");
187
		mnhnChp.setToolTip("Acronyme MNHN : herbier de moins de 5000 échantillons");
188
		mnhnChp.hide();
189
		droite.add(mnhnChp);
190
 
191
		ligne.add(gauche, new ColumnData(0.5));
192
		ligne.add(droite, new ColumnData(0.5));
193
		fieldSetIdentite.add(ligne);
194
 
195
		// Création du sous-formulaire : Type de Structure
196
		LayoutContainer ligneTs = new LayoutContainer();
197
		ligneTs.setLayout(new ColumnLayout());
198
 
199
		LayoutContainer gaucheTs = new LayoutContainer();
200
		layoutGauche = new FormLayout();
201
		layoutGauche.setLabelAlign(LabelAlign.LEFT);
202
		layoutGauche.setLabelWidth(200);
203
		layoutGauche.setPadding(0);
204
		gaucheTs.setLayout(layoutGauche);
205
 
206
		LayoutContainer droiteTs = new LayoutContainer();
207
		layoutDroite = new FormLayout();
208
		layoutDroite.setLabelWidth(0);
209
		layoutDroite.setPadding(0);
210
		droiteTs.setLayout(layoutDroite);
211
 
212
		ListStore<InterneValeur> typesStructure = new ListStore<InterneValeur>();
213
		typesStructure.add(InterneValeurListe.getTypeStructure());
214
 
215
		this.comboTypeStructure = new ComboBox<InterneValeur>();
216
		comboTypeStructure.setEmptyText("Sélectioner un type de structure...");
217
		comboTypeStructure.setFieldLabel("Statut des structures");
218
		comboTypeStructure.setDisplayField("nom");
219
		comboTypeStructure.setStore(typesStructure);
220
		comboTypeStructure.setEditable(false);
221
		comboTypeStructure.setTypeAhead(true);
222
		comboTypeStructure.setTriggerAction(TriggerAction.ALL);
223
		comboTypeStructure.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {
102 jpm 224
			@Override
100 jpm 225
			public void selectionChanged(SelectionChangedEvent<InterneValeur> se) {
226
				String typeAbr = se.getSelectedItem().getAbr();
227
				if (typeAbr.equals("stpu")) {
228
					comboLstpr.hide();
229
					comboLstpu.show();
230
				} else if (typeAbr.equals("stpr")) {
231
					comboLstpu.hide();
232
					comboLstpr.show();
233
				} else if (typeAbr.equals("")) {
234
					comboLstpr.hide();
235
					comboLstpu.hide();
236
					comboTypeStructure.clearSelections();
237
				}
238
			}
239
        });
240
		gaucheTs.add(comboTypeStructure);
241
 
91 jpm 242
		coelModele.obtenirListeValeurs(((Configuration) Registry.get(RegistreId.CONFIG)).getListeId("stpu"));
243
		magazinLstpu = new ListStore<Valeur>();
244
		magazinLstpu.add(new ArrayList<Valeur>());
245
		comboLstpu = new ComboBox<Valeur>();
100 jpm 246
		//comboLstpu.setFieldLabel("Statut des structures publiques");
247
		comboLstpu.setLabelSeparator("");
91 jpm 248
		comboLstpu.setDisplayField("nom");
100 jpm 249
		comboLstpu.setEditable(false);
91 jpm 250
		comboLstpu.setTriggerAction(TriggerAction.ALL);
251
		comboLstpu.setStore(magazinLstpu);
100 jpm 252
		comboLstpu.hide();
253
		droiteTs.add(comboLstpu);
69 jpm 254
 
91 jpm 255
		coelModele.obtenirListeValeurs(((Configuration) Registry.get(RegistreId.CONFIG)).getListeId("stpr"));
256
		magazinLstpr = new ListStore<Valeur>();
257
		magazinLstpr.add(new ArrayList<Valeur>());
258
		comboLstpr = new ComboBox<Valeur>();
100 jpm 259
		//comboLstpr.setFieldLabel("Statut des structures privées");
260
		comboLstpr.setLabelSeparator("");
91 jpm 261
		comboLstpr.setDisplayField("nom");
100 jpm 262
		comboLstpr.setEditable(false);
91 jpm 263
		comboLstpr.setTriggerAction(TriggerAction.ALL);
264
		comboLstpr.setStore(magazinLstpr);
100 jpm 265
		comboLstpr.hide();
266
		droiteTs.add(comboLstpr);
69 jpm 267
 
100 jpm 268
		ligneTs.add(gaucheTs, new ColumnData(0.5));
269
		ligneTs.add(droiteTs, new ColumnData(0.5));
270
		fieldSetIdentite.add(ligneTs);
271
 
272
		DateField dateFondationChp = new DateField();
273
		dateFondationChp.setFieldLabel("Date de fondation");
274
		dateFondationChp.getPropertyEditor().getFormat();
275
		dateFondationChp.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
276
		dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
277
		fieldSetIdentite.add(dateFondationChp);
278
 
279
		identificationOnglet.add(fieldSetIdentite);
280
 
281
		// Fieldset ADRESSE
282
		LayoutContainer principalFdAdresse = new LayoutContainer();
283
		principalFdAdresse.setLayout(new ColumnLayout());
284
 
285
		LayoutContainer gaucheFdAdresse = new LayoutContainer();
286
		layoutGauche = new FormLayout();
287
		layoutGauche.setLabelAlign(LabelAlign.LEFT);
288
		layoutGauche.setLabelWidth(100);
289
		layoutGauche.setPadding(0);
290
		gaucheFdAdresse.setLayout(layoutGauche);
291
 
292
		LayoutContainer droiteFdAdresse = new LayoutContainer();
293
		layoutDroite = new FormLayout();
294
		layoutDroite.setLabelAlign(LabelAlign.LEFT);
295
		layoutDroite.setLabelWidth(100);
296
		layoutDroite.setPadding(0);
297
		droiteFdAdresse.setLayout(layoutDroite);
298
 
299
		FieldSet fieldSetAdresse = new FieldSet();
300
		fieldSetAdresse.setHeading("Adresse");
301
		fieldSetAdresse.setCollapsible(true);
302
 
303
		layoutFieldset = new FormLayout();
304
		layoutFieldset.setLabelWidth(100);
305
		layoutFieldset.setPadding(4);
306
		fieldSetAdresse.setLayout(layoutFieldset);
307
 
91 jpm 308
		TextField<String> adrChp = new TextField<String>();
309
		adrChp.setFieldLabel("Adresse");
100 jpm 310
		fieldSetAdresse.add(adrChp, new FormData(550, 0));
69 jpm 311
 
91 jpm 312
		TextField<String> cpChp = new TextField<String>();
313
		cpChp.setFieldLabel("Code postal");
100 jpm 314
		gaucheFdAdresse.add(cpChp);
69 jpm 315
 
91 jpm 316
		TextField<String> villeChp = new TextField<String>();
317
		villeChp.setFieldLabel("Ville");
100 jpm 318
		droiteFdAdresse.add(villeChp);
69 jpm 319
 
91 jpm 320
		TextField<String> regionChp = new TextField<String>();
321
		regionChp.setFieldLabel("Région");
100 jpm 322
		gaucheFdAdresse.add(regionChp);
91 jpm 323
 
324
		TextField<String> paysChp = new TextField<String>();
325
		paysChp.setFieldLabel("Pays");
100 jpm 326
		droiteFdAdresse.add(paysChp);
91 jpm 327
 
100 jpm 328
		principalFdAdresse.add(gaucheFdAdresse, new ColumnData(.5));
329
		principalFdAdresse.add(droiteFdAdresse, new ColumnData(.5));
330
		fieldSetAdresse.add(principalFdAdresse);
331
		identificationOnglet.add(fieldSetAdresse);
332
 
333
		// Fieldset TÉLÉPHONE et EMAIL
334
 
335
		LayoutContainer principalFdTelMail = new LayoutContainer();
336
		principalFdTelMail.setLayout(new ColumnLayout());
337
 
338
		LayoutContainer gaucheFdTelMail = new LayoutContainer();
108 jpm 339
		gaucheFdTelMail.setLayout(creerFormLayout(100, LabelAlign.LEFT, 0));
100 jpm 340
 
341
		LayoutContainer droiteFdTelMail = new LayoutContainer();
108 jpm 342
		droiteFdTelMail.setLayout(creerFormLayout(100, LabelAlign.LEFT, 0));
100 jpm 343
 
344
		FieldSet fieldSetTelMail = new FieldSet();
345
		fieldSetTelMail.setHeading("Communication");
346
		fieldSetTelMail.setCollapsible(true);
347
 
108 jpm 348
		fieldSetTelMail.setLayout(creerFormLayout(200, LabelAlign.LEFT, 4));
100 jpm 349
 
91 jpm 350
		TextField<String> telChp = new TextField<String>();
351
		telChp.setFieldLabel("Téléphone");
100 jpm 352
		gaucheFdTelMail.add(telChp);
91 jpm 353
 
354
		TextField<String> faxChp = new TextField<String>();
355
		faxChp.setFieldLabel("Fax");
100 jpm 356
		droiteFdTelMail.add(faxChp);
91 jpm 357
 
358
		TextField<String> emailChp = new TextField<String>();
359
		emailChp.setFieldLabel("Courriel");
360
		emailChp.setToolTip("Saisir le courriel de l'organisation, pas de courriel individuel. Ex. : accueil@organisation.org");
100 jpm 361
		gaucheFdTelMail.add(emailChp);
91 jpm 362
 
363
		TextField<String> urlChp = new TextField<String>();
364
		urlChp.setFieldLabel("Site web");
100 jpm 365
		droiteFdTelMail.add(urlChp);
91 jpm 366
 
100 jpm 367
		principalFdTelMail.add(gaucheFdTelMail, new ColumnData(.5));
368
		principalFdTelMail.add(droiteFdTelMail, new ColumnData(.5));
369
		fieldSetTelMail.add(principalFdTelMail);
370
		identificationOnglet.add(fieldSetTelMail);
371
 
372
		onglets.add(identificationOnglet);
373
 
374
		//+-----------------------------------------------------------------------------------------------------------+
375
		// Onlget formulaire PERSONNEL
103 jpm 376
		onglets.add(creerOngletPersonnel());
91 jpm 377
 
100 jpm 378
		//+-----------------------------------------------------------------------------------------------------------+
379
		// Onlget formulaire CONSERVATION
108 jpm 380
		onglets.add(creerOngletConservation());
381
		onglets.setSelection(conservationOnglet);
100 jpm 382
 
383
		//+-----------------------------------------------------------------------------------------------------------+
384
		// Onlget formulaire VALORISATION
385
		TabItem valorisationOnglet = new TabItem();
386
		valorisationOnglet.setText("Valorisation");
387
		valorisationOnglet.setLayout(new FormLayout());
388
 
389
 
390
		onglets.add(valorisationOnglet);
391
 
392
		//+-----------------------------------------------------------------------------------------------------------+
393
		// Gestion du FORMULAIRE GÉNÉRAL
394
 
395
		// Ajout des onglets
396
		panel.add(onglets);
69 jpm 397
 
398
		// Ajout des boutons au panneau formulaire
399
		Button annulerBtn = new Button("Annuler");
400
		panel.addButton(annulerBtn);
401
		Button validerBtn = new Button("Valider");
402
		panel.addButton(validerBtn);
403
 
404
		// Ajout du panneau Formulaire à la disposition générale
405
		add(panel);
406
	}
108 jpm 407
 
408
	private TabItem creerOngletConservation() {
409
		conservationOnglet = new TabItem();
410
		conservationOnglet.setText("Conservation");
411
		conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));
412
 
109 jpm 413
		RadioGroup markFormationRGrpChp = new RadioGroup("mark_formation_grp");
414
		markFormationRGrpChp.setFieldLabel("Le personnel s'occupant des collections a-t-il suivi des formations en conservations ?");
415
		creerChoixUniqueBr(markFormationRGrpChp, "mark_formation");
416
		conservationOnglet.add(markFormationRGrpChp);
108 jpm 417
 
418
		TextField<String> formationChp = new TextField<String>();
419
		formationChp.setFieldLabel("Lesquelles ?");
420
		conservationOnglet.add(formationChp);
421
 
109 jpm 422
		RadioGroup markInteretFormationRGrpChp = new RadioGroup("mark_interet_formation_grp");
423
		markInteretFormationRGrpChp.setFieldLabel("Seriez vous intéressé par une formation à la conservation et à la restauration d'herbier ?");
424
		creerChoixUniqueBr(markInteretFormationRGrpChp, "mark_interet_formation_grp");
425
		conservationOnglet.add(markInteretFormationRGrpChp);
108 jpm 426
 
109 jpm 427
		trukLocalStockageCp = creerChoixMultipleCp("localStockage");
108 jpm 428
		conservationOnglet.add(trukLocalStockageCp);
429
 
109 jpm 430
		trukMeubleStockageCp = creerChoixMultipleCp("meubleStockage");
108 jpm 431
		conservationOnglet.add(trukMeubleStockageCp);
432
 
109 jpm 433
		trukParametreStockageCp = creerChoixMultipleCp("parametreStockage");
434
		conservationOnglet.add(trukParametreStockageCp);
435
 
436
		RadioGroup markCollectionCommuneRGrpChp = new RadioGroup("mark_collection_commune_grp");
437
		markCollectionCommuneRGrpChp.setFieldLabel("Les collections botaniques sont-elles conservées avec d'autres collections  dans les mêmes locaux (problème de conservation en commun) ?");
438
		creerChoixUniqueBr(markCollectionCommuneRGrpChp, "mark_collection_commune");
439
		conservationOnglet.add(markCollectionCommuneRGrpChp);
440
 
108 jpm 441
		return conservationOnglet;
442
	}
443
 
444
 
103 jpm 445
	private TabItem creerOngletPersonnel() {
108 jpm 446
		personnelOnglet = new TabItem();
103 jpm 447
		personnelOnglet.setText("Personnel");
448
		FormLayout personnelOngletLayout = new FormLayout();
449
		personnelOngletLayout.setLabelWidth(400);
450
		personnelOnglet.setLayout(personnelOngletLayout);
451
 
452
		NumberField nbreTotalPersonneStructureChp = new NumberField();
453
		nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution");
454
		nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#"));
455
		nbreTotalPersonneStructureChp.setToolTip("Ce champ doit contenir un nombre");
456
		personnelOnglet.add(nbreTotalPersonneStructureChp);
457
 
458
		personnelOnglet.add(this.creerGrillePersonnel());
459
 
460
		nbreTotalPersonnelChp = new LabelField();
461
		nbreTotalPersonnelChp.setFieldLabel("Nombre de personne travaillant sur les collections");
462
		nbreTotalPersonnelChp.setLabelSeparator(":");
463
		nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount());
464
		personnelOnglet.add(nbreTotalPersonnelChp);
465
 
466
		return personnelOnglet;
467
	}
468
 
102 jpm 469
	private ContentPanel creerGrillePersonnel() {
103 jpm 470
 
102 jpm 471
		List<Personne> personnes = new ArrayList<Personne>();
472
		personnes.add(new Personne(Valeur.FONCTION_DIRECTEUR));
473
		personnes.add(new Personne(Valeur.FONCTION_CONSERVATEUR));
474
 
103 jpm 475
		personnelGrilleMagazin = new ListStore<Personne>();
476
		personnelGrilleMagazin.add(personnes);
477
 
102 jpm 478
		List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
479
 
480
		CheckBoxSelectionModel<Personne> sm = new CheckBoxSelectionModel<Personne>();
481
		configs.add(sm.getColumn());
103 jpm 482
 
483
		ColumnConfig column = new ColumnConfig("ce_truk_fonction", "Fonction", 100);
484
		coelModele.obtenirListeValeurs(((Configuration) Registry.get(RegistreId.CONFIG)).getListeId("fonction"));
485
		magazinLiFonction = new ListStore<Valeur>();
486
		magazinLiFonction.add(new ArrayList<Valeur>());
487
 
488
		comboLiFonction = new ComboBox<Valeur>();
489
		comboLiFonction.setTriggerAction(TriggerAction.ALL);
490
		comboLiFonction.setEditable(true);
491
		comboLiFonction.setDisplayField("nom");
492
		//comboLiStatut.setEmptyText("Sélectionez une fonction...");
493
		comboLiFonction.setStore(magazinLiFonction);
494
 
495
		CellEditor fonctionEditor = new CellEditor(comboLiFonction) {
496
			@Override
497
			public Object preProcessValue(Object value) {
498
				if (value == null) {
499
					return value;
500
				}
501
				//GWT.log("pre : "+value.toString(), null);
502
				return comboLiFonction.getStore().findModel("nom", (String) value);
503
			}
504
 
505
			@Override
506
			public Object postProcessValue(Object value) {
507
				if (value == null) {
508
					return value;
509
				}
510
				//GWT.log("post : "+value.toString(), null);
511
				return ((Valeur) value).get("nom");
512
			}
513
		};
514
		column.setEditor(fonctionEditor);
102 jpm 515
		configs.add(column);
516
 
517
		column = new ColumnConfig();
518
		column.setId("prenom");
103 jpm 519
		column.setHeader("Prénom");
520
		column.setWidth(100);
521
		TextField<String> prenomChp = new TextField<String>();
522
		prenomChp.setAllowBlank(false);
523
		prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");
524
		prenomChp.setAutoValidate(true);
525
		column.setEditor(new CellEditor(prenomChp));
102 jpm 526
		configs.add(column);
527
 
528
		column = new ColumnConfig();
529
		column.setId("nom");
530
		column.setHeader("Nom");
103 jpm 531
		column.setWidth(100);
532
		TextField<String> nomChp = new TextField<String>();
533
		nomChp.setAllowBlank(false);
534
		nomChp.getMessages().setBlankText("Ce champ est obligatoire.");
535
		nomChp.setAutoValidate(true);
536
		column.setEditor(new CellEditor(nomChp));
102 jpm 537
		configs.add(column);
538
 
103 jpm 539
		column = new ColumnConfig("tel", "Téléphone", 100);
540
		TextField<String> telChp = new TextField<String>();
541
		column.setEditor(new CellEditor(telChp));
102 jpm 542
		configs.add(column);
543
 
544
		column = new ColumnConfig("fax", "Fax", 100);
103 jpm 545
		TextField<String> faxChp = new TextField<String>();
546
		column.setEditor(new CellEditor(faxChp));
102 jpm 547
		configs.add(column);
548
 
103 jpm 549
		column = new ColumnConfig("courriel", "Courriel", 100);
550
		TextField<String> emailChp = new TextField<String>();
551
		column.setEditor(new CellEditor(emailChp));
102 jpm 552
		configs.add(column);
553
 
103 jpm 554
		coelModele.obtenirListeValeurs(((Configuration) Registry.get(RegistreId.CONFIG)).getListeId("statut"));
555
		magazinLiStatut = new ListStore<Valeur>();
556
		magazinLiStatut.add(new ArrayList<Valeur>());
557
 
558
		comboLiStatut = new ComboBox<Valeur>();
559
		comboLiStatut.setTriggerAction(TriggerAction.ALL);
560
		comboLiStatut.setEditable(false);
561
		comboLiStatut.setDisplayField("nom");
562
		comboLiStatut.setEmptyText("Sélectionez un statut...");
563
		comboLiStatut.setStore(magazinLiStatut);
564
 
565
		CellEditor statutEditor = new CellEditor(comboLiStatut) {
566
			@Override
567
			public Object preProcessValue(Object value) {
568
				if (value == null) {
569
					return value;
570
				}
571
				//GWT.log("pre : "+value.toString(), null);
572
				return comboLiStatut.getStore().findModel("nom", (String) value);
573
			}
574
 
575
			@Override
576
			public Object postProcessValue(Object value) {
577
				if (value == null) {
578
					return value;
579
				}
580
				//GWT.log("post : "+value.toString(), null);
581
				return ((Valeur) value).get("nom");
582
			}
583
		};
584
		column = new ColumnConfig("statut", "Statut", 100);
585
		column.setEditor(statutEditor);
102 jpm 586
		configs.add(column);
587
 
103 jpm 588
		column = new ColumnConfig("tps_w", "Temps travail", 100);
589
		column.setNumberFormat(NumberFormat.getFormat("##"));
590
		NumberField tpsWChp = new NumberField();
591
		tpsWChp.setFormat(NumberFormat.getFormat("##"));
592
		tpsWChp.setToolTip("Ce champ doit contenir un nombre");
593
		column.setEditor(new CellEditor(tpsWChp));
594
		configs.add(column);
595
 
596
		column = new ColumnConfig("specialites", "Spécialités botaniques", 150);
597
		TextField<String> speChp = new TextField<String>();
598
		column.setEditor(new CellEditor(speChp));
599
		configs.add(column);
600
 
601
		CheckColumnConfig checkColumn = new CheckColumnConfig("mark_contact", "Contact ?", 60);
102 jpm 602
		configs.add(checkColumn);
603
 
604
		ContentPanel cp = new ContentPanel();
605
		cp.setHeading("Personnes travaillant sur les collections");
103 jpm 606
		cp.setIconStyle("icone-table");
607
		cp.setLayout(new FitLayout());
102 jpm 608
		cp.setFrame(true);
609
 
610
		ToolBar toolBar = new ToolBar();
103 jpm 611
 
612
		TextToolItem ajouterPersonnelBtn = new TextToolItem("Ajouter", "icone-vcard-ajouter");
613
		ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {
614
			@Override
615
			public void componentSelected(ToolBarEvent ce) {
616
				Personne personne = new Personne();
617
				grillePersonnel.stopEditing();
618
				personnelGrilleMagazin.insert(personne, 0);
619
				grillePersonnel.startEditing(0, 0);
620
				// Mise à jour du nombre de personnel travaillant sur les collections
621
				nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount());
622
				// Activation du bouton supprimer si la grille contient un élément
623
				if (grillePersonnel.getStore().getCount() > 0) {
624
					ce.component.enable();
625
				}
626
			}
627
		});
628
		toolBar.add(ajouterPersonnelBtn);
629
		toolBar.add(new SeparatorToolItem());
630
		TextToolItem supprimerPersonnelBtn = new TextToolItem("Supprimer", "icone-vcard-supprimer");
631
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {
632
			@Override
633
			public void componentSelected(ToolBarEvent ce) {
634
				grillePersonnel.getStore().remove(grillePersonnel.getStore().getAt(0));
635
				// Mise à jour du nombre de personnel travaillant sur les collections
636
				nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount());
637
				// Désactivation du bouton supprimer si la grille contient plus d'élément
638
				if (grillePersonnel.getStore().getCount() == 0) {
639
					ce.item.disable();
640
				}
641
			}
642
		});
643
		toolBar.add(supprimerPersonnelBtn);
102 jpm 644
		cp.setTopComponent(toolBar);
645
 
646
		ColumnModel cm = new ColumnModel(configs);
647
 
103 jpm 648
		grillePersonnel = new EditorGrid<Personne>(personnelGrilleMagazin, cm);
649
		grillePersonnel.setBorders(true);
650
		grillePersonnel.setSelectionModel(sm);
651
		grillePersonnel.addPlugin(sm);
652
		grillePersonnel.addPlugin(checkColumn);
653
  		grillePersonnel.setSize(1010, 400);
102 jpm 654
 
103 jpm 655
		cp.add(grillePersonnel);
102 jpm 656
		return cp;
657
	}
658
 
108 jpm 659
	/** Méthode simplifiant la création de FormLayout.
660
	 *
661
	 * @param labelWidth largeur des labels
662
	 * @param labelAlign alignement des labels
663
	 * @param padding padding du layout
664
	 * @return
665
	 */
666
	private FormLayout creerFormLayout(Integer labelWidth, LabelAlign labelAlign, Integer padding) {
667
		FormLayout formLayout = new FormLayout();
668
		formLayout.setLabelWidth(labelWidth);
669
		formLayout.setLabelAlign(labelAlign);
670
		if (padding != null) {
671
			formLayout.setPadding(padding);
672
		}
673
		return formLayout;
674
	}
675
 
109 jpm 676
	/** Méthode simplifiant la création de bouton radio oui/non
677
	 *
678
	 * @param listeNom nom de la liste de valeur
679
	 * @return
680
	 */
681
	private void creerChoixUniqueBr(RadioGroup radioGroup, String attributNom ) {
682
		Radio ouiRadio = new Radio();
683
		ouiRadio.setName(attributNom);
684
		ouiRadio.setBoxLabel("Oui");
685
		//ouiRadio.setValue(true);
686
 
687
		Radio nonRadio = new Radio();
688
		nonRadio.setName(attributNom);
689
		nonRadio.setBoxLabel("Non");
690
 
691
		radioGroup.add(ouiRadio);
692
		radioGroup.add(nonRadio);
693
	}
694
 
695
	/** Méthode simplifiant la création de choix multiple sous forme de case à cocher.
696
	 * Apelle un service retournant la liste des valeurs représentant les cases à cocher.
697
	 * Ajoute ou pas un champ "Autre".
698
	 *
699
	 * @param listeNom nom de la liste de valeur
700
	 * @return
701
	 */
702
	private ContentPanel creerChoixMultipleCp(String listeNom) {
703
		coelModele.obtenirListeValeurs(((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeNom));
704
		ContentPanel cp = new ContentPanel();
705
		cp.setLayout(creerFormLayout(650, LabelAlign.TOP, 0));
706
		cp.setWidth("100%");
707
		cp.setHeaderVisible(false);
708
		return cp;
709
	}
710
 
711
	/** Méthode simplifiant la création de choix multiple sous forme de case à cocher.
712
	 * Apelle un service retournant la liste des valeurs représentant les cases à cocher.
713
	 * Ajoute ou pas un champ "Autre".
714
	 *
715
	 * @param cp panneau conteant le groupe de case à cocher
716
	 * @param cacGroup le groupe de case à cocher
717
	 * @param labelTxt le texte du champ
718
	 * @param listeValeurs la liste de valeurs à transformer en case à cocher
719
	 * @param boolAutreChp booléen indiquant si oui ou non le champ autre doit apparaître
720
	 * @return
721
	 */
722
	private void creerChoixMultipleCac(ContentPanel cp, CheckBoxGroup cacGroupe, String labelTxt, ValeurListe listeValeurs, Boolean boolAutreChp) {
723
		cacGroupe.setFieldLabel(labelTxt);
724
		for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
725
			String nom =  listeValeurs.get(it.next()).get("nom");
726
			CheckBox cac = new CheckBox();
727
			GWT.log("Taille '"+nom+"' : "+nom.length(), null);
728
			// Calcul de la largeur de la checkbox en fonction de la taille du label
729
			int largeur = nom.length()*10;
730
			if (nom.length() > 15) {
731
				largeur = 170;
732
			}
733
			if (nom.length() > 25) {
734
				largeur = 250;
735
			}
736
			cac.setWidth(largeur);
737
			cac.setBoxLabel(nom);
738
			cacGroupe.add(cac);
739
		}
740
		cp.add(cacGroupe);
741
 
742
		if (boolAutreChp == true) {
743
			ContentPanel autreCp = new ContentPanel();
744
			autreCp.setLayout(creerFormLayout(75, LabelAlign.TOP, 0));
745
			autreCp.setHeaderVisible(false);
746
			TextField<String> autreTrukLocalStockageChp = new TextField<String>();
747
			autreTrukLocalStockageChp.setFieldLabel("Autre");
748
			autreTrukLocalStockageChp.setLabelStyle("font-weight:normal;");
749
			autreTrukLocalStockageChp.setWidth(300);
750
			autreCp.add(autreTrukLocalStockageChp);
751
			cp.add(autreCp);
752
		}
753
 
754
		cp.layout();
755
	}
756
 
69 jpm 757
	public void rafraichir(Object nouvelleDonnees) {
91 jpm 758
		if (nouvelleDonnees instanceof ValeurListe) {
759
			ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;
760
 
761
			List<Valeur> liste = new ArrayList<Valeur>();
762
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
763
				liste.add(listeValeurs.get(it.next()));
764
			}
765
			// Test pour savoir si la liste contient des éléments
766
			if (liste.size() > 0) {
767
				Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
768
				if (listeValeurs.getId().equals(config.getListeId("stpr"))) {
769
					magazinLstpr.removeAll();
770
					magazinLstpr.add(liste);
771
					comboLstpr.setStore(magazinLstpr);
772
				}
773
				if (listeValeurs.getId().equals(config.getListeId("stpu"))) {
774
					magazinLstpu.removeAll();
775
					magazinLstpu.add(liste);
776
					comboLstpu.setStore(magazinLstpu);
777
				}
103 jpm 778
				if (listeValeurs.getId().equals(config.getListeId("statut"))) {
779
					magazinLiStatut.removeAll();
780
					magazinLiStatut.add(liste);
781
					comboLiStatut.setStore(magazinLiStatut);
782
				}
783
				if (listeValeurs.getId().equals(config.getListeId("fonction"))) {
784
					magazinLiFonction.removeAll();
785
					magazinLiFonction.add(liste);
786
					comboLiFonction.setStore(magazinLiFonction);
787
				}
108 jpm 788
				if (listeValeurs.getId().equals(config.getListeId("localStockage"))) {
789
					trukLocalStockageCacGrpChp = new CheckBoxGroup();
109 jpm 790
					String labelTxt = "Avez vous des locaux spécifiques de stockage des collections botaniques ?";
791
					creerChoixMultipleCac(trukLocalStockageCp, trukLocalStockageCacGrpChp, labelTxt, listeValeurs, true);
108 jpm 792
				}
793
				if (listeValeurs.getId().equals(config.getListeId("meubleStockage"))) {
794
					trukMeubleStockageCacGrpChp = new CheckBoxGroup();
109 jpm 795
					String labelTxt = "Avez vous des meubles spécifiques au stockage des collections botaniques ?";
796
					creerChoixMultipleCac(trukMeubleStockageCp, trukMeubleStockageCacGrpChp, labelTxt, listeValeurs, true);
108 jpm 797
				}
109 jpm 798
				if (listeValeurs.getId().equals(config.getListeId("parametreStockage"))) {
799
					trukParametreStockageCacGrpChp = new CheckBoxGroup();
800
					String labelTxt = "Quels paramètres maîtrisez vous ?";
801
					creerChoixMultipleCac(trukParametreStockageCp, trukParametreStockageCacGrpChp, labelTxt, listeValeurs, true);
802
				}
103 jpm 803
				GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
91 jpm 804
			} else {
805
				GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
806
			}
807
		}
69 jpm 808
	}
100 jpm 809
 
69 jpm 810
}