Subversion Repositories eFlore/Applications.coel

Rev

Rev 231 | Rev 245 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 231 Rev 243
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line 2...
2
 
2
 
3
import java.util.ArrayList;
-
 
4
import java.util.Arrays;
3
import java.util.ArrayList;
5
import java.util.Iterator;
4
import java.util.Iterator;
6
import java.util.List;
-
 
Line 7... Line -...
7
import java.util.Map;
-
 
8
 
5
import java.util.List;
9
import org.tela_botanica.client.ComposantId;
6
 
10
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.Modele;
8
import org.tela_botanica.client.Modele;
12
import org.tela_botanica.client.RegistreId;
9
import org.tela_botanica.client.RegistreId;
13
import org.tela_botanica.client.i18n.Constantes;
10
import org.tela_botanica.client.i18n.Constantes;
14
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
15
import org.tela_botanica.client.modeles.Configuration;
12
import org.tela_botanica.client.modeles.Configuration;
16
import org.tela_botanica.client.modeles.Information;
13
import org.tela_botanica.client.modeles.Information;
17
import org.tela_botanica.client.modeles.InterneValeur;
14
import org.tela_botanica.client.modeles.InterneValeur;
-
 
15
import org.tela_botanica.client.modeles.InterneValeurListe;
18
import org.tela_botanica.client.modeles.InterneValeurListe;
16
import org.tela_botanica.client.modeles.Personne;
19
import org.tela_botanica.client.modeles.Personne;
17
import org.tela_botanica.client.modeles.PersonneListe;
20
import org.tela_botanica.client.modeles.Structure;
18
import org.tela_botanica.client.modeles.Structure;
21
import org.tela_botanica.client.modeles.StructureAPersonne;
19
import org.tela_botanica.client.modeles.StructureAPersonne;
22
import org.tela_botanica.client.modeles.StructureAPersonneListe;
-
 
23
import org.tela_botanica.client.modeles.StructureConservation;
20
import org.tela_botanica.client.modeles.StructureAPersonneListe;
24
import org.tela_botanica.client.modeles.StructureListe;
21
import org.tela_botanica.client.modeles.StructureConservation;
25
import org.tela_botanica.client.modeles.StructureValorisation;
22
import org.tela_botanica.client.modeles.StructureValorisation;
-
 
23
import org.tela_botanica.client.modeles.Valeur;
Line 26... Line 24...
26
import org.tela_botanica.client.modeles.Valeur;
24
import org.tela_botanica.client.modeles.ValeurListe;
27
import org.tela_botanica.client.modeles.ValeurListe;
25
import org.tela_botanica.client.util.UtilArray;
28
 
26
 
29
import com.extjs.gxt.ui.client.Events;
27
import com.extjs.gxt.ui.client.Events;
30
import com.extjs.gxt.ui.client.Registry;
-
 
31
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
28
import com.extjs.gxt.ui.client.Registry;
32
import com.extjs.gxt.ui.client.Style.Scroll;
29
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
33
import com.extjs.gxt.ui.client.Style.SelectionMode;
-
 
34
import com.extjs.gxt.ui.client.event.BaseEvent;
30
import com.extjs.gxt.ui.client.Style.Scroll;
-
 
31
import com.extjs.gxt.ui.client.data.BaseModelData;
35
import com.extjs.gxt.ui.client.event.ComponentEvent;
32
import com.extjs.gxt.ui.client.event.ComponentEvent;
36
import com.extjs.gxt.ui.client.event.EditorEvent;
33
import com.extjs.gxt.ui.client.event.GridEvent;
37
import com.extjs.gxt.ui.client.event.GridEvent;
34
import com.extjs.gxt.ui.client.event.KeyListener;
38
import com.extjs.gxt.ui.client.event.Listener;
35
import com.extjs.gxt.ui.client.event.Listener;
39
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
36
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
40
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
37
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
41
import com.extjs.gxt.ui.client.event.SelectionListener;
-
 
42
import com.extjs.gxt.ui.client.event.ToolBarEvent;
-
 
43
import com.extjs.gxt.ui.client.store.ListStore;
38
import com.extjs.gxt.ui.client.event.SelectionListener;
44
import com.extjs.gxt.ui.client.store.Record;
39
import com.extjs.gxt.ui.client.event.ToolBarEvent;
45
import com.extjs.gxt.ui.client.store.Store;
40
import com.extjs.gxt.ui.client.store.ListStore;
46
import com.extjs.gxt.ui.client.widget.Component;
41
import com.extjs.gxt.ui.client.widget.Component;
47
import com.extjs.gxt.ui.client.widget.ContentPanel;
42
import com.extjs.gxt.ui.client.widget.ContentPanel;
48
import com.extjs.gxt.ui.client.widget.Info;
43
import com.extjs.gxt.ui.client.widget.Info;
49
import com.extjs.gxt.ui.client.widget.LayoutContainer;
-
 
50
import com.extjs.gxt.ui.client.widget.TabItem;
-
 
51
import com.extjs.gxt.ui.client.widget.TabPanel;
44
import com.extjs.gxt.ui.client.widget.LayoutContainer;
52
import com.extjs.gxt.ui.client.widget.VerticalPanel;
45
import com.extjs.gxt.ui.client.widget.TabItem;
53
import com.extjs.gxt.ui.client.widget.WidgetComponent;
46
import com.extjs.gxt.ui.client.widget.TabPanel;
54
import com.extjs.gxt.ui.client.widget.button.Button;
47
import com.extjs.gxt.ui.client.widget.button.Button;
55
import com.extjs.gxt.ui.client.widget.form.CheckBox;
48
import com.extjs.gxt.ui.client.widget.form.CheckBox;
Line 67... Line 60...
67
import com.extjs.gxt.ui.client.widget.form.TextArea;
60
import com.extjs.gxt.ui.client.widget.form.TextArea;
68
import com.extjs.gxt.ui.client.widget.form.TextField;
61
import com.extjs.gxt.ui.client.widget.form.TextField;
69
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
62
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
70
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
63
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
71
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
64
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
72
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
-
 
73
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
65
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
74
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
66
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
75
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
67
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
76
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
68
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
77
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
69
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
Line 81... Line 73...
81
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
73
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
82
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
74
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
83
import com.extjs.gxt.ui.client.widget.layout.FormData;
75
import com.extjs.gxt.ui.client.widget.layout.FormData;
84
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
76
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
85
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
77
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
-
 
78
import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem;
86
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
79
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
87
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
80
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
88
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
81
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
89
import com.google.gwt.core.client.GWT;
82
import com.google.gwt.core.client.GWT;
90
import com.google.gwt.i18n.client.DateTimeFormat;
83
import com.google.gwt.i18n.client.DateTimeFormat;
91
import com.google.gwt.i18n.client.NumberFormat;
84
import com.google.gwt.i18n.client.NumberFormat;
92
import com.google.gwt.user.client.Event;
-
 
93
import com.google.gwt.user.client.Random;
-
 
94
import com.google.gwt.user.client.Window;
85
import com.google.gwt.user.client.Window;
95
import com.google.gwt.user.client.ui.HTML;
-
 
96
import com.google.gwt.user.client.ui.Widget;
-
 
Line 97... Line 86...
97
 
86
 
Line 98... Line 87...
98
public class FormStructureVue extends LayoutContainer implements Rafraichissable {
87
public class FormStructureVue extends LayoutContainer implements Rafraichissable {
99
	
88
	
100
	private Constantes i18nC = null;
89
	private Constantes i18nC = null;
Line 101... Line 90...
101
	private Mediateur mediateur = null;
90
	private Mediateur mediateur = null;
102
	private Modele modele = null ;
91
	private Modele modele = null ;
103
 
-
 
104
	private String mode = "AJOUT";
92
 
Line 105... Line 93...
105
	private FormPanel structureFormPanneau = null;
93
	private String mode = "AJOUT";
106
	private int tabIndex = 100;
94
	private FormPanel structureFormPanneau = null;
107
	private TabPanel onglets = null;
95
	private TabPanel onglets = null;
Line 213... Line 201...
213
	private RadioGroup rechercheMarkRGrpChp;
201
	private RadioGroup rechercheMarkRGrpChp;
214
	private RadioGroup sansMotifAccesMarkRGrpChp;
202
	private RadioGroup sansMotifAccesMarkRGrpChp;
215
	private RadioGroup avecMotifAccesMarkRGrpChp;
203
	private RadioGroup avecMotifAccesMarkRGrpChp;
216
	private TextField<String> publicationChp;
204
	private TextField<String> publicationChp;
217
	private ContentPanel materielConservationCp;
205
	private ContentPanel materielConservationCp;
-
 
206
	private ListStore<Personne> personneExistanteMagazin;
-
 
207
	private ComboBox<Personne> personneExistanteCombo;
Line 218... Line 208...
218
 
208
 
219
 
209
 
220
	public FormStructureVue() {
210
	public FormStructureVue() {
Line 291... Line 281...
291
		// Ajout du panneau Formulaire à la disposition générale
281
		// Ajout du panneau Formulaire à la disposition générale
292
		add(structureFormPanneau);
282
		add(structureFormPanneau);
293
	}
283
	}
Line 294... Line 284...
294
	
284
	
-
 
285
	private void soumettreFormulaire() {
-
 
286
		// Vérification de la validité des champs du formulaire
295
	private void soumettreFormulaire() {
287
		if (verifierFormulaire()) {
-
 
288
			GWT.log("Soumission du formulaire", null);
296
		GWT.log("Soumission du formulaire", null);
289
			// Collecte des données du formulaire
297
		Structure structure = collecterStructureIdentification();
290
			Structure structure = collecterStructureIdentification();
298
		StructureConservation conservation = collecterStructureConservation();
291
			StructureConservation conservation = collecterStructureConservation();
299
		StructureValorisation valorisation = collecterStructureValorisation();
292
			StructureValorisation valorisation = collecterStructureValorisation();
300
		collecterStructurePersonnel();
293
			collecterStructurePersonnel();
301
		
294
			
302
		if (mode.equals("AJOUT")) {
295
			if (mode.equals("AJOUT")) {
303
			// Ajout des informations sur la Structure
296
				// Ajout des informations sur la Structure
304
			//mediateur.ajouterStructure(this, structure);
297
				//mediateur.ajouterStructure(this, structure);
305
			// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
298
				// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
306
			// Voir la méthode rafraichir().
299
				// Voir la méthode rafraichir().
307
		} else if (mode.equals("MODIF")) {
300
			} else if (mode.equals("MODIF")) {
308
			// Modification des informations sur la Structure
301
				// Modification des informations sur la Structure
309
			mediateur.modifierStructure(this, structure, conservation, valorisation);
302
				mediateur.modifierStructure(this, structure, conservation, valorisation);
310
			// Modification des relations StructureAPersonne
303
				// Modification des relations StructureAPersonne
311
			GWT.log("Personnel modifié :"+personnelModifie.size(), null);
304
				GWT.log("Personnel modifié :"+personnelModifie.size(), null);
312
			mediateur.modifierStructureAPersonne(this, personnelModifie);
305
				mediateur.modifierStructureAPersonne(this, personnelModifie);
313
			// Ajout des relations StructureAPersonne
306
				// Ajout des relations StructureAPersonne
314
			GWT.log("Personnel ajouté :"+personnelAjoute.size(), null);
307
				GWT.log("Personnel ajouté :"+personnelAjoute.size(), null);
315
			mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute);
308
				mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute);
316
			// Suppression des relations StructureAPersonne
309
				// Suppression des relations StructureAPersonne
317
			GWT.log("Personnel supprimé :"+personnelSupprime.size(), null);
310
				GWT.log("Personnel supprimé :"+personnelSupprime.size(), null);
318
			mediateur.supprimerStructureAPersonne(this, personnelSupprime);
311
				mediateur.supprimerStructureAPersonne(this, personnelSupprime);
319
			// Nous rechargeons la liste
312
				// Nous rechargeons la liste du Personnel
-
 
313
				rafraichirPersonnel();
320
			mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE);
314
			}
321
		}
315
		}
Line -... Line 316...
-
 
316
	}
-
 
317
	
-
 
318
	private Boolean verifierFormulaire() {
-
 
319
		ArrayList<String> messages = new ArrayList<String>();
-
 
320
		
-
 
321
		// Vérification des infos sur la structure
-
 
322
		if (	(identificationOnglet.getData("acces").equals(true) && (nomStructureChp.getValue() == null || nomStructureChp.getValue().equals(""))) || 
-
 
323
				(identificationOnglet.getData("acces").equals(false) && identification.getNom().equals(""))) {
-
 
324
			messages.add("Veuillez indiquez un nom à l'institution.");
-
 
325
		}
-
 
326
		
-
 
327
		// Vérification du Personnel
-
 
328
		if (personnelOnglet.getData("acces").equals(true)) {
-
 
329
			String personnelNumero = "";
-
 
330
			int nbrePersonne = personnelGrilleMagazin.getCount();
-
 
331
			for (int i = 0; i < nbrePersonne; i++) {
-
 
332
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
-
 
333
				if (personne.getNom().equals("") || personne.getPrenom().equals("")) {
-
 
334
					personnelNumero += (i != 0 ? ", " : "")+(i+1);
-
 
335
				}
-
 
336
			}
-
 
337
			if (!personnelNumero.equals("")) {
-
 
338
				messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero);
-
 
339
			}
-
 
340
		}
-
 
341
 
-
 
342
		// Affichage des messages d'alerte
-
 
343
		if (messages.size() != 0) {
-
 
344
			String[] a = {};
-
 
345
			a = messages.toArray(a);
-
 
346
			Window.alert(UtilArray.implode(a, "\n\n"));
-
 
347
			return false;
-
 
348
		}
-
 
349
		return true;
322
	}
350
	}
323
	
351
	
324
	private StructureValorisation collecterStructureValorisation() {
352
	private StructureValorisation collecterStructureValorisation() {
325
		if (valorisationOnglet.getData("acces").equals(false)) {
353
		if (valorisationOnglet.getData("acces").equals(false)) {
326
			return valorisation;
354
			return valorisation;
Line 381... Line 409...
381
			return valorisationModifie;
409
			return valorisationModifie;
382
		}
410
		}
383
	}
411
	}
Line 384... Line 412...
384
	
412
	
385
	private void peuplerStructureValorisation() {
413
	private void peuplerStructureValorisation() {
386
		if (valorisation != null) {
414
		if (valorisation != null && valorisationOnglet.getData("acces").equals(false)) {
387
			// ACTION
415
			// ACTION
Line 388... Line 416...
388
			actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1)).setValue(true);
416
			actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1)).setValue(true);
389
			
417
			
Line 418... Line 446...
418
			avecMotifAccesMarkRGrpChp.get((valorisation.getVisiteAvecMotif().equals("1") ? 0 : 1)).setValue(true);
446
			avecMotifAccesMarkRGrpChp.get((valorisation.getVisiteAvecMotif().equals("1") ? 0 : 1)).setValue(true);
419
			// VISITE AVEC MOTIF INFO
447
			// VISITE AVEC MOTIF INFO
420
			avecMotifAccesChp.setValue(valorisation.getVisiteAvecMotifInfo());
448
			avecMotifAccesChp.setValue(valorisation.getVisiteAvecMotifInfo());
Line 421... Line 449...
421
			
449
			
-
 
450
			valorisationOnglet.layout();
-
 
451
			
-
 
452
			// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... 
422
			valorisationOnglet.layout();
453
			valorisationOnglet.setData("acces", true);
423
		}
454
		}
Line 424... Line 455...
424
	}
455
	}
425
	
456
	
Line 517... Line 548...
517
			return conservationModifie;
548
			return conservationModifie;
518
		}
549
		}
519
	}
550
	}
Line 520... Line 551...
520
	
551
	
521
	private void peuplerStructureConservation() {
552
	private void peuplerStructureConservation() {
522
		if (conservation != null) {
553
		if (conservation != null && conservationOnglet.getData("acces").equals(false)) {
523
			// FORMATION
554
			// FORMATION
524
			// Bouton oui, à toujours l'index 0 donc on teste en fonction...
555
			// Bouton oui, à toujours l'index 0 donc on teste en fonction...
525
			formationMarkRGrpChp.get((conservation.getFormation().equals("1") ? 0 : 1)).setValue(true);
556
			formationMarkRGrpChp.get((conservation.getFormation().equals("1") ? 0 : 1)).setValue(true);
526
			// FORMATION INFO
557
			// FORMATION INFO
Line 574... Line 605...
574
			peuplerCasesACocher(conservation.getAcquisitionTraitementPoison(), poisonTraitementTrukCacGrpChp, poisonTraitementAutreChp);
605
			peuplerCasesACocher(conservation.getAcquisitionTraitementPoison(), poisonTraitementTrukCacGrpChp, poisonTraitementAutreChp);
575
			// ACQUISITION TRAITEMENT INSECTE
606
			// ACQUISITION TRAITEMENT INSECTE
576
			peuplerCasesACocher(conservation.getAcquisitionTraitementInsecte(), insecteTraitementTrukCacGrpChp, insecteTraitementAutreChp);
607
			peuplerCasesACocher(conservation.getAcquisitionTraitementInsecte(), insecteTraitementTrukCacGrpChp, insecteTraitementAutreChp);
Line 577... Line 608...
577
			
608
			
-
 
609
			conservationOnglet.layout();
-
 
610
			
-
 
611
			// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
578
			conservationOnglet.layout();
612
			conservationOnglet.setData("acces", true);
579
		}
613
		}
Line 580... Line 614...
580
	}
614
	}
581
	
615
	
Line 630... Line 664...
630
			return structure;
664
			return structure;
631
		}
665
		}
632
	}
666
	}
Line 633... Line 667...
633
	
667
	
634
	private void peuplerStructureIdentification() {
668
	private void peuplerStructureIdentification() {
635
		if (identification != null) {
669
		if (identification != null && identificationOnglet.getData("acces").equals(false)) {
636
			idStructureChp.setValue(identification.getId());
670
			idStructureChp.setValue(identification.getId());
637
			nomStructureChp.setValue(identification.getNom());
671
			nomStructureChp.setValue(identification.getNom());
638
			if (!identification.getIdAlternatif().isEmpty()) {
672
			if (!identification.getIdAlternatif().isEmpty()) {
639
				String[] acronyme = identification.getIdAlternatif().split("##");
673
				String[] acronyme = identification.getIdAlternatif().split("##");
Line 674... Line 708...
674
			urlChp.setValue(identification.getUrl("WEB"));
708
			urlChp.setValue(identification.getUrl("WEB"));
Line 675... Line 709...
675
			
709
			
Line 676... Line 710...
676
			nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne());
710
			nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne());
-
 
711
			
-
 
712
			identificationOnglet.layout();
-
 
713
			
677
			
714
			// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
678
			identificationOnglet.layout();
715
			identificationOnglet.setData("acces", true);
Line 679... Line 716...
679
		}
716
		}
680
	}
717
	}
Line 685... Line 722...
685
		valorisationOnglet.setScrollMode(Scroll.AUTO);
722
		valorisationOnglet.setScrollMode(Scroll.AUTO);
686
		valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));
723
		valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));
687
		valorisationOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur
724
		valorisationOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur
688
		valorisationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
725
		valorisationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
689
			public void handleEvent(ComponentEvent be) {
726
			public void handleEvent(ComponentEvent be) {
690
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... 
-
 
691
				valorisationOnglet.setData("acces", true);
-
 
692
				peuplerStructureValorisation();
727
				peuplerStructureValorisation();
693
			}
728
			}
694
		});
729
		});
Line 695... Line 730...
695
		
730
		
Line 762... Line 797...
762
		conservationOnglet.setText("Conservation");
797
		conservationOnglet.setText("Conservation");
763
		conservationOnglet.setScrollMode(Scroll.AUTO);
798
		conservationOnglet.setScrollMode(Scroll.AUTO);
764
		conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));
799
		conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));
765
		conservationOnglet.setData("acces", false);
800
		conservationOnglet.setData("acces", false);
766
		conservationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
801
		conservationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
767
			public void handleEvent(ComponentEvent be) {  
802
			public void handleEvent(ComponentEvent be) {
768
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
-
 
769
				conservationOnglet.setData("acces", true);
-
 
770
				peuplerStructureConservation();
803
				peuplerStructureConservation();
771
			}  
804
			}  
772
		});  
805
		});  
Line 773... Line 806...
773
		
806
		
Line 965... Line 998...
965
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
998
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
966
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
999
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
967
				String index = it.next();
1000
				String index = it.next();
Line 968... Line 1001...
968
				
1001
				
969
				// Gestion de la fonction
1002
				// Gestion de la fonction
970
				if (magazinLiFonction != null && ((String) personnel.get(index).getFonction()).matches("^[0-9]+$")) {
1003
				if (magazinLiFonction != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {
-
 
1004
					GWT.log(personnel.get(index).getFonction(), null);
971
					GWT.log(personnel.get(index).getFonction(), null);
1005
					if (magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()) != null) {
-
 
1006
						personnel.get(index).set("fonction", magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
972
					personnel.get(index).set("fonction", magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
1007
					}
973
				} else {
1008
				} else {
974
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
1009
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
Line 975... Line 1010...
975
				}
1010
				}
976
				
1011
				
Line 977... Line 1012...
977
				// Gestion de la notion de "contact"
1012
				// Gestion de la notion de "contact"
978
				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
1013
				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
979
				
-
 
980
				// Gestion du statut
1014
				
981
				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
1015
				// Gestion du statut
982
					GWT.log(personnel.get(index).getStatut(), null);
1016
				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
983
					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
1017
					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
Line 1009... Line 1043...
1009
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
1043
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
1010
			public void handleEvent(ComponentEvent be) {
1044
			public void handleEvent(ComponentEvent be) {
1011
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
1045
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
1012
				personnelOnglet.setData("acces", true);
1046
				personnelOnglet.setData("acces", true);
Line 1013... Line -...
1013
				
-
 
1014
				// Création des objets de la grille
-
 
1015
				personnelModifie = new StructureAPersonneListe();
-
 
1016
				personnelAjoute = new StructureAPersonneListe();
-
 
1017
				personnelSupprime = new StructureAPersonneListe();
-
 
1018
				
1047
				
1019
				// Peuplement du formulaire
1048
				// Peuplement du formulaire
1020
				peuplerStructurePersonnel();
1049
				peuplerStructurePersonnel();
Line 1021... Line 1050...
1021
			}
1050
			}
Line 1058... Line 1087...
1058
		
1087
		
1059
		CellEditor fonctionEditor = new CellEditor(comboLiFonction) {  
1088
		CellEditor fonctionEditor = new CellEditor(comboLiFonction) {  
1060
			@Override  
1089
			@Override  
1061
			public Object preProcessValue(Object valeur) {  
1090
			public Object preProcessValue(Object valeur) {  
1062
				if (valeur == null) {
1091
				if (valeur == null) {
1063
					GWT.log("pre null :"+this.getValue()+"-"+this.row, null);
1092
					//GWT.log("pre null :"+this.getValue()+"-"+this.row, null);
1064
					return null;
1093
					return null;
1065
				}
1094
				}
1066
				GWT.log("pre : "+valeur.toString(), null);
1095
				//GWT.log("pre : "+valeur.toString(), null);
1067
				Object retour = null;
1096
				Object retour = null;
1068
				if (((String) valeur).matches("^[0-9]+$")) {
1097
				if (((String) valeur).matches("^[0-9]+$")) {
1069
					Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) valeur);
1098
					Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) valeur);
1070
					if (valeurRecherche != null) {
1099
					if (valeurRecherche != null) {
1071
						retour = valeurRecherche;
1100
						retour = valeurRecherche;
1072
						GWT.log("pre - retour valeur par chiffre : \n"+retour.toString(), null);
1101
						//GWT.log("pre - retour valeur par chiffre : \n"+retour.toString(), null);
1073
					} else {
1102
					} else {
1074
						this.getField().setRawValue((String) valeur);
1103
						this.getField().setRawValue((String) valeur);
1075
						retour = null;
1104
						retour = null;
1076
					}
1105
					}
1077
				} else if (valeur instanceof String) {
1106
				} else if (valeur instanceof String) {
1078
					this.getField().setRawValue((String) valeur);
1107
					this.getField().setRawValue((String) valeur);
1079
					retour = new Valeur("", (String) valeur, "", "");
1108
					retour = new Valeur("", (String) valeur, "", "");
1080
				} else {
1109
				} else {
1081
					retour = comboLiFonction.getStore().findModel("nom", (String) valeur);
1110
					retour = comboLiFonction.getStore().findModel("nom", (String) valeur);
1082
					GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null);
1111
					//GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null);
Line 1083... Line 1112...
1083
				}
1112
				}
1084
				
1113
				
Line 1085... Line 1114...
1085
				return retour;
1114
				return retour;
1086
			}  
1115
			}  
1087
			
1116
			
1088
			@Override  
1117
			@Override  
1089
			public Object postProcessValue(Object valeur) {  
1118
			public Object postProcessValue(Object valeur) {  
1090
				if (valeur == null) {
1119
				if (valeur == null) {
1091
					// Si la combobox n'a pas été utilisé, nous renvoyons la valeur brute saisie par l'utilisateur
1120
					// Si la combobox n'a pas été utilisé, nous renvoyons la valeur brute saisie par l'utilisateur
1092
					GWT.log("post raw : \n"+this.getField().getRawValue(), null);
1121
					//GWT.log("post raw : \n"+this.getField().getRawValue(), null);
1093
					String retour = this.getField().getRawValue();
1122
					String retour = this.getField().getRawValue();
1094
					if (retour.matches("^[0-9]+$")) {
1123
					if (retour.matches("^[0-9]+$")) {
1095
						GWT.log("ici", null);
1124
						//GWT.log("ici", null);
1096
						Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) retour);
1125
						Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) retour);
1097
						if (valeurRecherche != null) {
1126
						if (valeurRecherche != null) {
1098
							retour = valeurRecherche.getNom();
1127
							retour = valeurRecherche.getNom();
1099
						}
1128
						}
1100
					}
1129
					}
1101
					return retour;
1130
					return retour;
1102
				} else {
1131
				} else {
1103
					GWT.log("post : \n"+valeur.toString(), null);
1132
					//GWT.log("post : \n"+valeur.toString(), null);
1104
					String nom = "";
1133
					String nom = "";
1105
					if (valeur instanceof Valeur) {
1134
					if (valeur instanceof Valeur) {
Line 1106... Line 1135...
1106
						nom = (((Valeur) valeur).getNom());
1135
						nom = (((Valeur) valeur).getNom());
1107
						GWT.log("la "+nom, null);
1136
						//GWT.log("la "+nom, null);
1108
					}
1137
					}
1109
					
1138
					
1110
					return nom;
1139
					return nom;
1111
				}
1140
				}
Line 1112... Line 1141...
1112
			}
1141
			}
1113
		};
-
 
1114
		column.setEditor(fonctionEditor);
-
 
1115
		configs.add(column);
-
 
1116
		
1142
		};
1117
		column = new ColumnConfig();  
1143
		column.setEditor(fonctionEditor);
1118
		column.setId("prenom");  
1144
		configs.add(column);
1119
		column.setHeader("Prénom");
1145
		
1120
		column.setWidth(100);
1146
		column = new ColumnConfig("prenom", "Prénom", 100);  
1121
		TextField<String> prenomChp = new TextField<String>();  
1147
		TextField<String> prenomChp = new TextField<String>();  
Line 1122... Line 1148...
1122
		prenomChp.setAllowBlank(false);
1148
		prenomChp.setAllowBlank(false);
1123
		prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");
-
 
1124
		prenomChp.setAutoValidate(true);  
-
 
1125
		column.setEditor(new CellEditor(prenomChp));
-
 
1126
		configs.add(column);  
1149
		prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");
1127
		
1150
		prenomChp.setAutoValidate(true);  
1128
		column = new ColumnConfig();  
1151
		column.setEditor(new CellEditor(prenomChp));
1129
		column.setId("nom");
1152
		configs.add(column);  
1130
		column.setHeader("Nom");
1153
		
Line 1219... Line 1242...
1219
					ce.component.enable();  
1242
					ce.component.enable();  
1220
				}
1243
				}
1221
			}  
1244
			}  
1222
		});
1245
		});
1223
		toolBar.add(ajouterPersonnelBtn);
1246
		toolBar.add(ajouterPersonnelBtn);
-
 
1247
		
1224
		toolBar.add(new SeparatorToolItem());
1248
		toolBar.add(new SeparatorToolItem());
-
 
1249
		
1225
		TextToolItem supprimerPersonnelBtn = new TextToolItem("Supprimer", "icone-vcard-supprimer");
1250
		TextToolItem supprimerPersonnelBtn = new TextToolItem("Supprimer", "icone-vcard-supprimer");
1226
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
1251
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
1227
			@Override
1252
			@Override
1228
			public void componentSelected(ToolBarEvent ce) {
1253
			public void componentSelected(ToolBarEvent ce) {
1229
				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
1254
				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
1230
				if (personne != null) {
1255
				if (personne != null) {
1231
					// Ajout de la personne supprimée à la liste
1256
					// Ajout de la personne supprimée à la liste
1232
					if (personne.getIdPersonne() != null) {
1257
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
1233
						personnelSupprime.put(personne.getId(), personne);
1258
						personnelSupprime.put(personne.getId(), personne);
1234
					}
1259
					}
Line 1235... Line 1260...
1235
	
1260
	
1236
					// Suppression de l'enregistrement de la grille
1261
					// Suppression de l'enregistrement de la grille
Line 1241... Line 1266...
1241
						ce.item.disable();  
1266
						ce.item.disable();  
1242
					}
1267
					}
1243
				}
1268
				}
1244
			}   
1269
			}   
1245
		});
1270
		});
1246
		toolBar.add(supprimerPersonnelBtn);  
1271
		toolBar.add(supprimerPersonnelBtn);
-
 
1272
		
-
 
1273
		toolBar.add(new SeparatorToolItem());
-
 
1274
		
-
 
1275
		TextToolItem rafraichirPersonnelBtn = new TextToolItem("Rafraichir", "icone-rafraichir");
-
 
1276
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
-
 
1277
			@Override
-
 
1278
			public void componentSelected(ToolBarEvent ce) {
-
 
1279
				rafraichirPersonnel();
-
 
1280
			}   
-
 
1281
		});
-
 
1282
		toolBar.add(rafraichirPersonnelBtn);
-
 
1283
		
-
 
1284
		toolBar.add(new SeparatorToolItem());
-
 
1285
		
-
 
1286
		personneExistanteMagazin = new ListStore<Personne>();
-
 
1287
		personneExistanteMagazin.add(new ArrayList<Personne>());
-
 
1288
		
-
 
1289
		personneExistanteCombo = new ComboBox<Personne>();  
-
 
1290
		personneExistanteCombo.setWidth(200);
-
 
1291
		personneExistanteCombo.setEmptyText("Chercher une personne existante...");
-
 
1292
		personneExistanteCombo.setTriggerAction(TriggerAction.ALL);  
-
 
1293
		personneExistanteCombo.setEditable(true);
-
 
1294
		personneExistanteCombo.setDisplayField("fmt_nom_complet");
-
 
1295
		personneExistanteCombo.setStore(personneExistanteMagazin);
-
 
1296
		personneExistanteCombo.addKeyListener(new KeyListener() {
-
 
1297
			
-
 
1298
			public void componentKeyUp(ComponentEvent ce) {
-
 
1299
				if (!ce.isNavKeyPress() && personneExistanteCombo.getRawValue() != null && personneExistanteCombo.getRawValue().length() > 0) {
-
 
1300
					rafraichirPersonneExistante(personneExistanteCombo.getRawValue());
-
 
1301
				}
-
 
1302
			}
-
 
1303
			
-
 
1304
		});
-
 
1305
 
-
 
1306
		// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar
-
 
1307
		toolBar.add(new AdapterToolItem(personneExistanteCombo));
-
 
1308
		
-
 
1309
		TextToolItem ajouterPersonneExistanteBtn = new TextToolItem("Ajouter");
-
 
1310
		ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
-
 
1311
			@Override  
-
 
1312
			public void componentSelected(ToolBarEvent ce) {  
-
 
1313
				Personne personneExistante = personneExistanteCombo.getValue();
-
 
1314
				
-
 
1315
				StructureAPersonne personne = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE);
-
 
1316
				personne.setIdPersonne(personneExistante.getId());
-
 
1317
				personne.setPrenom(personneExistante.getPrenom());
-
 
1318
				personne.setNom(personneExistante.getNom());
-
 
1319
				
-
 
1320
				grillePersonnel.stopEditing();
-
 
1321
				int numNouveau = grillePersonnel.getData("nouveau");
-
 
1322
				grillePersonnel.setData("nouveau", ++numNouveau);
-
 
1323
				personnelGrilleMagazin.insert(personne, 0);  
-
 
1324
				grillePersonnel.startEditing(0, 0);
-
 
1325
 
-
 
1326
				// Activation du bouton supprimer si la grille contient un élément
-
 
1327
				if (grillePersonnel.getStore().getCount() > 0) {  
-
 
1328
					ce.component.enable();  
-
 
1329
				}
-
 
1330
			}  
-
 
1331
		});
-
 
1332
		toolBar.add(ajouterPersonneExistanteBtn);
-
 
1333
		
1247
		cp.setTopComponent(toolBar);  
1334
		cp.setTopComponent(toolBar);  
Line 1248... Line 1335...
1248
 
1335
 
Line 1249... Line 1336...
1249
		ColumnModel cm = new ColumnModel(configs);
1336
		ColumnModel cm = new ColumnModel(configs);
Line 1282... Line 1369...
1282
		identificationOnglet.setText("Identification");
1369
		identificationOnglet.setText("Identification");
1283
		identificationOnglet.setLayout(new FormLayout());
1370
		identificationOnglet.setLayout(new FormLayout());
1284
		identificationOnglet.setData("acces", false);
1371
		identificationOnglet.setData("acces", false);
1285
		identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
1372
		identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
1286
			public void handleEvent(ComponentEvent be) {  
1373
			public void handleEvent(ComponentEvent be) {  
1287
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
-
 
1288
				identificationOnglet.setData("acces", true);
-
 
1289
				peuplerStructureIdentification();
1374
				peuplerStructureIdentification();
1290
			}  
1375
			}  
1291
		});
1376
		});
Line 1292... Line 1377...
1292
		
1377
		
Line 1847... Line 1932...
1847
					}
1932
					}
1848
					structureFormPanneau.setHeading(titre);
1933
					structureFormPanneau.setHeading(titre);
1849
				} else if (info.getType().equals("liste_structure_a_personne")) {
1934
				} else if (info.getType().equals("liste_structure_a_personne")) {
1850
					if (info.getDonnee(0) != null) {
1935
					if (info.getDonnee(0) != null) {
1851
						personnel = (StructureAPersonneListe) info.getDonnee(0);
1936
						personnel = (StructureAPersonneListe) info.getDonnee(0);
1852
						
1937
 
-
 
1938
						// Création des objets contenant les manipulations de la grille
-
 
1939
						personnelModifie = new StructureAPersonneListe();
-
 
1940
						personnelAjoute = new StructureAPersonneListe();
-
 
1941
						personnelSupprime = new StructureAPersonneListe();
-
 
1942
 
1853
						//GWT.log(personnel.toString(), null);
1943
						//GWT.log(personnel.toString(), null);
1854
						if (onglets.getSelectedItem().equals(personnelOnglet)) {
1944
						if (onglets.getSelectedItem().equals(personnelOnglet)) {
1855
							peuplerStructurePersonnel();
1945
							peuplerStructurePersonnel();
1856
							Info.display("Peuplement", "ok");
1946
							Info.display("Chargement du Personnel", "ok");
1857
						}
1947
						}
1858
					}
1948
					}
1859
					if (info.getDonnee(1) != null) {
1949
					if (info.getDonnee(1) != null) {
1860
						Info.display("Debug", info.getDonnee(1).toString());
1950
						Info.display("Debug", info.getDonnee(1).toString());
1861
					}
1951
					}
-
 
1952
				} else if (info.getType().equals("liste_personne")) {
-
 
1953
					if (info.getDonnee(0) != null) {
-
 
1954
						PersonneListe personnes = (PersonneListe) info.getDonnee(0);
-
 
1955
						
-
 
1956
						List<Personne> liste = new ArrayList<Personne>();
-
 
1957
						for (Iterator<String> it = personnes.keySet().iterator(); it.hasNext();) {
-
 
1958
							liste.add(personnes.get(it.next()));
-
 
1959
						}
-
 
1960
						
-
 
1961
						GWT.log("Nbre de personnes trouvées :"+personnes.size(), null);
-
 
1962
						personneExistanteMagazin.removeAll();
-
 
1963
						personneExistanteMagazin.add(liste);
-
 
1964
						personneExistanteCombo.setStore(personneExistanteMagazin);
-
 
1965
						personneExistanteCombo.expand();
-
 
1966
					}
1862
				}
1967
				}
1863
			} else if (nouvelleDonnees instanceof ValeurListe) {
1968
			} else if (nouvelleDonnees instanceof ValeurListe) {
1864
				ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;
1969
				ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;
Line 1865... Line 1970...
1865
				
1970
				
Line 1967... Line 2072...
1967
			}
2072
			}
1968
		} catch (Exception e) {
2073
		} catch (Exception e) {
1969
			GWT.log("rafraichir()", e);
2074
			GWT.log("rafraichir()", e);
1970
		}
2075
		}
1971
	}
2076
	}
1972
	 
2077
	
-
 
2078
	private void rafraichirPersonnel() {
-
 
2079
		mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE);
-
 
2080
	}
-
 
2081
	
-
 
2082
	private void rafraichirPersonneExistante(String nom) {
-
 
2083
		mediateur.selectionnerPersonneParNomComplet(this, null, nom); 
-
 
2084
	}
1973
}
2085
}
1974
2086