Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 436 → Rev 437

/trunk/src/org/tela_botanica/client/vues/FormPersonneVue.java
File deleted
/trunk/src/org/tela_botanica/client/vues/PersonneForm.java
New file
0,0 → 1,1559
package org.tela_botanica.client.vues;
 
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.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Configuration;
import org.tela_botanica.client.modeles.InterneValeur;
 
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Personne;
import org.tela_botanica.client.modeles.PersonneListe;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
 
import com.extjs.gxt.ui.client.binding.FormBinding;
 
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
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.Info;
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.button.IconButton;
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.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.HiddenField;
import com.extjs.gxt.ui.client.widget.form.LabelField;
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.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.toolbar.TextToolItem;
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.user.client.ui.Widget;
 
 
 
 
public class PersonneForm extends FormPanel implements Rafraichissable {
/*--------------------------------------------------------------------------------------
* VARIABLES
* -------------------------------------------------------------------------------------
*/
private TabItem tiIdentite, tiAdresses, tiInfosNat;
private Mediateur mediateur = Registry.get(RegistreId.MEDIATEUR);
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
private Personne personneSelectionnee, personneSauvegarde = null;
private FormBinding binding = null;
/*--------------------------------------------------------------------------------------
* CONSTRUCTEUR
* -------------------------------------------------------------------------------------
*/
/**
* Constructeur du panneau
*
* Initialise le panneau et ajoute une barre d'outils à deux boutons (réinitialiser le
* formulaire et annuler la saisie).
*
* */
public PersonneForm() {
initialiserComposants();
}
public void initialiserComposants() {
personneSelectionnee = new Personne();
personneSauvegarde = new Personne();
initialiserPanneau();
ButtonBar barreOutilsBas = new ButtonBar();
barreOutilsBas.setButtonAlign(HorizontalAlignment.CENTER);
ajouterBoutonEnregistrer(barreOutilsBas);
ajouterBoutonEnregistrerEtRevenir(barreOutilsBas);
ajouterBoutonAnnuler(barreOutilsBas);
setBottomComponent(barreOutilsBas);
ToolBar barreOutilsHaut = new ToolBar();
ajouterBoutonReinitialiser(barreOutilsHaut);
setTopComponent(barreOutilsHaut);
initialiserOnglets();
creerComposantsIdentite();
creerComposantsAdresse();
layout();
binderPersonne(personneSelectionnee);
}
/*---------------------------------------------------------------------------------------
* SOUS-METHODES
* --------------------------------------------------------------------------------------
*/
/**
* Inialise le panneau donné
*
* @param contentPanel le panneau à initialiser
* */
public void initialiserPanneau() {
setIconStyle("icone-form-ajouter");
setCollapsible(false);
setHeading("Ajouter une personne");
setButtonAlign(HorizontalAlignment.CENTER);
setLayout(new FitLayout());
setBodyBorder(false);
setBorders(false);
setPadding(0);
setWidth("100%");
}
/**
* Crée les onglets identité, adresse et informations naturaliste
*
* */
public void initialiserOnglets() {
//TabPanel
TabPanel formulaireOnglets = new TabPanel();
//Tab 1 : identite
tiIdentite = new TabItem("Identité");
tiIdentite.setLayout(new FormLayout());
tiIdentite.setScrollMode(Scroll.AUTO);
formulaireOnglets.add(tiIdentite);
hmIdentite.put("tiIdentite", tiIdentite);
//Tab 2 : Adresse
tiAdresses = new TabItem("Adresse");
tiAdresses.setLayout(new FormLayout());
tiAdresses.setScrollMode(Scroll.AUTO);
formulaireOnglets.add(tiAdresses);
//Tab 3 : Infos Naturalistes
tiInfosNat = new TabItem("Informations Naturalistes");
tiInfosNat.setLayout(new FormLayout());
tiInfosNat.setScrollMode(Scroll.AUTO);
formulaireOnglets.add(tiInfosNat);
add(formulaireOnglets);
}
/**
* Crée les widgets pour l'onglet identité
*
* */
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
private FormData fd100 = new FormData("1");
public void creerComposantsIdentite() {
// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout());
LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout());
LayoutContainer main = new LayoutContainer();
main.setLayout(new ColumnLayout());
main.add(left, new ColumnData(.49));
main.add(right, new ColumnData(.49));
// Création des champs
FormLayout formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
FieldSet fsNoms = new FieldSet();
fsNoms.setHeading("Noms");
fsNoms.setLayout(formLayout);
// Nom complet : Affiché que si valeurs saisies
LabelField nomComplet = new LabelField();
nomComplet.setFieldLabel("Nom complet:");
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");
//Prénom
TextField<String> tfPrenom = new TextField<String>();
tfPrenom.setFieldLabel("Prénom");
tfPrenom.setName("prenom");
fsNoms.add(tfPrenom);
hmIdentite.put("tfPrenom", tfPrenom);
//Nom
TextField<String> tfNom = new TextField<String>();
tfNom.setFieldLabel("Nom");
tfNom.setName("nom");
fsNoms.add(tfNom);
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");
TextField<String> tfNomAutre = new TextField();
tfNomAutre.setFieldLabel("Autres noms");
tfNomAutre.setName("truk_nom_autre");
fsNoms.add(tfNomAutre);
hmIdentite.put("tfNomAutre", tfNomAutre);
TextField<String> tfAbreviation = new TextField<String>();
tfAbreviation.setFieldLabel("Abréviation");
tfAbreviation.setName("abreviation");
fsNoms.add(tfAbreviation);
hmIdentite.put("tfAbreviation", tfAbreviation);
//Abréviation autres
TextField<String> tfAbreviationAutre = new TextField<String>();
tfAbreviationAutre.setFieldLabel("Autres Abrév.");
tfAbreviationAutre.setName("truk_abreviation_autre");
fsNoms.add(tfAbreviationAutre);
hmIdentite.put("tfAbreviationAutre", tfAbreviationAutre);
left.add(fsNoms);
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
FieldSet fsNaissance = new FieldSet();
fsNaissance.setHeading("Naissance");
fsNaissance.setLayout(formLayout);
DateField dfDateNaissance = new DateField();
dfDateNaissance.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
dfDateNaissance.setFieldLabel("Date");
dfDateNaissance.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
fsNaissance.add(dfDateNaissance);
hmIdentite.put("dfDateNaissance", dfDateNaissance);
// Lieu naissance
TextField<String> tfLieuNaissance = new TextField();
tfLieuNaissance.setFieldLabel("Lieu");
tfLieuNaissance.setName("naissance_lieu");
fsNaissance.add(tfLieuNaissance);
hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
left.add(fsNaissance);
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
FieldSet fsDeces = new FieldSet();
fsDeces.setHeading("Décès");
fsDeces.setLayout(formLayout);
DateField dfDateDeces = new DateField();
dfDateDeces.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
dfDateDeces.setFormatValue(true);
dfDateDeces.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
dfDateDeces.setFieldLabel("Date");
fsDeces.add(dfDateDeces);
hmIdentite.put("dfDateDeces", dfDateDeces);
 
TextField<String> tfLieuDeces = new TextField();
tfLieuDeces.setFieldLabel("Lieu");
tfLieuDeces.setName("deces_lieu");
fsDeces.add(tfLieuDeces);
hmIdentite.put("tfLieuDeces", tfLieuDeces);
left.add(fsDeces);
tiIdentite.add(main);
FieldSet fsContactTel = new FieldSet();
fsContactTel.setHeading("Contact - Téléphones");
fsContactTel.setLayout(new RowLayout());
right.add(fsContactTel);
hmIdentite.put("fsContactTel", fsContactTel);
LayoutContainer lcTelephone = new LayoutContainer();
lcTelephone.setLayout(new ColumnLayout());
TextField tfTelephone = new TextField();
tfTelephone.setFieldLabel("tel");
lcTelephone.add(tfTelephone, new ColumnData(0.40));
hmIdentite.put("tfTelephone", tfTelephone);
ListStore<Valeur> storeTel = new ListStore<Valeur>();
ComboBox<Valeur> cbTelephone = new ComboBox<Valeur>();
cbTelephone.setDisplayField("nom");
cbTelephone.setEmptyText("Choisissez:");
cbTelephone.setStore(storeTel);
lcTelephone.add(cbTelephone, new ColumnData(0.40));
hmIdentite.put("cbTelephone", cbTelephone);
mediateur.obtenirListeValeurEtRafraichir(this, "tel");
IconButton bAjouter = new IconButton(ComposantClass.ICONE_AJOUTER);
bAjouter.addSelectionListener(
new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
String strTelephone = ((TextField<String>) hmIdentite.get("tfTelephone")).getValue();
if ((strTelephone==null)||(strTelephone.trim().equals(""))) {
MessageBox.alert("Erreur de saisie", "Vous devez saisir un numéro de téléphone", null);
} else if (hmIdentite.get("tel-" + strTelephone) != null){
MessageBox.alert("Erreur de saisie", "Le numéro saisi est déjà présent dans la liste", null);
} else {
String strValeurTypeTel = "";
String idTel = "";
Valeur valeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getValue();
if (valeurTypeTel != null) {
strValeurTypeTel = valeurTypeTel.getNom();
idTel = valeurTypeTel.get("abreviation");
} else {
strValeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getRawValue();
idTel = strValeurTypeTel;
}
if (strValeurTypeTel.trim().equals("")) {
MessageBox.alert("Erreur de saisie", "Vous devez saisir un type de téléphone", null);
} else {
ajouterTelephone(strTelephone, strValeurTypeTel, idTel);
}
}
}
}
);
lcTelephone.add(bAjouter, new ColumnData(0.15));
HiddenField<String> hfTelephone = new HiddenField<String>();
add(hfTelephone);
hmIdentite.put("hfTelephone", hfTelephone);
fsContactTel.add(lcTelephone);
FieldSet fsContact = new FieldSet();
fsContact.setHeading("Contact - Autres");
fsContact.setId("fsContact");
fsContact.setLayout(new RowLayout());
right.add(fsContact);
hmIdentite.put("fsContact", fsContact);
 
LabelField lfCourriel = new LabelField();
lfCourriel.setText("<b>Courriels:</b>");
fsContact.add(lfCourriel);
LayoutContainer lcCourriel = new LayoutContainer();
lcCourriel.setLayout(new ColumnLayout());
TextField tfCourriel = new TextField();
lcCourriel.add(tfCourriel, new ColumnData(0.80));
HiddenField hfHiddenCourriel = new HiddenField();
hfHiddenCourriel.setId("tfHiddenCourriel");
hfHiddenCourriel.setValue("");
add(hfHiddenCourriel);
hmIdentite.put("hfHiddenCourriel", hfHiddenCourriel);
//tfHiddenCourriel.setVisible(true);
hmIdentite.put("tfCourriel", tfCourriel);
IconButton bAjouterCourriel = new IconButton(ComposantClass.ICONE_AJOUTER);
bAjouterCourriel.addSelectionListener(
new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
String strEmail = ((TextField<String>) hmIdentite.get("tfCourriel")).getValue();
if ((strEmail==null)||(strEmail.trim().equals(""))) {
MessageBox.alert("Erreur de saisie", "Vous devez saisir une adresse", null);
} else if (hmIdentite.get("email-" + strEmail) != null){
MessageBox.alert("Erreur de saisie", "L'adresse saisie est déjà dans la liste", null);
} else {
if (!strEmail.matches("(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*")) {
MessageBox.alert("Erreur de saisie", "L'adresse n'est pas au bon format (ex: me@domain.com)", null);
} else if (strEmail.length()>255){
MessageBox.alert("Erreur de saisie", "L'adresse ne peut dépasser 255 caractères", null);
} else {
ajouterCourriel(strEmail);
}
}
}
});
lcCourriel.add(bAjouterCourriel, new ColumnData(0.15));
fsContact.add(lcCourriel);
LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
fsContact.add(lcCourrielContainer);
hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
 
LabelField lfUrl = new LabelField();
lfUrl.setText("<b>Sites Web:</b>");
fsContact.add(lfUrl);
LayoutContainer lcUrl = new LayoutContainer(new ColumnLayout());
hmIdentite.put("lcUrl", lcUrl);
HiddenField<String> hfUrl = new HiddenField<String>();
hmIdentite.put("hfUrl", hfUrl);
add(hfUrl);
TextField tfUrl = new TextField();
tfUrl.setValue("http://");
lcUrl.add(tfUrl, new ColumnData(0.8));
hmIdentite.put("tfUrl", tfUrl);
IconButton ibAjouterUrl = new IconButton(ComposantClass.ICONE_AJOUTER);
ibAjouterUrl.addSelectionListener(new SelectionListener<ComponentEvent>() {
 
public void componentSelected(ComponentEvent ce) {
TextField<String> tfUrl = (TextField) hmIdentite.get("tfUrl");
String strUrl = tfUrl.getValue();
if ((strUrl == null)||(strUrl.trim().equals("http://"))||(strUrl.trim().equals(""))) {
MessageBox.alert("Erreur de saisie", "Vous devez saisir un URL", null);
} else if(hmIdentite.get("url-" + strUrl) != null) {
MessageBox.alert("Erreur de saisie", "L'url est déjà présente dans la liste.", null);
} else {
tfUrl.setValue("");
if (!strUrl.matches("[a-z]{3,}://[a-z0-9-]+.[.a-z0-9-]+(?::[0-9]*)?")) {
MessageBox.alert("Erreur de saisie", "L'adresse n'est pas au bon format (ex: http://www.domain.com)", null);
} else if (strUrl.length()>255){
MessageBox.alert("Erreur de saisie", "L'adresse ne peut dépasser 255 caractères", null);
} else {
ajouterUrl(strUrl);
}
}
}
});
lcUrl.add(ibAjouterUrl, new ColumnData(0.15));
fsContact.add(lcUrl);
LayoutContainer lcUrlContainer = new LayoutContainer(new RowLayout());
fsContact.add(lcUrlContainer);
hmIdentite.put("lcUrlContainer", lcUrlContainer);
 
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);
//Civilité
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:");
lcAutreInformations1.add(cbSexe, fd100);
hmIdentite.put("cbSexe", cbSexe);
mediateur.obtenirListeValeurEtRafraichir(this, "sexe");
//Description
TextArea taDescription = new TextArea();
taDescription.setEmptyText("Saisissez une description");
taDescription.setFieldLabel("Description");
taDescription.setWidth("100%");
taDescription.setName("description");
lcAutreInformations1.add(taDescription, fd100);
hmIdentite.put("taDescription", taDescription);
fsAutresInfos.add(lcAutreInformations1);
// Logo
LayoutContainer lcAutreInformations2 = new LayoutContainer();
hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
LabelField lfUrlLogo = new LabelField();
lfUrlLogo.setText("<b>Logo:</b>");
lcAutreInformations2.add(lfUrlLogo);
LayoutContainer lcUrlLogo = new LayoutContainer(new ColumnLayout());
hmIdentite.put("lcUrlLogo", lcUrlLogo);
TextField tfUrlLogo = new TextField();
tfUrlLogo.setValue("http://");
HiddenField<String> hfUrlLogo = new HiddenField<String>();
hmIdentite.put("hfUrlLogo", hfUrlLogo);
lcUrlLogo.add(tfUrlLogo, new ColumnData(0.8));
hmIdentite.put("tfUrlLogo", tfUrlLogo);
IconButton ibAjouterUrlLogo = new IconButton(ComposantClass.ICONE_AJOUTER);
ibAjouterUrlLogo.addSelectionListener(new SelectionListener<ComponentEvent>() {
 
public void componentSelected(ComponentEvent ce) {
TextField<String> tfUrlLogo = (TextField) hmIdentite.get("tfUrlLogo");
String strUrl = tfUrlLogo.getValue();
if ((strUrl == null)||(strUrl.trim().equals("http://"))||(strUrl.trim().equals(""))) {
MessageBox.alert("Erreur de saisie", "Vous devez saisir un URL", null);
} else if(hmIdentite.get("url-" + strUrl) != null) {
MessageBox.alert("Erreur de saisie", "L'url est déjà présente dans la liste.", null);
} else {
tfUrlLogo.setValue("");
if (!strUrl.matches("[a-z]{3,}://[a-z0-9-]+.[.a-z0-9-]+(?::[0-9]*)?")) {
MessageBox.alert("Erreur de saisie", "L'adresse n'est pas au bon format (ex: http://www.domain.com)", null);
} else if (strUrl.length()>255){
MessageBox.alert("Erreur de saisie", "L'adresse ne peut dépasser 255 caractères", null);
} else {
ajouterUrlLogo(strUrl);
}
}
}
});
lcUrlLogo.add(ibAjouterUrlLogo, new ColumnData(0.15));
lcAutreInformations2.add(lcUrlLogo);
fsAutresInfos.add(lcAutreInformations2);
TextArea taLogo = new TextArea();
taLogo.setFieldLabel("Logos");
taLogo.setWidth("100%");
taLogo.setEmptyText("Saisissez les adresses des logos séparées par un saut de ligne");
//fsAutresInfos.add(taLogo, fd100);
hmIdentite.put("taLogo", taLogo);
right.add(fsAutresInfos);
// Ajout des évènements saisi
KeyListener klNoms = new KeyListener() {
public void componentKeyUp(ComponentEvent ev) {
rafraichir(null);
}
};
SelectionChangedListener<InterneValeur> selectionChange = new SelectionChangedListener<InterneValeur>() {
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());
// Droite
LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout());
// Principal
LayoutContainer main = new LayoutContainer();
main.setLayout(new ColumnLayout());
// Ajout au principal
main.add(left, new ColumnData(.49));
main.add(right, new ColumnData(.49));
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());
}
};
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");
FieldSet fsAdresse = new FieldSet();
fsAdresse.setHeading("Adresse personnelle");
fsAdresse.add(main);
tiAdresses.add(fsAdresse);
((ComboBox) hmIdentite.get("cbPrefixe")).setRawValue("ljkhlkj");
}
/**
* Ajouter le bouton réinitialiser à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
* */
public void ajouterBoutonReinitialiser(ToolBar barreOutils) {
//Le bouton réintialiser recharge la page sans sauvegarder les informations
TextToolItem reinitialiser = new TextToolItem("Réinitialiser le formulaire");
reinitialiser.setIconStyle(ComposantClass.ICONE_RAFRAICHIR);
reinitialiser.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
//((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicAjouterPersonne();
reinitialiser();
//System.out.println(personneSelectionnee);
}
});
barreOutils.add(reinitialiser);
}
/**
* Ajouter le bouton Sauvegarder et revenir à la liste à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
* */
public static void ajouterBoutonEnregistrerEtRevenir(ButtonBar barreOutils) {
//Le bouton réintialiser recharge la page sans sauvegarder les informations
Button enregistrer = new Button("Enregistrer et revenir à la liste");
enregistrer.setIconStyle(ComposantClass.ICONE_PREFERENCE);
enregistrer.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
// TODO : Enregistrer le formulaire
}
});
barreOutils.add(enregistrer);
}
/**
* Ajouter le bouton Sauvegarder à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
* */
public void ajouterBoutonEnregistrer(ButtonBar barreOutils) {
//Le bouton réintialiser recharge la page sans sauvegarder les informations
Button enregistrer = new Button("Enregistrer");
enregistrer.setIconStyle(ComposantClass.ICONE_PREFERENCE);
enregistrer.setId("main-button");
enregistrer.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
enregistrer();
}
});
barreOutils.add(enregistrer);
}
/**
* 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<ComponentEvent>() {
public void componentSelected(ComponentEvent 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 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("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"))) {
 
remplirCombobox("cbSexe", liste, "hmIdentite");
} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
remplirCombobox("cbTelephone", liste, "hmIdentite");
//Préselection du tél
ComboBox<Valeur> cbTelephone = (ComboBox<Valeur>) hmIdentite.get("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");
((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
}
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("ajout_personne")) {
personneSelectionnee.set("id_personne", info.toString());
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
Info.display("Enregistrement", "La personne a été ajoutée (PID:" + personneSelectionnee.getId() + ")");
//Passer en mode modifier
} else if (info.getType().equals("modification_personne")) {
Info.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
} else if (info.getType().equals("suppression_personne")) {
GWT.log(info.toString(), null);
Info.display("lk", info.getMessages().toString());
} else if (info.getDonnee(0) instanceof PersonneListe) {
Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
Iterator itPersonneListe = colPersonneListe.iterator();
Personne personne = (Personne) itPersonneListe.next();
personneSauvegarde = new Personne();
personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
binderPersonne(personne);
//Mise à jour de la personne
//Personne personne = (Personne) nouvellesDonnees;
//Prefixe
String prefixe = personne.get("ce_truk_prefix");
ComboBox<Valeur> cbPrefixe = (ComboBox<Valeur>) hmIdentite.get("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);
}
((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom"));
((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom"));
//Suffixe
String suffixe = personne.get("ce_truk_suffixe");
ComboBox<Valeur> cbSuffixe = (ComboBox<Valeur>) hmIdentite.get("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);
}
((TextField) hmIdentite.get("tfNomAutre")).setValue(personne.get("truk_nom_autre"));
((TextField) hmIdentite.get("tfAbreviation")).setValue(personne.get("abreviation"));
((TextField) hmIdentite.get("tfAbreviationAutre")).setValue(personne.get("truk_abreviation_autre"));
(((DateField) hmIdentite.get("dfDateNaissance"))).setValue(personne.getDate("naissance_date"));
((TextField) hmIdentite.get("tfLieuNaissance")).setValue(personne.get("naissance_lieu"));
(((DateField) hmIdentite.get("dfDateDeces"))).setValue(personne.getDate("deces_date"));
((TextField) hmIdentite.get("tfLieuDeces")).setValue(personne.get("deces_lieu"));
// Telephone
HashMap<String, String> hmTelephone = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_telephone");
if (hmTelephone!=null) {
ListStore storeTelephone = ((ComboBox) hmIdentite.get("cbTelephone")).getStore();
List lstModelsTelephone = storeTelephone.getModels();
Iterator<Valeur> itStore = lstModelsTelephone.iterator();
HashMap<String, String> hmTel = new HashMap();
while (itStore.hasNext()) {
Valeur v = itStore.next();
hmTel.put(v.getAbreviation(), v.getNom());
}
Collection<String> colTelephone = hmTelephone.keySet();
Iterator<String> itTelephone = colTelephone.iterator();
while (itTelephone.hasNext()) {
String strTypeTelephone = itTelephone.next();
String strTelephone = hmTelephone.get(strTypeTelephone);
String idTel = hmTel.get(strTypeTelephone);
if (idTel == null) {
idTel = strTypeTelephone;
}
ajouterTelephone(strTelephone, idTel, strTypeTelephone);
}
}
//Courriel
LinkedList<String> lCourriels = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_courriel");
Iterator<String> itCourriels = lCourriels.iterator();
while (itCourriels.hasNext()) {
String strEmail = itCourriels.next();
ajouterCourriel(strEmail);
}
// Sites
LinkedList<String> lUrl = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_url");
if (lUrl!=null) {
Iterator<String> itUrl = lUrl.iterator();
while (itUrl.hasNext()) {
String strUrl = itUrl.next();
ajouterUrl(strUrl);
}
}
// Sexe
String strSexe = personne.get("ce_sexe");
ComboBox<Valeur> cbSexe = (ComboBox<Valeur>) hmIdentite.get("cbSexe");
//FIXME : le lien avec la bdd ne peut pas se faire
if (cbSexe.getStore().findModel("abreviation", strSexe) != null) {
cbSexe.setValue(cbSexe.getStore().findModel("abreviation", strSexe));
} else {
cbSexe.setRawValue(strSexe);
}
((TextArea) hmIdentite.get("taDescription")).setRawValue((String) personne.get("description"));
// Logos
TextArea taLogo = (TextArea) hmIdentite.get("taLogo");
LinkedList<String> lLogo = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_logo");
if (lLogo!=null) {
Iterator<String> itLogo = lLogo.iterator();
String strValeurLogo = "";
while (itLogo.hasNext()) {
strValeurLogo += itLogo.next() + "\n";
}
if (!strValeurLogo.trim().equals("")) {
taLogo.setRawValue(strValeurLogo);
}
}
/*--------------------------------------------------
Adresse
---------------------------------------------------*/
// Adresse
((TextField<String>) hmAdresse.get("tfAdresse1")).setValue((String) personne.get("adresse_01"));
// Complément
((TextField<String>) hmAdresse.get("tfAdresse2")).setValue((String) personne.get("adresse_02"));
//Boite postale
((TextField<String>) hmAdresse.get("tfBoitePostale")).setValue((String) personne.get("bp"));
//Pays
String strPays = personne.get("pays");
ComboBox<Valeur> cbPays = (ComboBox<Valeur>) hmAdresse.get("cbPays");
if (cbPays.getStore().findModel("nom", strPays) != null) {
cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
} else {
cbPays.setRawValue(strPays);
}
//Région
String strRegion = personne.get("region");
if ((strRegion!=null)&&(!strRegion.equals(""))) {
ComboBox<Valeur> cbRegion = (ComboBox<Valeur>) hmAdresse.get("cbRegion");
cbRegion.setVisible(true);
if (cbRegion.getStore().findModel("nom", strRegion) != null) {
cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion));
} else {
cbRegion.setRawValue(strRegion);
}
}
//Cp
((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal"));
//Ville
((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville"));
} else {
Info.display("messages", info.getMessages().toString());
}
}
if (nouvellesDonnees == null)
{
ComboBox cb= (ComboBox) hmIdentite.get("cbPrefixe");
//Met à jour le nom Complet du formulaire
String valeurRetour = "";
// Prefixe
String prefixe = "";
Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefixe")).getValue();
if (valPrefixe != null) {
prefixe = valPrefixe.getNom();
} else {
prefixe = (String) ((ComboBox) hmIdentite.get("cbPrefixe")).getRawValue();
}
// Prénom
String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
// Nom
String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
// Suffixe
String suffixe = "";
Valeur valSuffixe = (Valeur) ((ComboBox) hmIdentite.get("cbSuffixe")).getValue();
if (valSuffixe != null) {
suffixe = valSuffixe.getNom();
} else {
suffixe = (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getRawValue();
}
// Mettre à jour la valeur
valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
valeurRetour = valeurRetour.replaceAll("null", "");
((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
if (!valeurRetour.trim().equals("")) {
((LabelField) hmIdentite.get("nomComplet")).show();
} else {
((LabelField) hmIdentite.get("nomComplet")).hide();
}
}
mediateur.masquerPopinChargement();
}
 
private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
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);
}
public void ajouterTelephone(String strTelephone, String strValeurTypeTel, String idTel) {
//Ajout d'un champ à la liste
String strIdTelephone = idTel + "##" + strTelephone + ";;";
FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
LayoutContainer lcTelephone = new LayoutContainer();
lcTelephone.setLayout(new ColumnLayout());
Text tTypeTelephone = new Text();
tTypeTelephone.setText(strValeurTypeTel+":");
hmIdentite.put("type-" + strIdTelephone, tTypeTelephone);
lcTelephone.add(tTypeTelephone, new ColumnData(0.40));
Text tTelephone = new Text();
tTelephone.setText(strTelephone);
hmIdentite.put("tel-" + strIdTelephone, tTelephone);
lcTelephone.add(tTelephone, new ColumnData(0.40));
IconButton bSupprimer = new IconButton(ComposantClass.ICONE_SUPPRIMER);
bSupprimer.setId(strIdTelephone);
bSupprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
String strIdTelephone = ce.component.getId();
LayoutContainer lcContactTel = (LayoutContainer) hmIdentite.get("lc-"+strIdTelephone);
lcContactTel.remove(hmIdentite.get("type-" + strIdTelephone));
hmIdentite.remove("type-" + strIdTelephone);
lcContactTel.remove(hmIdentite.get("tel-" + strIdTelephone));
hmIdentite.remove("tel-" + strIdTelephone);
lcContactTel.remove(ce.component);
FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
fsContactTel.remove(lcContactTel);
HiddenField<String> hfTelephone = (HiddenField) hmIdentite.get("hfTelephone");
String strValeurTelephone = hfTelephone.getValue();
strValeurTelephone = strValeurTelephone.replace(strIdTelephone, "");
hfTelephone.setValue(strValeurTelephone);
layout();
}
});
lcTelephone.add(bSupprimer, new ColumnData(0.15));
hmIdentite.put("lc-"+strIdTelephone, lcTelephone);
fsContactTel.add(lcTelephone);
HiddenField<String> hfTelephone = (HiddenField) hmIdentite.get("hfTelephone");
String strValeurTelephone = hfTelephone.getValue();
if (strValeurTelephone==null) {
strValeurTelephone = "";
}
strValeurTelephone += strIdTelephone;
hfTelephone.setValue(strValeurTelephone);
layout();
}
public void ajouterCourriel(String strEmail) {
TextField<String> tfCourriel = (TextField<String>) hmIdentite.get("tfCourriel");
tfCourriel.setValue("");
//Ajouter adresse email
LayoutContainer lcCourrielContainer = (LayoutContainer) hmIdentite.get("lcCourrielContainer");
LayoutContainer lcCourriel = new LayoutContainer();
lcCourriel.setLayout(new ColumnLayout());
LabelField lfCourriel = new LabelField();
lfCourriel.setText(strEmail);
lcCourriel.add(lfCourriel, new ColumnData(0.8));
hmIdentite.put("lc-" + strEmail, lcCourriel);
//Bouton supprimer
IconButton btnSupprimerCourriel = new IconButton(ComposantClass.ICONE_SUPPRIMER);
btnSupprimerCourriel.setId(strEmail);
btnSupprimerCourriel.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
//Suppression de l'adresse email
String strEmail = ce.component.getId();
LayoutContainer lcCourrielContainer = (LayoutContainer) hmIdentite.get("lcCourrielContainer");
LayoutContainer lcCourriel = (LayoutContainer) hmIdentite.get("lc-" + strEmail);
lcCourrielContainer.remove(lcCourriel);
hmIdentite.remove("lc-" + strEmail);
hmIdentite.remove("email-" + strEmail);
HiddenField<String> hfHiddenCourriel = (HiddenField) hmIdentite.get("hfHiddenCourriel");
String strValeurCourriel = hfHiddenCourriel.getValue();
strValeurCourriel = strValeurCourriel.replace(strEmail + ";;", "");
hfHiddenCourriel.setValue(strValeurCourriel);
}
});
lcCourriel.add(btnSupprimerCourriel);
lcCourrielContainer.add(lcCourriel);
hmIdentite.put("email-" + strEmail, lfCourriel);
HiddenField<String> hfHiddenCourriel = (HiddenField) hmIdentite.get("hfHiddenCourriel");
String strHiddenCourrielValue = hfHiddenCourriel.getValue();
if (strHiddenCourrielValue == null) {
strHiddenCourrielValue = "";
}
hfHiddenCourriel.setRawValue(strHiddenCourrielValue + strEmail + ";;");
layout();
}
public void ajouterUrl(String strUrl) {
LayoutContainer lcUrlContainer = (LayoutContainer) hmIdentite.get("lcUrlContainer");
LayoutContainer lcUrl = new LayoutContainer();
lcUrl.setLayout(new ColumnLayout());
hmIdentite.put("lc-" + strUrl, lcUrl);
Text tUrl = new Text(strUrl);
hmIdentite.put("url-"+strUrl, tUrl);
lcUrl.add(tUrl, new ColumnData(0.8));
IconButton ibSupprimerUrl = new IconButton(ComposantClass.ICONE_SUPPRIMER);
ibSupprimerUrl.setId(strUrl);
ibSupprimerUrl.addSelectionListener(new SelectionListener<ComponentEvent>() {
 
public void componentSelected(ComponentEvent ce) {
//Suppression url
String strUrl = ce.component.getId();
LayoutContainer lcUrl = (LayoutContainer) hmIdentite.get("lc-" + strUrl);
LayoutContainer lcUrlContainer = (LayoutContainer) hmIdentite.get("lcUrlContainer");
lcUrlContainer.remove(lcUrl);
HiddenField<String> hfUrl = (HiddenField<String>) hmIdentite.get("hfUrl");
String strValeurUrl = hfUrl.getValue();
strValeurUrl = strValeurUrl.replace(strUrl, "");
hfUrl.setValue(strValeurUrl);
}
});
lcUrl.add(ibSupprimerUrl, new ColumnData(0.15));
lcUrlContainer.add(lcUrl);
HiddenField<String> hfUrl = (HiddenField<String>) hmIdentite.get("hfUrl");
String strValeurUrl = hfUrl.getValue();
if (strValeurUrl == null) {
strValeurUrl = "";
}
strValeurUrl += strUrl + ";;";
hfUrl.setValue(strValeurUrl);
layout();
}
public void ajouterUrlLogo(String strUrl) {
LayoutContainer lcUrlContainer = (LayoutContainer) hmIdentite.get("lcAutreInformations2");
LayoutContainer lcUrl = new LayoutContainer();
lcUrl.setLayout(new ColumnLayout());
hmIdentite.put("lc-" + strUrl, lcUrl);
Text tUrl = new Text(strUrl);
hmIdentite.put("url-"+strUrl, tUrl);
lcUrl.add(tUrl, new ColumnData(0.8));
IconButton ibSupprimerUrl = new IconButton(ComposantClass.ICONE_SUPPRIMER);
ibSupprimerUrl.setId(strUrl);
ibSupprimerUrl.addSelectionListener(new SelectionListener<ComponentEvent>() {
 
public void componentSelected(ComponentEvent ce) {
//Suppression url
String strUrl = ce.component.getId();
LayoutContainer lcUrl = (LayoutContainer) hmIdentite.get("lc-" + strUrl);
LayoutContainer lcUrlContainer = (LayoutContainer) hmIdentite.get("lcAutreInformations2");
lcUrlContainer.remove(lcUrl);
HiddenField<String> hfUrlLogo = (HiddenField<String>) hmIdentite.get("hfUrlLogo");
String strValeurUrl = hfUrlLogo.getValue();
strValeurUrl = strUrl.replace(strUrl, "");
hfUrlLogo.setValue(strValeurUrl);
}
});
lcUrl.add(ibSupprimerUrl, new ColumnData(0.15));
lcUrlContainer.add(lcUrl);
HiddenField<String> hfUrlLogo = (HiddenField<String>) hmIdentite.get("hfUrlLogo");
String strValeurUrl = hfUrlLogo.getValue();
if (strValeurUrl == null) {
strValeurUrl = "";
}
strValeurUrl += strUrl + ";;";
hfUrlLogo.setValue(strValeurUrl);
layout();
}
public void reinitialiser() {
mediateur.afficherPopinChargement();
binderPersonne(personneSauvegarde);
layout();
mediateur.masquerPopinChargement();
}
public void binderPersonne(Personne personne) {
binding = new FormBinding(this);
personneSelectionnee = personne;
binding.autoBind();
binding.bind(personneSelectionnee);
layout();
}
 
/**
* Enregistre les information de la personne en cours
*
*/
public void enregistrer() {
LinkedList lstMessageErreur = new LinkedList<String>();
//Préparer les données
ComboBox combo = (ComboBox) hmIdentite.get("cbSexe");
Valeur valeur;
String strValeur = "";
if (combo.getValue()!=null) {
valeur = (Valeur) combo.getValue();
strValeur = valeur.getId();
}
if (!strValeur.trim().equals("")) {
personneSelectionnee.set("sexe", strValeur);
} else {
lstMessageErreur.add("Le champ Sexe n'a pas été renseigné");
}
strValeur = obtenirValeurCombo("cbPrefixe");
personneSelectionnee.set("ce_truk_prefix", strValeur);
strValeur = obtenirValeurCombo("cbSuffixe");
personneSelectionnee.set("ce_truk_suffix", strValeur);
personneSelectionnee.set("truk_courriel", ((HiddenField<String>) hmIdentite.get("hfHiddenCourriel")).getValue());
//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
String strPrefixe = "";
combo = (ComboBox) hmIdentite.get("cbPrefixe");
valeur = (Valeur) combo.getValue();
if (valeur != null) {
strPrefixe = valeur.getNom();
} else {
strPrefixe = combo.getRawValue();
}
String strSuffixe = "";
combo = (ComboBox) hmIdentite.get("cbSuffixe");
valeur = (Valeur) combo.getValue();
if (valeur != null) {
strSuffixe = valeur.getNom();
} else {
strSuffixe = combo.getRawValue();
}
strValeur = strPrefixe
+ " " + personneSelectionnee.get("prenom")
+ " " + personneSelectionnee.get("nom")
+ " " + strSuffixe;
personneSelectionnee.set("fmt_nom_complet", strValeur);
personneSelectionnee.set("naissance_date", (Date) ((DateField) hmIdentite.get("dfDateNaissance")).getValue());
strValeur = obtenirValeurCombo("cbPays");
personneSelectionnee.set("pays", strValeur);
strValeur = obtenirValeurCombo("cbRegion");
personneSelectionnee.set("region", strValeur);
personneSelectionnee.set("truk_telephone", ((HiddenField<String>) hmIdentite.get("hfTelephone")).getValue());
String logoUrls = ((HiddenField<String>) hmIdentite.get("hfUrlLogo")).getValue();
if (logoUrls == null) {
logoUrls = "";
}
personneSelectionnee.set("truk_logo", logoUrls);
personneSelectionnee.set("truk_url", ((HiddenField) hmIdentite.get("hfUrl")).getValue());
//if (lstMessageErreur.size() < 0) {
mediateur.enregistrerPersonne(this, personneSelectionnee);
/*} else {
String strMessagesErreur = "";
Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
while (itMessagesErreur.hasNext()) {
strMessagesErreur += " - " + itMessagesErreur.next() +" \n";
}
MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
}*/
}
private String obtenirValeurCombo(String strComboName) {
String strValeur = "";
Valeur valeur;
ComboBox combo = (ComboBox) hmIdentite.get(strComboName);
if (combo == null) {
combo = (ComboBox) hmAdresse.get(strComboName);
}
if (combo.getValue()!=null) {
valeur = (Valeur) combo.getValue();
strValeur = valeur.getId();
} else {
strValeur = combo.getRawValue();
}
return strValeur;
}
}