Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 973 Rev 976
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;
-
 
20
import org.tela_botanica.client.interfaces.Rafraichissable;
19
import org.tela_botanica.client.interfaces.Rafraichissable;
Line 21... Line 20...
21
 
20
 
22
import org.tela_botanica.client.modeles.Information;
21
import org.tela_botanica.client.modeles.Information;
23
import org.tela_botanica.client.modeles.MenuApplicationId;
22
import org.tela_botanica.client.modeles.MenuApplicationId;
Line 31... Line 30...
31
import org.tela_botanica.client.util.UtilString;
30
import org.tela_botanica.client.util.UtilString;
32
import org.tela_botanica.client.vues.Formulaire;
31
import org.tela_botanica.client.vues.Formulaire;
Line 33... Line 32...
33
 
32
 
34
import com.extjs.gxt.ui.client.event.Events;
33
import com.extjs.gxt.ui.client.event.Events;
35
import com.extjs.gxt.ui.client.Registry;
-
 
36
import com.extjs.gxt.ui.client.Style.IconAlign;
34
import com.extjs.gxt.ui.client.Registry;
37
import com.extjs.gxt.ui.client.Style.Scroll;
35
import com.extjs.gxt.ui.client.Style.Scroll;
Line 38... Line -...
38
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
-
 
39
 
36
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
Line 40... Line 37...
40
import com.extjs.gxt.ui.client.binding.FieldBinding;
37
 
41
import com.extjs.gxt.ui.client.binding.FormBinding;
38
import com.extjs.gxt.ui.client.binding.FormBinding;
42
 
39
 
Line 75... Line 72...
75
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
72
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
76
import com.extjs.gxt.ui.client.widget.layout.TableData;
73
import com.extjs.gxt.ui.client.widget.layout.TableData;
77
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
74
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
78
import com.google.gwt.core.client.GWT;
75
import com.google.gwt.core.client.GWT;
79
import com.google.gwt.i18n.client.DateTimeFormat;
76
import com.google.gwt.i18n.client.DateTimeFormat;
80
import com.google.gwt.user.client.Window;
-
 
81
import com.google.gwt.user.client.ui.Widget;
77
import com.google.gwt.user.client.ui.Widget;
Line 82... Line 78...
82
 
78
 
Line 83... Line 79...
83
public class PersonneForm extends Formulaire implements Rafraichissable {
79
public class PersonneForm extends Formulaire implements Rafraichissable {
Line 87... Line 83...
87
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
83
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
88
	private Personne personneSelectionnee, personneSauvegarde = null;
84
	private Personne personneSelectionnee, personneSauvegarde = null;
Line 89... Line 85...
89
	
85
	
90
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
86
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
91
	private HashMapComposants hmIdentite = new HashMapComposants();
87
	private HashMapComposants hmIdentite = new HashMapComposants();
92
	private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
88
	private HashMapComposants hmAdresse = new HashMapComposants();
93
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
89
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
94
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
90
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
Line 95... Line 91...
95
	private FormData fd100 = new FormData("95%");
91
	private FormData fd100 = new FormData("95%");
Line 607... Line 603...
607
		
603
		
608
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
604
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
609
		fsInfosNat.add(specialite);
605
		fsInfosNat.add(specialite);
Line 610... Line 606...
610
		hmInfosNat.put("specialite", specialite);
606
		hmInfosNat.put("specialite", specialite);
-
 
607
		
611
		
608
		ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte(), 200, 200);
612
		ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte());
609
				
Line 613... Line 610...
613
		recolte.initialiserType("pays");
610
		recolte.initialiserType("pays");
614
		hmInfosNat.put("recolte", recolte);
611
		hmInfosNat.put("recolte", recolte);
615
		
612
		
Line 616... Line -...
616
		fsInfosNat.add(recolte);
-
 
617
		tiInfosNat.add(fsInfosNat);
-
 
618
	}
-
 
619
	
-
 
620
	
-
 
621
	
-
 
622
	/**
-
 
623
	 * Ajouter le bouton Sauvegarder et revenir à la liste à la barre d'outils donnée
-
 
624
	 * 
-
 
625
	 * @param barreOutils la barre d'outils à modifier
-
 
626
	 * */
-
 
627
	private void ajouterBoutonEnregistrerEtRevenir(ButtonBar barreOutils)	{
-
 
628
		
-
 
629
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
-
 
630
		enregistrerEtRevenir = new Button("Enregistrer et revenir à la liste");
-
 
631
		enregistrerEtRevenir.setIcon(Images.ICONES.scriptGo());
-
 
632
		enregistrerEtRevenir.setIconAlign(IconAlign.LEFT);
-
 
633
		enregistrerEtRevenir.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
634
			public void componentSelected(ButtonEvent ce) {  
-
 
635
				if (enregistrer() == true)	{
-
 
636
					((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
-
 
637
				}
-
 
638
			}  
-
 
639
		});
-
 
640
		
-
 
641
		hmIdentite.put("btnEnregistrerRevenir", enregistrerEtRevenir);
-
 
642
		barreOutils.add(enregistrerEtRevenir);
-
 
643
		enregistrerEtRevenir.setEnabled(false);
-
 
644
		
-
 
645
	}
-
 
646
	
-
 
647
	/**
-
 
648
	 * Ajouter le bouton Sauvegarder à la barre d'outils donnée
-
 
649
	 * 
-
 
650
	 * @param barreOutils la barre d'outils à modifier
-
 
651
	 * */
-
 
652
	private void ajouterBoutonEnregistrer(ButtonBar barreOutils)	{
-
 
653
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
-
 
654
		enregistrer = new Button("Enregistrer");
-
 
655
		enregistrer.setIcon(Images.ICONES.scriptSave());
-
 
656
		enregistrer.setIconAlign(IconAlign.LEFT);
-
 
657
		enregistrer.setId("main-button");
-
 
658
		enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
659
			public void componentSelected(ButtonEvent ce) {  
-
 
660
				enregistrer();
-
 
661
			}  
-
 
662
		});
-
 
663
		enregistrer.setEnabled(false);
-
 
664
		hmIdentite.put("btnEnregistrer", enregistrer);
613
		fsInfosNat.add(recolte);
665
		barreOutils.add(enregistrer);
614
		tiInfosNat.add(fsInfosNat);
666
	}
615
	}
667
	
616
	
668
	/**
617
	/**
Line 714... Line 663...
714
				cbTelephone.setValue(liste.get(1));
663
				cbTelephone.setValue(liste.get(1));
715
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
664
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
716
				remplirCombobox("cbPays", liste, "hmAdresse");
665
				remplirCombobox("cbPays", liste, "hmAdresse");
717
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
666
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
718
				remplirCombobox("cbRegion", liste, "hmAdresse");
667
				remplirCombobox("cbRegion", liste, "hmAdresse");
719
				((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
668
				hmAdresse.getComboBox("cbRegion").setVisible(true);
720
			}
669
			}
721
		} else if (nouvellesDonnees instanceof ProjetListe) {
670
		} else if (nouvellesDonnees instanceof ProjetListe) {
722
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
671
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
723
			List<Projet> liste = projets.toList();
672
			List<Projet> liste = projets.toList();
Line 907... Line 856...
907
		/*--------------------------------------------------
856
		/*--------------------------------------------------
908
		                      Adresse
857
		                      Adresse
909
		 ---------------------------------------------------*/
858
		 ---------------------------------------------------*/
Line 910... Line 859...
910
		
859
		
911
		// Adresse
860
		// Adresse
Line 912... Line 861...
912
		((TextField<String>) hmAdresse.get("tfAdresse1")).setValue((String) personne.get("adresse_01"));
861
		hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
913
 
862
 
Line 914... Line 863...
914
		// Complément
863
		// Complément
915
		((TextField<String>) hmAdresse.get("tfAdresse2")).setValue((String) personne.get("adresse_02"));
864
		hmAdresse.getTextField("tfAdresse2").setValue((String) personne.get("adresse_02"));
Line 916... Line 865...
916
		
865
		
917
		//Boite postale
866
		//Boite postale
918
		((TextField<String>) hmAdresse.get("tfBoitePostale")).setValue((String) personne.get("bp"));
867
		hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
919
		
-
 
Line 920... Line 868...
920
		//Pays
868
		
921
		String strPays = personne.get("pays");
869
		//Pays
922
		ComboBox<Valeur> cbPays = (ComboBox<Valeur>) hmAdresse.get("cbPays");
870
		String strPays = personne.get("pays");
923
		
871
		ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
924
		
872
		
Line 925... Line 873...
925
		if (cbPays.getStore().findModel("nom", strPays) != null)	{
873
		if (cbPays.getStore().findModel("nom", strPays) != null)	{
926
			cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
874
			cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
927
		}	else	{
875
		}	else	{
928
			cbPays.setRawValue(strPays);
876
			cbPays.setRawValue(strPays);
929
		}
877
		}
Line 930... Line 878...
930
		
878
		
931
		//Région
879
		//Région
932
		String strRegion = personne.get("region");
880
		String strRegion = personne.get("region");
933
		if ((strRegion!=null)&&(!strRegion.equals("")))	{
881
		if ((strRegion!=null)&&(!strRegion.equals("")))	{
934
			ComboBox<Valeur> cbRegion = (ComboBox<Valeur>) hmAdresse.get("cbRegion");
882
			ComboBox<Valeur> cbRegion = hmAdresse.getComboBoxValeur("cbRegion");
935
			cbRegion.setVisible(true);
883
			cbRegion.setVisible(true);
Line 936... Line 884...
936
			
884
			
937
			if (cbRegion.getStore().findModel("nom", strRegion) != null)	{
885
			if (cbRegion.getStore().findModel("nom", strRegion) != null)	{
Line 938... Line 886...
938
				cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion));
886
				cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion));
939
			}	else	{
887
			}	else	{
Line 940... Line 888...
940
				cbRegion.setRawValue(strRegion);
888
				cbRegion.setRawValue(strRegion);
941
			}
889
			}
942
		}
890
		}
Line 943... Line 891...
943
		
891
		
-
 
892
		//Cp
944
		//Cp
893
		hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
Line 945... Line 894...
945
		((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal"));
894
		
946
		
895
		//Ville
Line 947... Line 896...
947
		//Ville
896
		hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
Line 996... Line 945...
996
		personneSelectionnee = personne;
945
		personneSelectionnee = personne;
997
		binding.autoBind();
946
		binding.autoBind();
998
		binding.bind(personneSelectionnee);
947
		binding.bind(personneSelectionnee);
999
		layout();
948
		layout();
1000
	}
949
	}
1001
 
-
 
1002
	/**
-
 
1003
	 * Enregistre les information de la personne en cours 
-
 
1004
	 * 
-
 
1005
	 */
-
 
1006
	public boolean enregistrer()	{
-
 
1007
		boolean success = false;
-
 
1008
		LinkedList lstMessageErreur = new LinkedList<String>();
-
 
1009
	
-
 
1010
		ComboBox<Projet> cbProjets = hmIdentite.getComboBox("cbProjets");
-
 
1011
		Projet projet = cbProjets.getValue();
-
 
1012
		if (projet == null)	{
-
 
1013
			lstMessageErreur.add("Le projet n'a pas été renseigné");
-
 
1014
		} else {
-
 
1015
			personneSelectionnee.set("ce_projet", projet.getId());
-
 
1016
		}
-
 
1017
		
-
 
1018
		String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
-
 
1019
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
-
 
1020
			lstMessageErreur.add("Le nom n'a pas été saisi");
-
 
1021
		} else {
-
 
1022
			strTfNom = UtilString.ucFirst(strTfNom);
-
 
1023
			personneSelectionnee.set("nom", strTfNom);
-
 
1024
		}
-
 
1025
		
-
 
1026
		String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
-
 
1027
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
-
 
1028
		
-
 
1029
		//Préparer les données
-
 
1030
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
-
 
1031
		Valeur valeur;
-
 
1032
		String strValeur = "";
-
 
1033
		
-
 
1034
		valeur = combo.getValue();
-
 
1035
		if (valeur!=null)	{
-
 
1036
			personneSelectionnee.set("ce_sexe", valeur.getId());
-
 
1037
		}
-
 
1038
		
-
 
1039
		strValeur = obtenirValeurCombo("cbPrefixe");
-
 
1040
		personneSelectionnee.set("ce_truk_prefix", strValeur);
-
 
1041
		
-
 
1042
		strValeur = obtenirValeurCombo("cbSuffixe"); 
-
 
1043
		personneSelectionnee.set("ce_truk_suffix", strValeur);
-
 
1044
		
-
 
1045
		String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
-
 
1046
		personneSelectionnee.set("truk_nom_autre", nomAutre);
-
 
1047
		
-
 
1048
		String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
-
 
1049
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
-
 
1050
		
-
 
1051
		personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
-
 
1052
		
-
 
1053
		
-
 
1054
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
-
 
1055
		String strPrefixe = "";
-
 
1056
		combo = hmIdentite.getComboBoxValeur("cbPrefixe");
-
 
1057
		valeur = combo.getValue();
-
 
1058
		if (valeur != null)	{
-
 
1059
			strPrefixe = valeur.getNom();
-
 
1060
		} else {
-
 
1061
			strPrefixe = combo.getRawValue();
-
 
1062
		}
-
 
1063
		
-
 
1064
		String strSuffixe = "";
-
 
1065
		combo = hmIdentite.getComboBoxValeur("cbSuffixe");
-
 
1066
		valeur = combo.getValue();
-
 
1067
		if (valeur != null)	{
-
 
1068
			strSuffixe = valeur.getNom() + " ";
-
 
1069
		} else {
-
 
1070
			strSuffixe = combo.getRawValue() +" ";
-
 
1071
		}
-
 
1072
		
-
 
1073
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
-
 
1074
		
-
 
1075
		DateField dfDateNaissance = hmIdentite.getDateField("dfDateNaissance");
-
 
1076
		Date naissanceDate = dfDateNaissance.getValue();
-
 
1077
		personneSelectionnee.setNaissanceDate(naissanceDate);
-
 
1078
		
-
 
1079
		Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
-
 
1080
		if (rbEstDecedee.getValue() == true)	{
-
 
1081
			DateField dfDecesDate = hmIdentite.getDateField("dfDateDeces");
-
 
1082
			String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
-
 
1083
			personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu);
-
 
1084
		}	else	{
-
 
1085
			personneSelectionnee.setNonDecedee();			
-
 
1086
		}
-
 
1087
		
-
 
1088
		strValeur = obtenirValeurCombo("cbPays");
-
 
1089
		personneSelectionnee.set("ce_truk_pays", strValeur);
-
 
1090
		
-
 
1091
		strValeur = obtenirValeurCombo("cbRegion");
-
 
1092
		personneSelectionnee.set("ce_truk_region", strValeur);
-
 
1093
		
-
 
1094
		personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
-
 
1095
		
-
 
1096
		String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
-
 
1097
		personneSelectionnee.set("truk_logo", logoUrls);
-
 
1098
		
-
 
1099
		personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
-
 
1100
		
-
 
1101
		//Infos Naturalistes
-
 
1102
		String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs();
-
 
1103
		personneSelectionnee.set("truk_recolte", recolte);
-
 
1104
		
-
 
1105
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
-
 
1106
		personneSelectionnee.set("ce_truk_specialite", specialite);
-
 
1107
		
-
 
1108
		
-
 
1109
		if (lstMessageErreur.size() == 0)	{
-
 
1110
			
-
 
1111
			System.out.println("2." + personne);
-
 
1112
			mediateur.enregistrerPersonne(this, personneSelectionnee);
-
 
1113
			success = true;
-
 
1114
		} else {
-
 
1115
			String strMessagesErreur = "<span><br />";
-
 
1116
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
-
 
1117
			while (itMessagesErreur.hasNext())	{
-
 
1118
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
-
 
1119
			}
-
 
1120
			strMessagesErreur += "</span>";
-
 
1121
			
-
 
1122
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
-
 
1123
 			success = false;
-
 
1124
		}
-
 
1125
		
-
 
1126
		return success;
-
 
1127
	}
-
 
Line 1128... Line 950...
1128
	
950
	
1129
	private String obtenirValeurCombo(String strComboName)	{
951
	private String obtenirValeurCombo(String strComboName)	{
1130
		String strValeur = "";
952
		String strValeur = "";
Line 1131... Line 953...
1131
		Valeur valeur;
953
		Valeur valeur;
1132
		
954
		
1133
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
955
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
1134
		if (combo == null)	{
956
		if (combo == null)	{
1135
			combo = (ComboBox) hmAdresse.get(strComboName);
957
			combo = hmAdresse.getComboBoxValeur(strComboName);
1136
		}
958
		}
1137
		strValeur = combo.getRawValue();
959
		strValeur = combo.getRawValue();
1138
		valeur = combo.getStore().findModel(strValeur);
960
		valeur = combo.getStore().findModel(strValeur);
1139
		if (valeur != null)	{
961
		if (valeur != null)	{
Line 1140... Line -...
1140
			strValeur = valeur.getId();
-
 
1141
		}
-
 
1142
		
-
 
1143
		/*if (combo.getValue()!=null)	{
-
 
1144
			valeur = (Valeur) combo.getValue();
-
 
1145
			strValeur = valeur.getId();
-
 
1146
		} else {
-
 
1147
			strValeur = combo.getRawValue();
962
			strValeur = valeur.getId();
1148
		}*/
963
		}
Line 1149... Line 964...
1149
		
964
		
1150
		return strValeur;
965
		return strValeur;