1,8 → 1,10 |
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; |
12,7 → 14,9 |
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; |
|
38,6 → 42,7 |
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; |
52,6 → 57,7 |
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; |
|
|
82,25 → 88,40 |
* */ |
public FormPersonneVue() { |
|
initialiserComposants(null); |
|
} |
|
public FormPersonneVue(Personne personne) { |
|
initialiserComposants(personne); |
} |
|
public void initialiserComposants(Personne personne) { |
|
initialiserPanneau(); |
|
ToolBar barreOutils = new ToolBar(); |
ToolBar barreOutilsBas = new ToolBar(); |
|
ajouterBoutonEnregistrer(barreOutils); |
ajouterBoutonEnregistrerEtRevenir(barreOutils); |
ajouterBoutonReinitialiser(barreOutils); |
ajouterBoutonAnnuler(barreOutils); |
ajouterBoutonEnregistrer(barreOutilsBas); |
ajouterBoutonEnregistrerEtRevenir(barreOutilsBas); |
ajouterBoutonAnnuler(barreOutilsBas); |
|
setBottomComponent(barreOutilsBas); |
|
setBottomComponent(barreOutils); |
ToolBar barreOutilsHaut = new ToolBar(); |
ajouterBoutonReinitialiser(barreOutilsHaut); |
setTopComponent(barreOutilsHaut); |
|
|
initialiserOnglets(); |
|
creerComposantsIdentite(); |
creerComposantsAdresse(); |
|
layout(); |
|
|
rafraichir(personne); |
} |
|
|
208,8 → 229,15 |
|
hmIdentite.put("nomComplet", nomComplet); |
|
|
|
//Préfixe |
ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>(); |
|
// Remplir la liste des préfixe |
mediateur.obtenirListeValeurEtRafraichir(this, "prefixe"); |
|
|
ListStore<Valeur> storePrefixe = new ListStore<Valeur>(); |
cbPrefixe.setStore(storePrefixe); |
cbPrefixe.setDisplayField("nom"); |
219,9 → 247,8 |
|
hmIdentite.put("cbPrefixe", cbPrefixe); |
|
// Remplir la liste des préfixe |
mediateur.obtenirListeValeurEtRafraichir(this, "prefixe"); |
|
|
//Prénom |
TextField<String> tfPrenom = new TextField<String>(); |
tfPrenom.setFieldLabel("Prénom"); |
367,7 → 394,7 |
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); |
388,62 → 415,9 |
if (strValeurTypeTel.trim().equals("")) { |
MessageBox.alert("Erreur de saisie", "Vous devez saisir un type de téléphone", null); |
} else { |
|
//Ajout d'un champ à la liste |
HiddenField<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"); |
|
Text tTypeTelephone = new Text(); |
tTypeTelephone.setText(strValeurTypeTel+":"); |
|
hmIdentite.put("type-" + strTelephone, tTypeTelephone); |
fsContactTel.add(tTypeTelephone); |
|
Text tTelephone = new Text(); |
tTelephone.setText(strTelephone); |
hmIdentite.put("tel-" + strTelephone, tTelephone); |
fsContactTel.add(tTelephone); |
|
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(); |
FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel"); |
|
fsContactTel.remove(hmIdentite.get("type-" + strTelephone)); |
hmIdentite.remove("type-" + strTelephone); |
|
fsContactTel.remove(hmIdentite.get("tel-" + strTelephone)); |
hmIdentite.remove("tel-" + strTelephone); |
|
((TabItem) hmIdentite.get("tiIdentite")).remove(hmIdentite.get("hidden-" + strTelephone)); |
hmIdentite.remove("hidden-" + strTelephone); |
|
fsContactTel.remove(ce.component); |
|
layout(); |
|
} |
}); |
|
fsContactTel.add(bSupprimer); |
|
((TabItem) hmIdentite.get("tiIdentite")).add(hfTelephone); |
|
layout(); |
ajouterTelephone(strTelephone, strValeurTypeTel); |
} |
|
} |
|
|
} |
} |
); |
605,6 → 579,7 |
ListStore<Valeur> storeRegion = new ListStore<Valeur>(); |
cbRegion.setStore(storeRegion); |
|
|
right.add(cbRegion, fd100); |
hmAdresse.put("cbRegion", cbRegion); |
|
633,6 → 608,9 |
|
tiAdresses.add(fsAdresse); |
|
((ComboBox) hmIdentite.get("cbPrefixe")).setRawValue("ljkhlkj"); |
|
|
} |
|
/** |
643,7 → 621,7 |
public static void ajouterBoutonReinitialiser(ToolBar barreOutils) { |
|
//Le bouton réintialiser recharge la page sans sauvegarder les informations |
TextToolItem reinitialiser = new TextToolItem("Réinitialiser"); |
TextToolItem reinitialiser = new TextToolItem("Réinitialiser le formulaire"); |
reinitialiser.setIconStyle(ComposantClass.ICONE_RAFRAICHIR); |
reinitialiser.addSelectionListener(new SelectionListener<ComponentEvent>() { |
public void componentSelected(ComponentEvent ce) { |
681,6 → 659,7 |
//Le bouton réintialiser recharge la page sans sauvegarder les informations |
TextToolItem enregistrer = new TextToolItem("Enregistrer"); |
enregistrer.setIconStyle(ComposantClass.ICONE_PREFERENCE); |
enregistrer.setId("main-button"); |
enregistrer.addSelectionListener(new SelectionListener<ComponentEvent>() { |
public void componentSelected(ComponentEvent ce) { |
// TODO : Enregistrer le formulaire |
761,35 → 740,169 |
} |
|
|
} else if (nouvellesDonnees instanceof Personne) { |
|
} else if (nouvellesDonnees instanceof Information) { |
|
Information info = (Information) nouvellesDonnees; |
|
//Mise à jour de la personne |
Personne personne = (Personne) nouvellesDonnees; |
personneSelectionnee = personne; |
if (info.getDonnee(0) instanceof PersonneListe) { |
|
|
//Prefixe |
String prefixe = (String) personne.get("ce_truk_prefix"); |
ComboBox<Valeur> cbPrefixe = (ComboBox<Valeur>) hmIdentite.get("cbPrefixe"); |
cbPrefixe.setRawValue(prefixe); |
|
((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom")); |
((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom")); |
((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")); |
|
//FIXME : DATES |
DateField dfDateNaissance = ((DateField) hmIdentite.get("dfDateNaissance")); |
String strDateNaissance = (String) personne.get("naissance_date"); |
|
|
((TextField) hmIdentite.get("tfLieuNaissance")).setValue(personne.get("naissance_lieu")); |
//((DateField) hmIdentite.get("dfDateDeces")).setValue(new Date((String) personne.get("deces_date"))); |
((TextField) hmIdentite.get("tfLieuDeces")).setValue(personne.get("deces_lieu")); |
|
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; |
|
//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("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")); |
|
//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("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")); |
|
// Telephone |
HashMap<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); |
} |
|
//Courriel |
TextArea 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); |
} |
|
// Sites |
TextArea 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); |
} |
|
// 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"); |
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")); |
} |
} |
|
if (nouvellesDonnees == null) |
842,8 → 955,9 |
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; |
859,6 → 973,66 |
((ComboBox) hm.get(idComboBox)).setStore(store); |
} |
|
|
public void ajouterTelephone(String strTelephone, String strValeurTypeTel) { |
|
|
//Ajout d'un champ à la liste |
HiddenField<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"); |
|
Text tTypeTelephone = new Text(); |
tTypeTelephone.setText(strValeurTypeTel+":"); |
|
hmIdentite.put("type-" + strTelephone, tTypeTelephone); |
fsContactTel.add(tTypeTelephone); |
|
Text tTelephone = new Text(); |
tTelephone.setText(strTelephone); |
hmIdentite.put("tel-" + strTelephone, tTelephone); |
fsContactTel.add(tTelephone); |
|
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(); |
FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel"); |
|
fsContactTel.remove(hmIdentite.get("type-" + strTelephone)); |
hmIdentite.remove("type-" + strTelephone); |
|
fsContactTel.remove(hmIdentite.get("tel-" + strTelephone)); |
hmIdentite.remove("tel-" + strTelephone); |
|
((TabItem) hmIdentite.get("tiIdentite")).remove(hmIdentite.get("hidden-" + strTelephone)); |
hmIdentite.remove("hidden-" + strTelephone); |
|
fsContactTel.remove(ce.component); |
|
layout(); |
|
} |
}); |
|
fsContactTel.add(bSupprimer); |
|
((TabItem) hmIdentite.get("tiIdentite")).add(hfTelephone); |
|
layout(); |
|
|
|
|
} |
|
|
|
} |