Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 981 Rev 991
Line 14... Line 14...
14
import org.tela_botanica.client.composants.ChampMultiValeurs;
14
import org.tela_botanica.client.composants.ChampMultiValeurs;
15
import org.tela_botanica.client.composants.ChampMultiValeursImage;
15
import org.tela_botanica.client.composants.ChampMultiValeursImage;
16
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
16
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
17
import org.tela_botanica.client.composants.HashMapComposants;
17
import org.tela_botanica.client.composants.HashMapComposants;
18
import org.tela_botanica.client.configuration.Configuration;
18
import org.tela_botanica.client.configuration.Configuration;
-
 
19
import org.tela_botanica.client.images.Images;
19
import org.tela_botanica.client.interfaces.Rafraichissable;
20
import org.tela_botanica.client.interfaces.Rafraichissable;
Line 20... Line 21...
20
 
21
 
21
import org.tela_botanica.client.modeles.Information;
22
import org.tela_botanica.client.modeles.Information;
22
import org.tela_botanica.client.modeles.MenuApplicationId;
23
import org.tela_botanica.client.modeles.MenuApplicationId;
23
import org.tela_botanica.client.modeles.Valeur;
24
import org.tela_botanica.client.modeles.Valeur;
24
import org.tela_botanica.client.modeles.ValeurListe;
25
import org.tela_botanica.client.modeles.ValeurListe;
25
import org.tela_botanica.client.modeles.personne.Personne;
26
import org.tela_botanica.client.modeles.personne.Personne;
26
import org.tela_botanica.client.modeles.personne.PersonneListe;
27
import org.tela_botanica.client.modeles.personne.PersonneListe;
27
import org.tela_botanica.client.modeles.projet.Projet;
28
import org.tela_botanica.client.modeles.projet.Projet;
-
 
29
import org.tela_botanica.client.modeles.projet.ProjetListe;
-
 
30
import org.tela_botanica.client.modeles.publication.Publication;
-
 
31
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
-
 
32
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
28
import org.tela_botanica.client.modeles.projet.ProjetListe;
33
import org.tela_botanica.client.modeles.publication.PublicationListe;
29
import org.tela_botanica.client.util.Pattern;
34
import org.tela_botanica.client.util.Pattern;
30
import org.tela_botanica.client.util.UtilString;
35
import org.tela_botanica.client.util.UtilString;
Line 31... Line 36...
31
import org.tela_botanica.client.vues.Formulaire;
36
import org.tela_botanica.client.vues.Formulaire;
Line 46... Line 51...
46
import com.extjs.gxt.ui.client.event.SelectionListener;
51
import com.extjs.gxt.ui.client.event.SelectionListener;
47
import com.extjs.gxt.ui.client.store.ListStore;
52
import com.extjs.gxt.ui.client.store.ListStore;
48
import com.extjs.gxt.ui.client.widget.LayoutContainer;
53
import com.extjs.gxt.ui.client.widget.LayoutContainer;
49
import com.extjs.gxt.ui.client.widget.MessageBox;
54
import com.extjs.gxt.ui.client.widget.MessageBox;
Line -... Line 55...
-
 
55
 
50
 
56
import com.extjs.gxt.ui.client.widget.ContentPanel;
51
import com.extjs.gxt.ui.client.widget.Info;
57
import com.extjs.gxt.ui.client.widget.Info;
52
import com.extjs.gxt.ui.client.widget.TabItem;
58
import com.extjs.gxt.ui.client.widget.TabItem;
53
import com.extjs.gxt.ui.client.widget.TabPanel;
59
import com.extjs.gxt.ui.client.widget.TabPanel;
Line 65... Line 71...
65
import com.extjs.gxt.ui.client.widget.form.TextField;
71
import com.extjs.gxt.ui.client.widget.form.TextField;
66
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
72
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
67
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
73
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
68
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
74
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
69
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
75
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
-
 
76
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
70
import com.extjs.gxt.ui.client.widget.layout.FormData;
77
import com.extjs.gxt.ui.client.widget.layout.FormData;
71
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
78
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
72
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
79
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
73
import com.extjs.gxt.ui.client.widget.layout.TableData;
80
import com.extjs.gxt.ui.client.widget.layout.TableData;
74
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
81
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
-
 
82
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
-
 
83
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
75
import com.google.gwt.core.client.GWT;
84
import com.google.gwt.core.client.GWT;
76
import com.google.gwt.i18n.client.DateTimeFormat;
85
import com.google.gwt.i18n.client.DateTimeFormat;
-
 
86
import com.google.gwt.user.client.Window;
77
import com.google.gwt.user.client.ui.Widget;
87
import com.google.gwt.user.client.ui.Widget;
Line 78... Line 88...
78
 
88
 
Line 79... Line 89...
79
public class PersonneForm extends Formulaire implements Rafraichissable {
89
public class PersonneForm extends Formulaire implements Rafraichissable {
80
 
90
 
-
 
91
	// VARIABLES
81
	// VARIABLES
92
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
82
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
93
	PersonneFormPublication tiPubli;
Line 83... Line 94...
83
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
94
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
84
	private Personne personneSelectionnee, personneSauvegarde = null;
95
	protected Personne personneSelectionnee, personneSauvegarde = null;
85
	
96
	
86
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
97
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
Line 94... Line 105...
94
	
105
	
95
	private Personne personne = null;
106
	private Personne personne = null;
96
	private String personneId = null;
107
	private String personneId = null;
Line -... Line 108...
-
 
108
	private FormBinding binding = null;
-
 
109
	
-
 
110
	//Publi
-
 
111
	private ComboBox<Publication> cbPubli;
97
	private FormBinding binding = null;
112
	private ListStore<Publication> storePubli;
98
	
113
	
99
	// CONSTRUCTEUR 
114
	// CONSTRUCTEUR  
100
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
115
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
Line 101... Line 116...
101
		initialiserPersonneForm(mediateurCourrant, personneId);
116
		initialiserPersonneForm(mediateurCourrant, personneId);
Line 117... Line 132...
117
		initialiserComposants();
132
		initialiserComposants();
118
		genererTitreFormulaire();
133
		genererTitreFormulaire();
Line 119... Line 134...
119
		
134
		
120
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
135
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
-
 
136
			mediateur.selectionnerPersonne(this, personne, null);
121
			mediateur.selectionnerPersonne(this, personne, null);
137
			mediateurCourrant.selectionnerPublicationAPersonne(this, null, personne.getId(), PublicationAPersonne.ROLE_SUJET);
122
		}
138
		}
Line 123... Line 139...
123
	}
139
	}
124
	
140
	
Line 137... Line 153...
137
		initialiserOnglets();	
153
		initialiserOnglets();	
Line 138... Line 154...
138
		
154
		
139
		creerComposantsIdentite();
155
		creerComposantsIdentite();
140
		creerComposantsAdresse();
156
		creerComposantsAdresse();
-
 
157
		creerComposantsInfosNat();
Line 141... Line 158...
141
		creerComposantsInfosNat();
158
		//creerComposantsPubli();
142
		
159
		
Line 143... Line 160...
143
		binderPersonne(personneSelectionnee);
160
		binderPersonne(personneSelectionnee);
Line 150... Line 167...
150
	public void initialiserOnglets()	{
167
	public void initialiserOnglets()	{
151
		//TabPanel
168
		//TabPanel
152
		TabPanel formulaireOnglets = new TabPanel();
169
		TabPanel formulaireOnglets = new TabPanel();
Line 153... Line 170...
153
		
170
		
154
		//Tab 1 : identite
171
		//Tab 1 : identite
155
		tiIdentite = new TabItem(i18nC.personneIdentite());
172
		tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite");
156
		tiIdentite.setLayout(new FormLayout());
-
 
157
		tiIdentite.setScrollMode(Scroll.AUTO);
-
 
158
		
173
		tiIdentite.setStyleAttribute("padding", "0");
159
		formulaireOnglets.add(tiIdentite);
-
 
Line 160... Line 174...
160
		hmIdentite.put("tiIdentite", tiIdentite);
174
		formulaireOnglets.add(tiIdentite);
161
		
175
		
162
		//Tab 2 : Adresse
-
 
163
		tiAdresses = new TabItem(i18nC.adresse());
-
 
164
		tiAdresses.setLayout(new FormLayout());
176
		//Tab 2 : Adresse
Line 165... Line 177...
165
		tiAdresses.setScrollMode(Scroll.AUTO);
177
		tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses");
166
		formulaireOnglets.add(tiAdresses);
178
		formulaireOnglets.add(tiAdresses);
167
		
-
 
168
		//Tab 3 : Infos Naturalistes
-
 
169
		tiInfosNat = new TabItem(i18nC.personneInfoNat());
-
 
170
		tiInfosNat.setLayout(new FormLayout());
179
		
-
 
180
		//Tab 3 : Infos Naturalistes
-
 
181
		tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat");
-
 
182
		formulaireOnglets.add(tiInfosNat);
-
 
183
		
171
		tiInfosNat.setScrollMode(Scroll.AUTO);
184
		tiPubli = new PersonneFormPublication(this);
172
		
185
		formulaireOnglets.add(tiPubli);
Line 173... Line 186...
173
		formulaireOnglets.add(tiInfosNat);
186
	
174
		getFormulaire().add(formulaireOnglets);
187
		getFormulaire().add(formulaireOnglets);
Line 624... Line 637...
624
		hmInfosNat.put("recolte", recolte);
637
		hmInfosNat.put("recolte", recolte);
625
		fsInfosNat.add(recolte);
638
		fsInfosNat.add(recolte);
626
		tiInfosNat.add(fsInfosNat);
639
		tiInfosNat.add(fsInfosNat);
627
	}
640
	}
Line -... Line 641...
-
 
641
	
-
 
642
	public void creerComposantsPubli(){
-
 
643
		//Création des composants de l'onglet publication
-
 
644
 
-
 
645
		ContentPanel cp = new ContentPanel();
-
 
646
		cp.setHeading("Publications dont la personne est le sujet");
-
 
647
		cp.setIcon(Images.ICONES.table());
-
 
648
		cp.setLayout(new FitLayout());
-
 
649
		cp.setFrame(true);
-
 
650
		
-
 
651
		ToolBar toolBar = new ToolBar();
-
 
652
 
-
 
653
		Button ajouterPubli = new Button("Ajouter");
-
 
654
		ajouterPubli.setIcon(Images.ICONES.vcardAjouter());
-
 
655
		ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
656
			@Override  
-
 
657
			public void componentSelected(ButtonEvent ce) {  
-
 
658
				Window.alert("ajout publi");
-
 
659
				/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
-
 
660
				ajouterMembreAGrillePersonnel(membreDuPersonnel);*/
-
 
661
			}  
-
 
662
		});
-
 
663
		toolBar.add(ajouterPubli);
-
 
664
		
-
 
665
		toolBar.add(new SeparatorToolItem());
-
 
666
		
-
 
667
		Button supprimerPubli = new Button("Supprimer");
-
 
668
		supprimerPubli.setIcon(Images.ICONES.vcardSupprimer());
-
 
669
		supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
670
			@Override
-
 
671
			public void componentSelected(ButtonEvent ce) {
-
 
672
				/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
-
 
673
				if (personne != null) {
-
 
674
					// Ajout de la personne supprimée à la liste
-
 
675
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
-
 
676
						personnelSupprime.put(personne.getId(), personne);
-
 
677
					}
-
 
678
	
-
 
679
					// Suppression de l'enregistrement de la grille
-
 
680
					grillePersonnel.getStore().remove(personne);
-
 
681
					
-
 
682
					// Désactivation du bouton supprimer si la grille contient plus d'élément
-
 
683
					if (grillePersonnel.getStore().getCount() == 0) {  
-
 
684
						//TODO : check : Item -> component
-
 
685
						ce.getComponent().disable();  
-
 
686
					}
-
 
687
				}*/
-
 
688
				Window.alert("supprimer");
-
 
689
			}   
-
 
690
		});
-
 
691
		toolBar.add(supprimerPubli);
-
 
692
		
-
 
693
		toolBar.add(new SeparatorToolItem());
-
 
694
		
-
 
695
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
-
 
696
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
-
 
697
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
698
			@Override
-
 
699
			public void componentSelected(ButtonEvent ce) {
-
 
700
				//rafraichirPersonnel();
-
 
701
				Window.alert("rafraichir");
-
 
702
			}   
-
 
703
		});
-
 
704
		toolBar.add(rafraichirPersonnelBtn);
-
 
705
		
-
 
706
		//Ajout d'une ComboBox
-
 
707
		storePubli = new ListStore<Publication>();
-
 
708
		storePubli.add(new ArrayList<Publication>());
-
 
709
		
-
 
710
		cbPubli = new ComboBox<Publication>();
-
 
711
		cbPubli.setWidth(200);
-
 
712
		cbPubli.setEmptyText("Chercher une publication existante...");
-
 
713
		cbPubli.setTriggerAction(TriggerAction.ALL);  
-
 
714
		cbPubli.setEditable(true);
-
 
715
		cbPubli.setDisplayField("fmt_nom_complet");
-
 
716
		cbPubli.setStore(storePubli);
-
 
717
		cbPubli.addKeyListener(new KeyListener() {
-
 
718
			
-
 
719
			public void componentKeyUp(ComponentEvent ce) {
-
 
720
				if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) {
-
 
721
					rafraichirPublicationsExistante(cbPubli.getRawValue());
-
 
722
				}
-
 
723
			}
-
 
724
			
-
 
725
		});
-
 
726
		
-
 
727
		toolBar.add(cbPubli);
-
 
728
		toolBar.add(new SeparatorToolItem());
-
 
729
		cp.setTopComponent(toolBar);  
-
 
730
		
-
 
731
		
-
 
732
		tiPubli.add(cp);
-
 
733
	}
-
 
734
 
-
 
735
	public void rafraichirPublicationsExistante(String nomPubli)	{
-
 
736
		nomPubli +="%";
-
 
737
		mediateur.selectionnerPublicationParNomComplet(this, null, nomPubli);
-
 
738
	}
628
	
739
	
629
	/**
740
	/**
630
	 * Ajouter le bouton annuler à la barre d'outils donnée
741
	 * Ajouter le bouton annuler à la barre d'outils donnée
631
	 * 
742
	 * 
632
	 * @param barreOutils la barre d'outils à modifier
743
	 * @param barreOutils la barre d'outils à modifier
Line 649... Line 760...
649
	}
760
	}
Line 650... Line 761...
650
	
761
	
Line 651... Line 762...
651
	// RAFRAICHISSEMENT DU PANNEAU
762
	// RAFRAICHISSEMENT DU PANNEAU
-
 
763
 
-
 
764
	public void rafraichir(Object nouvellesDonnees) {
-
 
765
		if (nouvellesDonnees instanceof PublicationAPersonneListe)	{
-
 
766
			Information info = new Information();
-
 
767
			info.setType("publication_liees");
652
 
768
			info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees);
653
	public void rafraichir(Object nouvellesDonnees) {
769
			tiPubli.rafraichir(info);
Line 654... Line 770...
654
		if (nouvellesDonnees instanceof ValeurListe) {
770
		} else if (nouvellesDonnees instanceof ValeurListe) {
655
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
771
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
656
			
772
			
Line 686... Line 802...
686
			ComboBox cbProjets = hmIdentite.getComboBox("cbProjets");
802
			ComboBox cbProjets = hmIdentite.getComboBox("cbProjets");
687
			ListStore<Projet> storeProjets= cbProjets.getStore();
803
			ListStore<Projet> storeProjets= cbProjets.getStore();
688
			storeProjets.removeAll();
804
			storeProjets.removeAll();
689
			storeProjets.add(liste);
805
			storeProjets.add(liste);
690
			cbProjets.setStore(storeProjets);
806
			cbProjets.setStore(storeProjets);
-
 
807
		} else if (nouvellesDonnees instanceof PublicationListe)	{
-
 
808
			
-
 
809
			PublicationListe publicationListe = (PublicationListe) nouvellesDonnees;
-
 
810
			List<Publication> liste = publicationListe.toList();
-
 
811
			storePubli.removeAll();
-
 
812
			storePubli.add(liste);
-
 
813
			cbPubli.setStore(storePubli);
-
 
814
			
691
		} else if (nouvellesDonnees instanceof Information)	{
815
		} else if (nouvellesDonnees instanceof Information)	{
692
			Information info = (Information) nouvellesDonnees;
816
			Information info = (Information) nouvellesDonnees;
693
			if (info.getType().equals("ajout_personne"))	{
817
			if (info.getType().equals("ajout_personne"))	{
694
				if (info.getDonnee(0) != null) {
818
				if (info.getDonnee(0) != null) {
695
					personneSelectionnee.setId(info.getDonnee(0).toString());
819
					personneSelectionnee.setId(info.getDonnee(0).toString());
Line 714... Line 838...
714
				
838
				
715
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
839
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
716
				Iterator itPersonneListe = colPersonneListe.iterator();
840
				Iterator itPersonneListe = colPersonneListe.iterator();
Line -... Line 841...
-
 
841
				Personne personne = (Personne) itPersonneListe.next();
717
				Personne personne = (Personne) itPersonneListe.next();
842
				
718
				
843
				//TODO : Je vois pas l'intérêt des lignes ci dessous..
Line 719... Line 844...
719
				personneSauvegarde = new Personne();
844
				personneSauvegarde = new Personne();
Line 912... Line 1037...
912
		 * -----------------------------------------------------*/
1037
		 * -----------------------------------------------------*/
Line 913... Line 1038...
913
		
1038
		
914
		hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
1039
		hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
915
		String tr = personne.getString("truk_recolte");
1040
		String tr = personne.getString("truk_recolte");
916
		hmInfosNat.getChampMultiValeursMultiTypes("recolte").peupler(tr);
1041
		hmInfosNat.getChampMultiValeursMultiTypes("recolte").peupler(tr);
-
 
1042
		
-
 
1043
		//Onglet publi
917
		 
1044
		tiPubli.mettreAJourPersonne();
918
		gererEtatActivationBouton();
1045
		gererEtatActivationBouton();
Line 919... Line 1046...
919
	}
1046
	}
920
 
1047
 
Line 977... Line 1104...
977
		return strValeur;
1104
		return strValeur;
978
	}
1105
	}
Line 979... Line 1106...
979
 
1106
 
980
	public boolean soumettreFormulaire() {
1107
	public boolean soumettreFormulaire() {
-
 
1108
		if (verifierFormulaire())	{
-
 
1109
			tiPubli.collecter();
981
		if (verifierFormulaire())	{
1110
			tiPubli.soumettre();
982
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1111
			mediateur.enregistrerPersonne(this, personneSelectionnee);
983
		}
1112
		}
984
		return true;
1113
		return true;