Rev 352 | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.client.vues;import java.util.ArrayList;import java.util.Collection;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.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.ContentPanel;import com.extjs.gxt.ui.client.widget.LayoutContainer;import com.extjs.gxt.ui.client.widget.MessageBox;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.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.FlowLayout;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.TextToolItem;import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;import com.google.gwt.i18n.client.DateTimeFormat;import com.google.gwt.user.client.Window;import com.google.gwt.user.client.ui.Widget;public class FormPersonneVue extends ContentPanel 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 = 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 FormPersonneVue() {initialiserComposants(null);}public FormPersonneVue(Personne personne) {initialiserComposants(personne);}public void initialiserComposants(Personne 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();rafraichir(personne);}/*---------------------------------------------------------------------------------------* SOUS-METHODES* --------------------------------------------------------------------------------------*//*** Inialise le panneau donné** @param contentPanel le panneau à initialiser* */public void initialiserPanneau() {setLayout(new FitLayout());setIconStyle("icone-form-ajouter");setCollapsible(false);setHeading("Ajouter une personne");setButtonAlign(HorizontalAlignment.CENTER);setLayout(new FormLayout());}/*** Crée les onglets identité, adresse et informations naturaliste** */public void initialiserOnglets() {//TabPanelTabPanel formulaireOnglets = new TabPanel();//Tab 1 : identitetiIdentite = new TabItem("Identité");tiIdentite.setLayout(new FormLayout());tiIdentite.setScrollMode(Scroll.AUTO);formulaireOnglets.add(tiIdentite);hmIdentite.put("tiIdentite", tiIdentite);//Tab 2 : AdressetiAdresses = new TabItem("Adresse");tiAdresses.setLayout(new FormLayout());tiAdresses.setScrollMode(Scroll.AUTO);formulaireOnglets.add(tiAdresses);//Tab 3 : Infos NaturalistestiInfosNat = 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 Identiteprivate 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// On crée 3 Layout container : un principal, un pour la colonne de gauche, un pour la colonne de droite// GaucheLayoutContainer left = new LayoutContainer();left.setLayout(new FormLayout());// DroiteLayoutContainer right = new LayoutContainer();right.setLayout(new FormLayout());// PrincipalLayoutContainer main = new LayoutContainer();main.setLayout(new ColumnLayout());// Ajout au principalmain.add(left, new ColumnData(.49));main.add(right, new ColumnData(.49));// Création des champs//FormLayout sera utilisé à plusieurs reprisesFormLayout formLayout = new FormLayout();FieldSet fsNoms = new FieldSet();fsNoms.setHeading("Noms");formLayout.setLabelAlign(LabelAlign.LEFT);fsNoms.setLayout(formLayout);// Nom complet// Affiché que si valeurs saisiesLabelField nomComplet = new LabelField();nomComplet.setFieldLabel("Nom complet:");nomComplet.hide();fsNoms.add(nomComplet);hmIdentite.put("nomComplet", nomComplet);//PréfixeComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();// Remplir la liste des préfixemediateur.obtenirListeValeurEtRafraichir(this, "prefixe");ListStore<Valeur> storePrefixe = new ListStore<Valeur>();cbPrefixe.setStore(storePrefixe);cbPrefixe.setDisplayField("nom");cbPrefixe.setEmptyText("Choisissez le préfixe:");cbPrefixe.setFieldLabel("Prefix");fsNoms.add(cbPrefixe);hmIdentite.put("cbPrefixe", cbPrefixe);//PrénomTextField<String> tfPrenom = new TextField<String>();tfPrenom.setFieldLabel("Prénom");fsNoms.add(tfPrenom);hmIdentite.put("tfPrenom", tfPrenom);//NomTextField<String> tfNom = new TextField<String>();tfNom.setFieldLabel("Nom");fsNoms.add(tfNom);hmIdentite.put("tfNom", tfNom);//SuffixeComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();cbSuffixe.setStore(storeSuffixe);cbSuffixe.setFieldLabel("Suffixe");cbSuffixe.setDisplayField("nom");cbSuffixe.setEmptyText("Choisissez un suffixe:");fsNoms.add(cbSuffixe);hmIdentite.put("cbSuffixe", cbSuffixe);// Remplir la liste des suffixes:mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");// Nom : autreTextField<String> tfNomAutre = new TextField();tfNomAutre.setFieldLabel("Autres noms");fsNoms.add(tfNomAutre);hmIdentite.put("tfNomAutre", tfNomAutre);//AbréviationTextField<String> tfAbreviation = new TextField<String>();tfAbreviation.setFieldLabel("Abréviation");fsNoms.add(tfAbreviation);hmIdentite.put("tfAbreviation", tfAbreviation);//Abréviation autresTextField<String> tfAbreviationAutre = new TextField<String>();tfAbreviationAutre.setFieldLabel("Autres Abrév.");fsNoms.add(tfAbreviationAutre);hmIdentite.put("tfAbreviationAutre", tfAbreviationAutre);left.add(fsNoms);// NaissanceFieldSet fsNaissance = new FieldSet();fsNaissance.setHeading("Naissance");formLayout = new FormLayout();formLayout.setLabelAlign(LabelAlign.LEFT);fsNaissance.setLayout(formLayout);// Date naissanceDateField dfDateNaissance = new DateField();dfDateNaissance.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));dfDateNaissance.setFieldLabel("Date");fsNaissance.add(dfDateNaissance);hmIdentite.put("dfDateNaissance", dfDateNaissance);// Lieu naissanceTextField<String> tfLieuNaissance = new TextField();tfLieuNaissance.setFieldLabel("Lieu");fsNaissance.add(tfLieuNaissance);hmIdentite.put("tfLieuNaissance", tfLieuNaissance);left.add(fsNaissance);// DecesFieldSet fsDeces = new FieldSet();fsDeces.setHeading("Décès");formLayout = new FormLayout();formLayout.setLabelAlign(LabelAlign.LEFT);fsDeces.setLayout(formLayout);// Date décèsDateField 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);// Lieu décèsTextField<String> tfLieuDeces = new TextField();tfLieuDeces.setFieldLabel("Lieu");fsDeces.add(tfLieuDeces);hmIdentite.put("tfLieuDeces", tfLieuDeces);left.add(fsDeces);tiIdentite.add(main);// Contact - TéléphoneFieldSet fsContactTel = new FieldSet();fsContactTel.setHeading("Contact - Téléphones");fsContactTel.setLayout(new RowLayout());hmIdentite.put("fsContactTel", fsContactTel);right.add(fsContactTel);//TéléphoneLayoutContainer 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);//Type de téléphoneComboBox<Valeur> cbTelephone = new ComboBox<Valeur>();cbTelephone.setDisplayField("nom");cbTelephone.setEmptyText("Choisissez:");ListStore<Valeur> storeTel = new ListStore<Valeur>();cbTelephone.setStore(storeTel);lcTelephone.add(cbTelephone, new ColumnData(0.40));hmIdentite.put("cbTelephone", cbTelephone);mediateur.obtenirListeValeurEtRafraichir(this, "tel");// Bouton ajouterIconButton bAjouter = new IconButton(ComposantClass.ICONE_AJOUTER);// Evenement boutonbAjouter.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 = "";Valeur valeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getValue();if (valeurTypeTel != null) {strValeurTypeTel = valeurTypeTel.getNom();} else {strValeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getRawValue();}if (strValeurTypeTel.trim().equals("")) {MessageBox.alert("Erreur de saisie", "Vous devez saisir un type de téléphone", null);} else {ajouterTelephone(strTelephone, strValeurTypeTel);}}}});lcTelephone.add(bAjouter, new ColumnData(0.15));fsContactTel.add(lcTelephone);//Contact - autresFieldSet fsContact = new FieldSet();fsContact.setHeading("Contact - Autres");fsContact.setId("fsContact");fsContact.setLayout(new RowLayout());right.add(fsContact);// CourrielsLabelField lfCourriel = new LabelField();lfCourriel.setFieldLabel("Courriel:");lfCourriel.setText("<b>Courriels:</b>");fsContact.add(lfCourriel);LayoutContainer lcCourriel = new LayoutContainer();ColumnLayout clLayout = new ColumnLayout();lcCourriel.setLayout(clLayout);TextField tfCourriel = new TextField();lcCourriel.add(tfCourriel, new ColumnData(0.80));// Bouton ajouterIconButton bAjouterCourriel = new IconButton(ComposantClass.ICONE_AJOUTER);lcCourriel.add(bAjouterCourriel, new ColumnData(0.15));fsContact.add(lcCourriel);TextArea taCourriel = new TextArea();taCourriel.setFieldLabel("Courriels");taCourriel.setEmptyText("Saisissez les adresses courriels séparées par un saut de ligne");//fsContact.add(taCourriel, fd100);hmIdentite.put("taCourriel", taCourriel);// URLSTextArea taUrl = new TextArea();taUrl.setFieldLabel("Sites");taUrl.setWidth("100%");taUrl.setEmptyText("Saisissez les adresses des sites séparées par un saut de ligne");//fsContact.add(taUrl, fd100);hmIdentite.put("taUrl", taUrl);// Autres informationsFieldSet fsAutresInfos = new FieldSet();fsAutresInfos.setHeading("Autres informations");formLayout = new FormLayout();formLayout.setLabelAlign(LabelAlign.LEFT);fsAutresInfos.setLayout(formLayout);right.add(fsAutresInfos);//CivilitéComboBox<Valeur> cbSexe = new ComboBox<Valeur>();ListStore<Valeur> storeSexe = new ListStore<Valeur>();cbSexe.setStore(storeSexe);cbSexe.setFieldLabel("Sexe");cbSexe.setDisplayField("nom");cbSexe.setEmptyText("Choisissez le sexe:");fsAutresInfos.add(cbSexe, fd100);hmIdentite.put("cbSexe", cbSexe);mediateur.obtenirListeValeurEtRafraichir(this, "sexe");//DescriptionTextArea taDescription = new TextArea();taDescription.setEmptyText("Saisissez une description");taDescription.setFieldLabel("Description");taDescription.setWidth("100%");fsAutresInfos.add(taDescription, fd100);hmIdentite.put("taDescription", taDescription);// LogoTextArea 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);// Ajout des évènements saisiKeyListener 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() {// GaucheLayoutContainer left = new LayoutContainer();left.setLayout(new FormLayout());// DroiteLayoutContainer right = new LayoutContainer();right.setLayout(new FormLayout());// PrincipalLayoutContainer main = new LayoutContainer();main.setLayout(new ColumnLayout());// Ajout au principalmain.add(left, new ColumnData(.49));main.add(right, new ColumnData(.49));TextField<String> tfAdresse1 = new TextField();tfAdresse1.setFieldLabel("Adresse");left.add(tfAdresse1, fd100);hmAdresse.put("tfAdresse1", tfAdresse1);TextField<String> tfAdresse2 = new TextField();tfAdresse2.setFieldLabel("Complément d'adresse");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");left.add(tfBoitePostale, fd100);hmAdresse.put("tfBoitePostale", tfBoitePostale);TextField<Integer> tfCodePostal = new TextField<Integer>();tfCodePostal.setFieldLabel("Code postal");right.add(tfCodePostal, fd100);hmAdresse.put("tfCodePostal", tfCodePostal);TextField tfVille = new TextField();tfVille.setFieldLabel("Ville");right.add(tfVille, fd100);hmAdresse.put("tfVille", tfVille);// MAJ ComboBoxmediateur.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 static void ajouterBoutonReinitialiser(ToolBar barreOutils) {//Le bouton réintialiser recharge la page sans sauvegarder les informationsTextToolItem 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();}});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 informationsButton 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 static void ajouterBoutonEnregistrer(ButtonBar barreOutils) {//Le bouton réintialiser recharge la page sans sauvegarder les informationsButton enregistrer = new Button("Enregistrer");enregistrer.setIconStyle(ComposantClass.ICONE_PREFERENCE);enregistrer.setId("main-button");enregistrer.addSelectionListener(new SelectionListener<ComponentEvent>() {public void componentSelected(ComponentEvent ce) {// TODO : Enregistrer le formulaire}});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édenteButton 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 valeursList<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élComboBox<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.getDonnee(0) instanceof PersonneListe) {Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();Iterator itPersonneListe = colPersonneListe.iterator();Personne personne = (Personne) itPersonneListe.next();//Mise à jour de la personne//Personne personne = (Personne) nouvellesDonnees;personneSelectionnee = personne;//PrefixeString 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("nom", prefixeCourant) != null) {cbPrefixe.setValue(cbPrefixe.getStore().findModel("nom", prefixeCourant));} else {cbPrefixe.setRawValue(prefixeCourant);}((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom"));((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom"));//SuffixeString 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("nom", suffixeCourant) != null) {cbSuffixe.setValue(cbSuffixe.getStore().findModel("nom", 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"));// TelephoneHashMap<String, String> hmTelephone = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_telephone");Collection<String> colTelephone = hmTelephone.keySet();Iterator<String> itTelephone = colTelephone.iterator();while (itTelephone.hasNext()) {String strTelephone = itTelephone.next();String strTypeTelephone = hmTelephone.get(strTelephone);ajouterTelephone(strTelephone, strTypeTelephone);}//CourrielTextArea taCourriels = (TextArea) hmIdentite.get("taCourriel");LinkedList<String> lCourriels = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_courriel");Iterator<String> itCourriels = lCourriels.iterator();String strValeurCourriel = "";while (itCourriels.hasNext()) {strValeurCourriel += itCourriels.next() + "\n";}if (!strValeurCourriel.trim().equals("")) {taCourriels.setRawValue(strValeurCourriel);}// SitesTextArea taUrl = (TextArea) hmIdentite.get("taUrl");LinkedList<String> lUrl = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_url");Iterator<String> itUrl = lUrl.iterator();String strValeurUrl = "";while (itUrl.hasNext()) {strValeurUrl += itUrl.next() + "\n";}if (!strValeurUrl.trim().equals("")) {taUrl.setRawValue(strValeurUrl);}// SexeString strSexe = personne.get("ce_sexe");ComboBox<Valeur> cbSexe = (ComboBox<Valeur>) hmIdentite.get("cbSexe");//FIXME : le lien avec la bdd ne peut pas se faireif (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"));// LogosTextArea taLogo = (TextArea) hmIdentite.get("taLogo");LinkedList<String> lLogo = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_logo");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"));//PaysString 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égionString 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"));}}if (nouvellesDonnees == null){ComboBox cb= (ComboBox) hmIdentite.get("cbPrefixe");//Met à jour le nom Complet du formulaireString valeurRetour = "";// PrefixeString prefixe = "";Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefixe")).getValue();if (valPrefixe != null) {prefixe = valPrefixe.getNom();} else {prefixe = (String) ((ComboBox) hmIdentite.get("cbPrefixe")).getRawValue();}// PrénomString prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();// NomString nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();// SuffixeString 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 valeurvaleurRetour = 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) {//Ajout d'un champ à la listeHiddenField<String> hfTelephone = new HiddenField<String>();hfTelephone.setId("hidden-" + strTelephone);hfTelephone.setFieldLabel(strValeurTypeTel);hfTelephone.setValue(strTelephone);hmIdentite.put("hidden-" + strTelephone, hfTelephone);FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");LayoutContainer lcTelephone = new LayoutContainer();lcTelephone.setLayout(new ColumnLayout());Text tTypeTelephone = new Text();tTypeTelephone.setText(strValeurTypeTel+":");hmIdentite.put("type-" + strTelephone, tTypeTelephone);lcTelephone.add(tTypeTelephone, new ColumnData(0.40));Text tTelephone = new Text();tTelephone.setText(strTelephone);hmIdentite.put("tel-" + strTelephone, tTelephone);lcTelephone.add(tTelephone, new ColumnData(0.40));IconButton bSupprimer = new IconButton(ComposantClass.ICONE_SUPPRIMER);bSupprimer.setId(strTelephone);bSupprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {public void componentSelected(ComponentEvent ce) {String strTelephone = ce.component.getId();LayoutContainer lcContactTel = (LayoutContainer) hmIdentite.get("lc-"+strTelephone);lcContactTel.remove(hmIdentite.get("type-" + strTelephone));hmIdentite.remove("type-" + strTelephone);lcContactTel.remove(hmIdentite.get("tel-" + strTelephone));hmIdentite.remove("tel-" + strTelephone);((TabItem) hmIdentite.get("tiIdentite")).remove(hmIdentite.get("hidden-" + strTelephone));hmIdentite.remove("hidden-" + strTelephone);lcContactTel.remove(ce.component);FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");fsContactTel.remove(lcContactTel);layout();}});lcTelephone.add(bSupprimer, new ColumnData(0.15));hmIdentite.put("lc-"+strTelephone, lcTelephone);fsContactTel.add(lcTelephone);((TabItem) hmIdentite.get("tiIdentite")).add(hfTelephone);layout();}}