Subversion Repositories eFlore/Applications.coel

Rev

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