Subversion Repositories eFlore/Applications.coel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1414 → Rev 1415

/trunk/src/org/tela_botanica/client/vues/personne/PersonneForm.java
New file
0,0 → 1,1401
package org.tela_botanica.client.vues.personne;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.ChampMultiValeurs;
import org.tela_botanica.client.composants.ChampMultiValeursImage;
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable;
import org.tela_botanica.client.composants.ChampMultiValeursPaginable;
import org.tela_botanica.client.composants.HashMapComposants;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneListe;
import org.tela_botanica.client.modeles.projet.Projet;
import org.tela_botanica.client.modeles.projet.ProjetListe;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.modeles.publication.PublicationListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
 
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
 
import com.extjs.gxt.ui.client.binding.FieldBinding;
import com.extjs.gxt.ui.client.binding.FormBinding;
 
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
 
import com.extjs.gxt.ui.client.widget.ContentPanel;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.Proxy;
import org.tela_botanica.client.composants.pagination.ProxyProjets;
import org.tela_botanica.client.composants.pagination.ProxyValeur;
import org.tela_botanica.client.composants.pagination.TransformateurJSONaModelData;
 
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Text;
 
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
 
public class PersonneForm extends Formulaire implements Rafraichissable {
 
// VARIABLES
private TabItem tiIdentite, tiAdresses, tiInfosNat;
PersonneFormPublication tiPubli;
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
protected Personne personneSelectionnee, personneSauvegarde = null;
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
private HashMapComposants hmIdentite = new HashMapComposants();
private HashMapComposants hmAdresse = new HashMapComposants();
private HashMapComposants hmInfosNat = new HashMapComposants();
private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
private FormData fd100 = new FormData("95%");
private Button enregistrer, enregistrerEtRevenir;
private Personne personne = null;
private String personneId = null;
private FormBinding binding = null;
//Gestion du mode synchrone
private Sequenceur sequenceur;
//Publi
private ComboBox<Publication> cbPubli;
private ListStore<Publication> storePubli;
// CONSTRUCTEUR
public PersonneForm(Mediateur mediateurCourrant, String personneId) {
initialiserPersonneForm(mediateurCourrant, personneId);
}
public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
initialiserPersonneForm(mediateurCourrant, personneId);
}
private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
//Initialisation du séquenceur
sequenceur = new Sequenceur();
personne = new Personne();
personne.setId(personneIdCourrant);
personneId = personneIdCourrant;
String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
 
initialiserComposants();
genererTitreFormulaire();
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur);
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", null);
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerPersonne(this, personne, null, sequenceur);
}
}
private void genererTitreFormulaire() {
String titre = i18nC.personneModeAjout();
if (mode.equals(Formulaire.MODE_MODIFIER)) {
titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
}
panneauFormulaire.setHeading(titre);
}
public void initialiserComposants() {
personneSelectionnee = new Personne();
personneSauvegarde = new Personne();
initialiserOnglets();
creerComposantsIdentite();
creerComposantsAdresse();
creerComposantsInfosNat();
//creerComposantsPubli();
binderPersonne(personneSelectionnee);
}
/**
* Crée les onglets identité, adresse et informations naturaliste
*
* */
public void initialiserOnglets() {
//TabPanel
TabPanel formulaireOnglets = new TabPanel();
//Tab 1 : identite
tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite");
tiIdentite.setStyleAttribute("padding", "0");
formulaireOnglets.add(tiIdentite);
//Tab 2 : Adresse
tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses");
formulaireOnglets.add(tiAdresses);
//Tab 3 : Infos Naturalistes
tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat");
formulaireOnglets.add(tiInfosNat);
//Tab 4 : Publications
tiPubli = new PersonneFormPublication(this);
formulaireOnglets.add(tiPubli);
getFormulaire().add(formulaireOnglets);
}
/**
* Crée les widgets pour l'onglet identité
*
* */
public void creerComposantsIdentite() {
// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout());
left.setStyleAttribute("padding", "15px");
LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout());
right.setStyleAttribute("padding", "15px");
LayoutContainer main = new LayoutContainer();
main.add(left, new ColumnData(.45));
main.add(right, new ColumnData(.45));
main.setLayout(new ColumnLayout());
main.setHeight("100%");
main.setScrollMode(Scroll.AUTO);
// Création des champs
FormLayout formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset PROJET
FieldSet fsProjet = new FieldSet();
fsProjet.setHeading(i18nC.menuProjet());
fsProjet.setLayout(new FormLayout());
ModelType modelTypeProjets = new ModelType();
modelTypeProjets.setRoot("projets");
modelTypeProjets.setTotalName("nbElements");
modelTypeProjets.addField("cpr_nom");
modelTypeProjets.addField("cpr_id_projet");
String displayNameProjets = "cpr_nom";
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(sequenceur);
ChampComboBoxRechercheTempsReelPaginable cbProjets = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
cbProjets.setWidth(100, 600);
cbProjets.getCombo().setTabIndex(tabIndex++);
cbProjets.getCombo().setFieldLabel(i18nC.personneProjet());
cbProjets.getCombo().setEmptyText(i18nC.txtListeProjetDefaut());
cbProjets.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
cbProjets.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
cbProjets.getCombo().setAllowBlank(false);
cbProjets.getCombo().setEditable(false);
fsProjet.add(cbProjets, new FormData(600, 0));
hmIdentite.put("cbProjets", cbProjets);
left.add(fsProjet);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset NOM
FieldSet fsNoms = new FieldSet();
fsNoms.setHeading("Noms");
fsNoms.setLayout(formLayout);
// Nom complet : Affiché que si valeurs saisies
LabelField nomComplet = new LabelField();
nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
nomComplet.hide();
fsNoms.add(nomComplet);
hmIdentite.put("nomComplet", nomComplet);
//Préfixe
ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
cbPrefixe.setStore(storePrefixe);
cbPrefixe.setDisplayField("nom");
cbPrefixe.setEmptyText("Choisissez le préfixe:");
cbPrefixe.setFieldLabel("Prefix");
fsNoms.add(cbPrefixe);
hmIdentite.put("cbPrefixe", cbPrefixe);
mediateur.obtenirListeValeurEtRafraichir(this, "prefixe", sequenceur);
 
//Prénom
TextField<String> tfPrenom = new TextField<String>();
tfPrenom.setFieldLabel("Prénom");
tfPrenom.setName("prenom");
 
fsNoms.add(tfPrenom, new FormData(300, 0));
hmIdentite.put("tfPrenom", tfPrenom);
 
//Nom
TextField<String> tfNom = new TextField<String>();
tfNom.setFieldLabel("Nom");
tfNom.setAllowBlank(false);
tfNom.setName("nom");
tfNom.addStyleName(ComposantClass.OBLIGATOIRE);
tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire());
fsNoms.add(tfNom, new FormData(300, 0));
hmIdentite.put("tfNom", tfNom);
//Suffixe
ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
cbSuffixe.setStore(storeSuffixe);
cbSuffixe.setFieldLabel("Suffixe");
cbSuffixe.setDisplayField("nom");
cbSuffixe.setEmptyText("Choisissez un suffixe:");
fsNoms.add(cbSuffixe);
hmIdentite.put("cbSuffixe", cbSuffixe);
mediateur.obtenirListeValeurEtRafraichir(this, "suffixes", sequenceur);
 
TextField<String> tfAbreviation = new TextField<String>();
tfAbreviation.setFieldLabel("Abréviation");
tfAbreviation.setName("abreviation");
fsNoms.add(tfAbreviation);
hmIdentite.put("tfAbreviation", tfAbreviation);
 
TableLayout layoutAutreNoms = new TableLayout(2);
layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
hmIdentite.put("nomAutre", nomAutre);
autresNoms.add(nomAutre, new TableData("200px", "15px"));
ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
hmIdentite.put("abreviationAutre", abreviationAutre);
autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
fsNoms.add(autresNoms);
left.add(fsNoms);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset NAISSANCE ET DÉCÈS
FieldSet fsNaissanceEtDeces = new FieldSet();
fsNaissanceEtDeces.setHeading("Naissance et Décès");
fsNaissanceEtDeces.setLayout(new ColumnLayout());
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.TOP);
LayoutContainer containerNaissance = new LayoutContainer(formLayout);
//Remplacement du DateField par un champ texte
TextField tfDateNaissance = new TextField();
tfDateNaissance.setFieldLabel("Date de naissance");
containerNaissance.add(tfDateNaissance);
hmIdentite.put("tfDateNaissance", tfDateNaissance);
// Lieu naissance
TextField<String> tfLieuNaissance = new TextField<String>();
tfLieuNaissance.setFieldLabel("Lieu de naissance");
tfLieuNaissance.setName("naissance_lieu");
containerNaissance.add(tfLieuNaissance);
hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5));
left.add(fsNaissanceEtDeces);
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.TOP);
LayoutContainer containerDeces = new LayoutContainer(formLayout);
Radio rbEstDecedee = new Radio();
rbEstDecedee.setId("ce_deces");
rbEstDecedee.setBoxLabel("oui");
rbEstDecedee.setValueAttribute("1");
rbEstDecedee.setId("rbEstD");
rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
if(((Radio) be.getComponent()).getValue().equals(true)) {
hmIdentite.getTextField("tfDateDeces").setVisible(true);
hmIdentite.getTextField("tfLieuDeces").setVisible(true);
} else {
TextField tfDateDeces = hmIdentite.getTextField("tfDateDeces");
tfDateDeces.setValue(null);
tfDateDeces.setVisible(false);
TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces");
tfLieuDeces.setValue(null);
tfLieuDeces.setVisible(false);
}
}
});
TextField tfDateDeces = new TextField();
tfDateDeces.setFieldLabel("Date de décès");
tfDateDeces.setVisible(false);
 
containerDeces.add(tfDateDeces);
hmIdentite.put("tfDateDeces", tfDateDeces);
 
TextField<String> tfLieuDeces = new TextField<String>();
tfLieuDeces.setFieldLabel("Lieu de décès");
tfLieuDeces.setName("deces_lieu");
tfLieuDeces.setVisible(false);
containerDeces.add(tfLieuDeces);
hmIdentite.put("tfLieuDeces", tfLieuDeces);
hmIdentite.put("rbEstDecedee", rbEstDecedee);
Radio rbNestPasDecedee = new Radio();
rbNestPasDecedee.setValueAttribute("0");
rbNestPasDecedee.setBoxLabel("non");
rbNestPasDecedee.setValue(true);
RadioGroup rbgDeces = new RadioGroup();
rbgDeces.setId("rbgDeces");
rbgDeces.setFieldLabel("Est décédée");
rbgDeces.add(rbEstDecedee);
rbgDeces.add(rbNestPasDecedee);
hmIdentite.put("rbgDeces", rbgDeces);
containerDeces.add(rbgDeces);
fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5));
tiIdentite.add(main);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset CONTACT
FieldSet fsContact = new FieldSet();
fsContact.setHeading("Contact");
fsContact.setLayout(new RowLayout());
ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100);
telephones.initialiserType("tel");
fsContact.add(telephones, new FormData(450, 0));
hmIdentite.put("telephones", telephones);
ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280);
courriels.setValidation(Pattern.email, "moi@domaine.fr");
fsContact.add(courriels, new FormData(450, 0));
hmIdentite.put("courriels", courriels);
LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
fsContact.add(lcCourrielContainer);
hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
 
fsContact.add(new Text(""));
ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
sites.setValeurParDefaut("http://");
sites.setValidation(Pattern.url, "http://www.monsite.com");
fsContact.add(sites);
hmIdentite.put("sites", sites);
right.add(fsContact);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset AUTRES INFOS
FieldSet fsAutresInfos = new FieldSet();
fsAutresInfos.setHeading("Autres informations");
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
fsAutresInfos.setLayout(formLayout);
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.TOP);
LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
ListStore<Valeur> storeSexe = new ListStore<Valeur>();
ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
cbSexe.setStore(storeSexe);
cbSexe.setFieldLabel("Sexe");
cbSexe.setDisplayField("nom");
cbSexe.setEmptyText("Choisissez le sexe:");
cbSexe.setTypeAhead(true);
cbSexe.setTriggerAction(TriggerAction.ALL);
FormData fd = new FormData();
fd.setWidth(100);
lcAutreInformations1.add(cbSexe, fd);
hmIdentite.put("cbSexe", cbSexe);
mediateur.obtenirListeValeurEtRafraichir(this, "sexe", sequenceur);
//Description
TextArea taDescription = new TextArea();
taDescription.setEmptyText("Saisissez une description");
taDescription.setFieldLabel("Description");
taDescription.setWidth("100%");
taDescription.setName("description");
lcAutreInformations1.add(taDescription, new FormData(500, 200));
hmIdentite.put("taDescription", taDescription);
fsAutresInfos.add(lcAutreInformations1);
// Logo
LayoutContainer lcLogoUrl = new LayoutContainer();
hmIdentite.put("lcLogoUrl", lcLogoUrl);
ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
logo.setImageHeight("150px");
logo.setValeurParDefaut("http://");
logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
logo.setValeurBoutonSupprimer("Supprimer");
hmIdentite.put("logos", logo);
lcLogoUrl.add(logo);
fsAutresInfos.add(logo);
LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
fsAutresInfos.add(lcAutreInformations2);
right.add(fsAutresInfos);
//+------------------------------------------------------------------------------------------------------------+
// Ajout des évènements saisi
KeyListener klNoms = new KeyListener() {
public void componentKeyUp(ComponentEvent ev) {
rafraichir(null);
}
};
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
public void selectionChanged(SelectionChangedEvent se) {
rafraichir(null);
}
};
cbPrefixe.addSelectionChangedListener(selectionChange);
cbPrefixe.addKeyListener(klNoms);
tfPrenom.addKeyListener(klNoms);
tfNom.addKeyListener(klNoms);
cbSuffixe.addSelectionChangedListener(selectionChange);
}
public void creerComposantsAdresse() {
// Gauche
LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout());
left.setStyleAttribute("padding", "15px");
// Droite
LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout());
// Principal
LayoutContainer main = new LayoutContainer();
main.setLayout(new TableLayout(2));
// Ajout au principal
main.add(left);
main.add(right);
TextField<String> tfAdresse1 = new TextField();
tfAdresse1.setFieldLabel("Adresse");
tfAdresse1.setName("adresse_01");
left.add(tfAdresse1, fd100);
hmAdresse.put("tfAdresse1", tfAdresse1);
TextField<String> tfAdresse2 = new TextField();
tfAdresse2.setFieldLabel("Complément d'adresse");
tfAdresse2.setName("adresse_02");
left.add(tfAdresse2, fd100);
hmAdresse.put("tfAdresse2", tfAdresse2);
ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
cbPays.setFieldLabel("Pays");
cbPays.setDisplayField("nom");
cbPays.setEmptyText("Sélectionnez le pays:");
ListStore<Valeur> storePays = new ListStore<Valeur>();
cbPays.setStore(storePays);
right.add(cbPays, fd100);
hmAdresse.put("cbPays", cbPays);
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
public void selectionChanged(SelectionChangedEvent se) {
// Rafraichir avec le pays sélectionné
obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
//mettreAJourRegion();
}
};
cbPays.addSelectionChangedListener(selectionChange);
ComboBox<Valeur> cbRegion = new ComboBox<Valeur>();
cbRegion.setFieldLabel("Region");
cbRegion.setDisplayField("nom");
cbRegion.setEmptyText("Sélectionnez la région:");
cbRegion.setVisible(false);
ListStore<Valeur> storeRegion = new ListStore<Valeur>();
cbRegion.setStore(storeRegion);
right.add(cbRegion, fd100);
hmAdresse.put("cbRegion", cbRegion);
TextField<String> tfBoitePostale = new TextField<String>();
tfBoitePostale.setFieldLabel("Boite postale");
tfBoitePostale.setName("bp");
left.add(tfBoitePostale, fd100);
hmAdresse.put("tfBoitePostale", tfBoitePostale);
TextField<Integer> tfCodePostal = new TextField<Integer>();
tfCodePostal.setFieldLabel("Code postal");
tfCodePostal.setName("code_postal");
right.add(tfCodePostal, fd100);
hmAdresse.put("tfCodePostal", tfCodePostal);
TextField tfVille = new TextField();
tfVille.setFieldLabel("Ville");
tfVille.setName("ville");
right.add(tfVille, fd100);
hmAdresse.put("tfVille", tfVille);
// MAJ ComboBox
mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur);
FieldSet fsAdresse = new FieldSet();
fsAdresse.setHeading("Adresse personnelle");
fsAdresse.add(main);
tiAdresses.add(fsAdresse);
}
public void creerComposantsInfosNat() {
FormLayout fl = new FormLayout();
fl.setLabelAlign(LabelAlign.TOP);
FieldSet fsInfosNat = new FieldSet();
fsInfosNat.setLayout(fl);
fsInfosNat.setTitle("Informations Naturaliste");
 
TextArea taBiographie = new TextArea();
taBiographie.setFieldLabel("Vie et renommée de l'auteur");
taBiographie.setWidth("400");
taBiographie.setName("biographie");
fsInfosNat.add(taBiographie, new FormData(800, 200));
 
ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
fsInfosNat.add(specialite);
hmInfosNat.put("specialite", specialite);
 
ModelType typeTypes = new ModelType();
typeTypes.setRoot("valeurs");
typeTypes.setTotalName("nbElements");
typeTypes.addField("cmlv_nom");
typeTypes.addField("cmlv_id_valeur");
typeTypes.addField("cmlv_abreviation");
typeTypes.addField("cmlv_description");
String displayNameTypes = "cmlv_nom";
String nomListeTypes = "pays";
ProxyValeur<ModelData> proxyTypes = new ProxyValeur<ModelData>(nomListeTypes, sequenceur);
ChampMultiValeursMultiTypesPaginable recolte = new ChampMultiValeursMultiTypesPaginable(i18nC.personneRecolte(), 450, false, null, null, null, typeTypes, proxyTypes, displayNameTypes);
hmInfosNat.put("recolte", recolte);
fsInfosNat.add(recolte);
tiInfosNat.add(fsInfosNat);
}
public void creerComposantsPubli(){
//Création des composants de l'onglet publication
 
ContentPanel cp = new ContentPanel();
cp.setHeading("Publications dont la personne est le sujet");
cp.setIcon(Images.ICONES.table());
cp.setLayout(new FitLayout());
cp.setFrame(true);
ToolBar toolBar = new ToolBar();
 
Button ajouterPubli = new Button("Ajouter");
ajouterPubli.setIcon(Images.ICONES.vcardAjouter());
ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
ajouterMembreAGrillePersonnel(membreDuPersonnel);*/
}
});
toolBar.add(ajouterPubli);
toolBar.add(new SeparatorToolItem());
Button supprimerPubli = new Button("Supprimer");
supprimerPubli.setIcon(Images.ICONES.vcardSupprimer());
supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
if (personne != null) {
// Ajout de la personne supprimée à la liste
if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
personnelSupprime.put(personne.getId(), personne);
}
// Suppression de l'enregistrement de la grille
grillePersonnel.getStore().remove(personne);
// Désactivation du bouton supprimer si la grille contient plus d'élément
if (grillePersonnel.getStore().getCount() == 0) {
//TODO : check : Item -> component
ce.getComponent().disable();
}
}*/
Window.alert("supprimer");
}
});
toolBar.add(supprimerPubli);
toolBar.add(new SeparatorToolItem());
Button rafraichirPersonnelBtn = new Button("Rafraichir");
rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
//rafraichirPersonnel();
Window.alert("rafraichir");
}
});
toolBar.add(rafraichirPersonnelBtn);
//Ajout d'une ComboBox
storePubli = new ListStore<Publication>();
storePubli.add(new ArrayList<Publication>());
cbPubli = new ComboBox<Publication>();
cbPubli.setWidth(200);
cbPubli.setEmptyText("Chercher une publication existante...");
cbPubli.setTriggerAction(TriggerAction.ALL);
cbPubli.setEditable(true);
cbPubli.setDisplayField("fmt_nom_complet");
cbPubli.setStore(storePubli);
cbPubli.addKeyListener(new KeyListener() {
public void componentKeyUp(ComponentEvent ce) {
if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) {
rafraichirPublicationsExistante(cbPubli.getRawValue());
}
}
});
toolBar.add(cbPubli);
toolBar.add(new SeparatorToolItem());
cp.setTopComponent(toolBar);
tiPubli.add(cp);
}
 
public void rafraichirPublicationsExistante(String nomPubli) {
nomPubli +="%";
mediateur.selectionnerPublicationParNomComplet(this, null, nomPubli);
}
/**
* Ajouter le bouton annuler à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
* */
public static void ajouterBoutonAnnuler(ButtonBar barreOutils) {
// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
Button annuler = new Button("Revenir à la liste");
annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
}
});
annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
barreOutils.add(annuler);
}
public void obtenirListeRegionParPays(String strPays) {
mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
}
// RAFRAICHISSEMENT DU PANNEAU
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof PublicationAPersonneListe) {
Information info = new Information();
info.setType("publication_liees");
info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees);
tiPubli.rafraichir(info);
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
// Créer une liste de valeurs
List<Valeur> liste = new ArrayList<Valeur>();
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
liste.add(listeValeurs.get(it.next()));
}
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
tiPubli.rafraichir(nouvellesDonnees);
} else if (listeValeurs.getId().equals(config.getListeId("prefixe"))) {
remplirCombobox("cbPrefixe", liste, "hmIdentite");
} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
remplirCombobox("cbSuffixe", liste, "hmIdentite");
} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
//Ajout de la valeur "Inconnu"
ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe");
Valeur inconnu = new Valeur();
inconnu.set("nom", "Inconnu");
inconnu.set("id", "0");
liste.add(0, inconnu);
remplirCombobox("cbSexe", liste, "hmIdentite");
/*List<Valeur> selection = new LinkedList<Valeur>();
selection.add(inconnu);
cbSexe.setSelection(s);*/
} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
remplirCombobox("cbTelephone", liste, "hmIdentite");
 
//Préselection du tél
ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone");
cbTelephone.setValue(liste.get(1));
} else if (listeValeurs.getId().equals(config.getListeId("pays"))) {
remplirCombobox("cbPays", liste, "hmAdresse");
} else if (listeValeurs.getId().equals(config.getListeId("region"))) {
remplirCombobox("cbRegion", liste, "hmAdresse");
mettreAJourRegion();
hmAdresse.getComboBox("cbRegion").setVisible(true);
}
} else if (nouvellesDonnees instanceof ProjetListe) {
ProjetListe projets = (ProjetListe) nouvellesDonnees;
List<Projet> liste = projets.toList();
ComboBox cbProjets = hmIdentite.getComboBox("cbProjets");
ListStore<Projet> storeProjets= cbProjets.getStore();
storeProjets.removeAll();
storeProjets.add(liste);
cbProjets.setStore(storeProjets);
} else if (nouvellesDonnees instanceof PublicationListe) {
PublicationListe publicationListe = (PublicationListe) nouvellesDonnees;
List<Publication> liste = publicationListe.toList();
storePubli.removeAll();
storePubli.add(liste);
cbPubli.setStore(storePubli);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("ajout_personne")) {
if (info.getDonnee(0) != null) {
personneSelectionnee.setId(info.getDonnee(0).toString());
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
this.personne = personneSelectionnee;
this.personneId = personneSelectionnee.getId();
InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
repandreRafraichissement();
if (clicBoutonvalidation) {
mediateur.clicMenu(menuIdCourant);
}
} else {
InfoLogger.display("Enregistrement", info.getMessages().toString());
}
} else if (info.getType().equals("modification_personne")) {
InfoLogger.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
repandreRafraichissement();
if (clicBoutonvalidation) {
mediateur.clicMenu(menuIdCourant);
}
} else if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if (info.getDonnee(0) instanceof PersonneListe) {
Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
Iterator itPersonneListe = colPersonneListe.iterator();
Personne personne = (Personne) itPersonneListe.next();
//TODO : Je vois pas l'intérêt des lignes ci dessous..
personneSauvegarde = new Personne();
personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
binderPersonne(personne);
mettreAJourPersonne(personne);
this.personne = personne;
this.personneId = personne.getId();
nouvellesDonnees = null;
} else {
InfoLogger.display("messages", info.getMessages().toString());
}
}
if (nouvellesDonnees == null) {
ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe");
//Met à jour le nom Complet du formulaire
String valeurRetour = "";
// Prefixe
String prefixe = "";
Valeur valPrefixe = cb.getValue();
if (valPrefixe != null) {
prefixe = valPrefixe.getNom();
} else {
prefixe = (String) cb.getRawValue();
}
// Prénom
String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
// Nom
String nom = (String) hmIdentite.getTextField("tfNom").getValue();
// Suffixe
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
String suffixe = "";
Valeur valSuffixe = cbSuffixe.getValue();
if (valSuffixe != null) {
suffixe = valSuffixe.getNom();
} else {
suffixe = (String) cbSuffixe.getRawValue();
}
// Mettre à jour la valeur
valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
valeurRetour = valeurRetour.replaceAll("null", "");
hmIdentite.getLabelField("nomComplet").setValue(valeurRetour);
if (!valeurRetour.trim().equals("")) {
hmIdentite.getLabelField("nomComplet").show();
} else {
hmIdentite.getLabelField("nomComplet").hide();
}
}
mediateur.masquerPopinChargement();
if (this.mode.equals(MODE_AJOUTER)) {
gererEtatActivationBouton();
}
}
 
private void repandreRafraichissement() {
if (vueExterneARafraichirApresValidation != null) {
String type = "personne_modifiee";
if (mode.equals(Formulaire.MODE_AJOUTER)) {
type = "personne_ajoutee";
}
Information info = new Information(type);
info.setDonnee(0, personneSelectionnee);
vueExterneARafraichirApresValidation.rafraichir(info);
}
}
private void mettreAJourRegion() {
//Met à jour la combo box en sélectionnant la valeur enregistrée pour la personne
ComboBox<Valeur> cbRegion = hmAdresse.getComboBoxValeur("cbRegion");
if (personneSelectionnee.get("ce_truk_region")!=null && personneSelectionnee.get("ce_truk_region").toString().startsWith("AUTRE##")) {
cbRegion.setRawValue(personneSelectionnee.get("ce_truk_region").toString().replaceFirst("^AUTRE##", ""));
} else if (personneSelectionnee.get("ce_truk_region") != null && cbRegion.getStore().getCount() > 0) {
Valeur valeurRegion = cbRegion.getStore().findModel("id_valeur", personneSelectionnee.get("ce_truk_region"));
if (valeurRegion!=null) {
cbRegion.setValue(valeurRegion);
}
}
}
private void mettreAJourPersonne(Personne personne) {
//Mise à jour de la personne
ChampComboBoxRechercheTempsReelPaginable cbProjets = hmIdentite.getComboBoxRechercheTempsReelPaginable("cbProjets");
cbProjets.getCombo().setValue(cbProjets.getStore().findModel("cpr_id_projet", personne.get("ce_projet")));
//Prefixe
String prefixe = personne.get("ce_truk_prefix");
ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe");
String prefixeCourant = personne.get("ce_truk_prefix");
if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null) {
cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
} else {
cbPrefixe.setRawValue(prefixeCourant);
}
hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom"));
hmIdentite.getTextField("tfNom").setValue(personne.get("nom"));
//Suffixe
String suffixe = personne.get("ce_truk_suffixe");
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
String suffixeCourant = personne.get("ce_truk_suffix");
if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null) {
cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
} else {
cbSuffixe.setRawValue(suffixeCourant);
}
hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre"));
hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation"));
hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre"));
hmIdentite.getTextField("tfDateNaissance").setValue(personne.getAnneeOuDateNaiss());
hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu"));
if (personne.estDecedee()) {
hmIdentite.getTextField("tfDateDeces").setValue(personne.getAnneeOuDateDeces());
hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu"));
Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee");
rbEstDecede.setValue(true);
}
hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone"));
//Courriel
hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel());
//Sites web
hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url"));
// Sexe
String strSexe = personne.get("ce_sexe");
ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe");
 
if (cbSexe.getStore().findModel("id_valeur", strSexe) != null) {
cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
}
hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description"));
//Logo
hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo"));
/*--------------------------------------------------
Adresse
---------------------------------------------------*/
// Adresse
hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
 
// Complément
hmAdresse.getTextField("tfAdresse2").setValue((String) personne.get("adresse_02"));
//Boite postale
hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
//Pays
String strPays = personne.get("ce_truk_pays");
ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
cbPays.getStore().sort("nom", SortDir.ASC);
if (cbPays.getStore().findModel("id_valeur", strPays) != null) {
cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays));
cbPays.fireEvent(Events.OnChange);
} else {
cbPays.setRawValue(strPays);
}
//Région : doit être chargé après chargement de la liste des régions...
String strRegion = personne.get("ce_truk_region");
if ((strRegion!=null)&&(!strRegion.equals(""))) {
ComboBox<Valeur> cbRegion = hmAdresse.getComboBoxValeur("cbRegion");
cbRegion.setVisible(true);
if (cbRegion.getStore().findModel("id_valeur", strRegion) != null) {
cbRegion.setValue(cbRegion.getStore().findModel("id_valeur", strRegion));
} else {
cbRegion.setRawValue(strRegion);
}
}
//Cp
hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
//Ville
hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
/*--------------------------------------------------------
* Infos naturalistes
* -----------------------------------------------------*/
hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
String tr = personne.getString("truk_recolte");
hmInfosNat.getChampMultiValeursMultiTypesPaginable("recolte").peupler(tr);
//Onglet publi
tiPubli.mettreAJourPersonne();
gererEtatActivationBouton();
}
public void remplirCombobox(String idComboBox, List liste, String hashMapId) {
HashMap hm = null;
if (hashMapId.equals("hmIdentite")) {
hm = hmIdentite;
} else if (hashMapId.equals("hmAdresse")){
hm = hmAdresse;
} else {
hm = hmInfosNat;
}
ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
store.removeAll();
store.add(liste);
((ComboBox) hm.get(idComboBox)).setStore(store);
}
private void gererEtatActivationBouton() {
/* if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false) {
enregistrer.setEnabled(false);
enregistrerEtRevenir.setEnabled(false);
} else {
enregistrer.setEnabled(true);
enregistrerEtRevenir.setEnabled(true);
}*/
}
public void reinitialiserFormulaire() {
mediateur.afficherPopinChargement();
mettreAJourPersonne(personneSauvegarde);
mediateur.masquerPopinChargement();
}
 
public void binderPersonne(Personne personne) {
binding = new FormBinding(getFormulaire());
personneSelectionnee = personne;
FieldBinding f = new FieldBinding((RadioGroup) hmIdentite.get("rbgDeces"), null);
binding.autoBind();
binding.removeFieldBinding(f);
binding.bind(personneSelectionnee);
layout();
}
 
private String obtenirValeurCombo(String strComboName) {
String strValeur = "";
Valeur valeur;
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
if (combo == null) {
combo = hmAdresse.getComboBoxValeur(strComboName);
}
strValeur = combo.getRawValue();
valeur = combo.getValue();
if (valeur != null) {
strValeur = valeur.getId();
}
return strValeur;
}
 
public boolean soumettreFormulaire() {
tiPubli.collecter();
if (verifierFormulaire()) {
tiPubli.soumettre();
mediateur.enregistrerPersonne(this, personneSelectionnee);
return true;
}
else return false;
}
 
public boolean verifierFormulaire() {
boolean success = true;
LinkedList<String> lstMessageErreur = new LinkedList<String>();
ChampComboBoxRechercheTempsReelPaginable cbProjets = hmIdentite.getComboBoxRechercheTempsReelPaginable("cbProjets");
if (cbProjets.getValeur() == null) {
lstMessageErreur.add("Le projet n'a pas été renseigné");
} else {
Projet projet = new Projet(cbProjets.getValeur());
personneSelectionnee.set("ce_projet", projet.getId());
}
String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
if ((strTfNom == null)||(strTfNom.trim().equals(""))) {
lstMessageErreur.add("Le nom n'a pas été saisi");
} else {
strTfNom = UtilString.ucFirst(strTfNom);
personneSelectionnee.set("nom", strTfNom);
}
String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
//Préparer les données
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
Valeur valeur;
String strValeur = "";
valeur = combo.getValue();
if (valeur!=null) {
personneSelectionnee.set("ce_sexe", valeur.getId());
}
strValeur = obtenirValeurCombo("cbPrefixe");
personneSelectionnee.set("ce_truk_prefix", strValeur);
strValeur = obtenirValeurCombo("cbSuffixe");
personneSelectionnee.set("ce_truk_suffix", strValeur);
String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
personneSelectionnee.set("truk_nom_autre", nomAutre);
String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
String strPrefixe = "";
combo = hmIdentite.getComboBoxValeur("cbPrefixe");
valeur = combo.getValue();
if (valeur != null) {
strPrefixe = valeur.getNom();
} else {
strPrefixe = combo.getRawValue();
}
String strSuffixe = "";
combo = hmIdentite.getComboBox("cbSuffixe");
valeur = combo.getValue();
if (valeur != null) {
strSuffixe = valeur.getNom() + " ";
} else {
strSuffixe = combo.getRawValue() +" ";
}
personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
 
/** NAISSANCE **/
String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue();
traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur);
/** DECES **/
Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
if (rbEstDecedee.getValue() == true) {
// date
String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue();
traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur);
// lieu
String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
personneSelectionnee.setDecesLieu(decesLieu);
} else {
personneSelectionnee.setNonDecedee();
}
strValeur = obtenirValeurCombo("cbPays");
personneSelectionnee.set("ce_truk_pays", strValeur);
strValeur = obtenirValeurCombo("cbRegion");
ComboBox<Valeur> cbRegions = hmAdresse.getComboBoxValeur("cbRegion");
if (cbRegions.getStore().findModel("id_valeur", strValeur) == null) {
strValeur = "AUTRE##" + strValeur;
}
personneSelectionnee.set("ce_truk_region", strValeur);
personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
personneSelectionnee.set("truk_logo", logoUrls);
personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
//Infos Naturalistes
String recolte = ((ChampMultiValeursMultiTypesPaginable) hmInfosNat.get("recolte")).getValeurs();
personneSelectionnee.set("truk_recolte", recolte);
String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
personneSelectionnee.set("ce_truk_specialite", specialite);
lstMessageErreur.addAll(tiPubli.verifier());
if (lstMessageErreur.size() != 0) {
String strMessagesErreur = "<span><br />";
Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
while (itMessagesErreur.hasNext()) {
strMessagesErreur += "<br /> - " + itMessagesErreur.next();
}
strMessagesErreur += "</span>";
MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
success = false;
}
return success;
}
private void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) {
String valeurDate = date;
if (!UtilString.isEmpty(valeurDate)){
String jour = "";
String mois = "";
String annee = "";
/** JJ/MM/AAAA **/
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
jour = valeurDate.substring(0,2);
mois = valeurDate.substring(3,5);
annee = valeurDate.substring(6,10);
String dateComplete = annee+"-"+mois+"-"+jour;
if (jour == "00" || mois == "00" || annee == "0000") {
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
}
else {
if (typeDate=="naissance") {
Date naissanceDate = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDate);
personneSelectionnee.setNaissanceDate(naissanceDate);
} else if (typeDate=="décès") {
Date decesDate = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDate);
personneSelectionnee.setDecesDate(decesDate);
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
}
}
/** MM/AAAA **/
} else if (valeurDate.matches("\\d{2}/\\d{4}")) {
jour = "00";
mois = valeurDate.substring(0,2);
annee = valeurDate.substring(3,7);
String dateComplete = annee+"-"+mois+"-"+jour;
if (mois == "00" || annee == "0000") {
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
}
else {
if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete);
else if (typeDate=="décès") {
personneSelectionnee.set("deces_date", dateComplete);
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
}
}
}
/** AAAA **/
else if (valeurDate.matches("\\d{4}")) {
if (valeurDate == "0000") {
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
}
else {
if (typeDate=="naissance") personneSelectionnee.set("naissance_date", valeurDate + "-00-00");
else if (typeDate=="décès") {
personneSelectionnee.set("deces_date", valeurDate + "-00-00");
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
}
}
} else {
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
}
}
}
public Personne getPersonne() {
return this.personne;
}
public String getPersonneId() {
return this.personneId;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r1136-1368