39,7 → 39,6 |
|
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.IconButtonEvent; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
52,7 → 51,6 |
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; |
60,7 → 58,6 |
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.Radio; |
import com.extjs.gxt.ui.client.widget.form.RadioGroup; |
76,16 → 73,11 |
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.Image; |
import com.google.gwt.user.client.ui.Widget; |
|
public class PersonneForm extends FormPanel implements Rafraichissable { |
|
/*-------------------------------------------------------------------------------------- |
* VARIABLES |
* ------------------------------------------------------------------------------------- |
*/ |
|
// VARIABLES |
private TabItem tiIdentite, tiAdresses, tiInfosNat; |
private Mediateur mediateur = Registry.get(RegistreId.MEDIATEUR); |
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG); |
96,6 → 88,7 |
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 HashMap<String, Valeur> hmCbSelectionnee = new HashMap(); |
private FormData fd100 = new FormData("1"); |
|
private Button enregistrer, enregistrerEtRevenir; |
102,22 → 95,11 |
|
public static final String MODE_AJOUTER = "AJOUT"; |
public static final String MODE_MODIFIER = "MODIF"; |
|
|
|
private FormBinding binding = null; |
|
/*-------------------------------------------------------------------------------------- |
* CONSTRUCTEUR |
* ------------------------------------------------------------------------------------- |
*/ |
// 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(String mode) { |
this.mode = mode; |
initialiserComposants(); |
124,7 → 106,6 |
} |
|
public void initialiserComposants() { |
|
personneSelectionnee = new Personne(); |
personneSauvegarde = new Personne(); |
|
155,17 → 136,9 |
binderPersonne(personneSelectionnee); |
} |
|
/*--------------------------------------------------------------------------------------- |
* SOUS-METHODES |
* -------------------------------------------------------------------------------------- |
*/ |
/** |
* Inialise le panneau donné |
* |
* @param contentPanel le panneau à initialiser |
* */ |
// SOUS-METHODES |
|
public void initialiserPanneau() { |
|
setCollapsible(false); |
if (this.mode.equals(MODE_AJOUTER)) { |
setHeading(mediateur.i18nC.personneModeAjout()); |
222,7 → 195,6 |
|
|
public void creerComposantsIdentite() { |
|
// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
319,7 → 291,7 |
|
mediateur.obtenirListeValeurEtRafraichir(this, "suffixes"); |
|
TextField<String> tfNomAutre = new TextField(); |
TextField<String> tfNomAutre = new TextField<String>(); |
tfNomAutre.setFieldLabel("Autres noms"); |
tfNomAutre.setName("truk_nom_autre"); |
|
359,7 → 331,7 |
hmIdentite.put("dfDateNaissance", dfDateNaissance); |
|
// Lieu naissance |
TextField<String> tfLieuNaissance = new TextField(); |
TextField<String> tfLieuNaissance = new TextField<String>(); |
tfLieuNaissance.setFieldLabel("Lieu"); |
tfLieuNaissance.setName("naissance_lieu"); |
|
414,7 → 386,7 |
fsDeces.add(dfDateDeces); |
hmIdentite.put("dfDateDeces", dfDateDeces); |
|
TextField<String> tfLieuDeces = new TextField(); |
TextField<String> tfLieuDeces = new TextField<String>(); |
tfLieuDeces.setFieldLabel("Lieu"); |
tfLieuDeces.setName("deces_lieu"); |
tfLieuDeces.setVisible(false); |
530,8 → 502,8 |
|
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() { |
public void selectionChanged(SelectionChangedEvent se) { |
rafraichir(null); |
} |
rafraichir(null); |
} |
}; |
|
cbPrefixe.addSelectionChangedListener(selectionChange); |
543,7 → 515,6 |
} |
|
public void creerComposantsAdresse() { |
|
// Gauche |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
585,10 → 556,9 |
|
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() { |
public void selectionChanged(SelectionChangedEvent se) { |
// Rafraichir avec le pays sélectionné |
obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString()); |
|
} |
// Rafraichir avec le pays sélectionné |
obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString()); |
} |
}; |
|
cbPays.addSelectionChangedListener(selectionChange); |
689,7 → 659,6 |
* @param barreOutils la barre d'outils à modifier |
* */ |
private void ajouterBoutonEnregistrer(ButtonBar barreOutils) { |
|
//Le bouton réintialiser recharge la page sans sauvegarder les informations |
enregistrer = new Button("Enregistrer"); |
enregistrer.setIcon(Images.ICONES.scriptSave()); |
727,19 → 696,10 |
mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays); |
} |
|
|
|
/*--------------------------------------------------------------------------------------- |
* RAFRAICHISSEMENT DU PANNEAU |
* -------------------------------------------------------------------------------------- |
*/ |
// RAFRAICHISSEMENT DU PANNEAU |
|
public void rafraichir(Object nouvellesDonnees) { |
|
|
|
if (nouvellesDonnees instanceof ValeurListe) { |
|
|
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
|
// Créer une liste de valeurs |
749,227 → 709,171 |
} |
|
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); |
((ComboBox<Valeur>) hmAdresse.get("cbRegion")).setVisible(true); |
} |
|
|
} else if (nouvellesDonnees instanceof ProjetListe) { |
|
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
List<Projet> liste = projets.toList(); |
|
List<Projet> liste = new ArrayList<Projet>(); |
for (Iterator<String> it = projets.keySet().iterator(); it.hasNext();) { |
liste.add(projets.get(it.next())); |
} |
ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets"); |
ComboBox<Projet> cbProjets = (ComboBox<Projet>) hmIdentite.get("cbProjets"); |
ListStore<Projet> storeProjets= cbProjets.getStore(); |
storeProjets.removeAll(); |
storeProjets.add(liste); |
cbProjets.setStore(storeProjets); |
|
} else if (nouvellesDonnees instanceof Information) { |
|
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("ajout_personne")) { |
|
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null); |
Info.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")"); |
|
} 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("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(); |
|
personneSauvegarde = new Personne(); |
personneSauvegarde = (Personne) personne.cloner(personneSauvegarde); |
|
binderPersonne(personne); |
//Mise à jour de la personne |
//Personne personne = (Personne) nouvellesDonnees; |
|
ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets"); |
cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet"))); |
|
//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 strTelephone = itTelephone.next(); |
String strTypeTelephone = hmTelephone.get(strTelephone); |
String idTel = hmTel.get(strTypeTelephone); |
if (idTel == null) { |
idTel = strTypeTelephone; |
} |
|
ajouterTelephone(strTelephone, idTel, strTypeTelephone); |
} |
}*/ |
|
((ChampMultiValeursMultiTypes) hmIdentite.get("telephones")).peupler(personne.getString("truk_telephone")); |
|
//Courriel |
((ChampMultiValeurs) hmIdentite.get("courriels")).peupler(personne.getCourriel()); |
|
//Sites web |
((ChampMultiValeurs) hmIdentite.get("sites")).peupler(personne.getString("truk_url")); |
|
|
// Sexe |
String strSexe = personne.get("ce_sexe"); |
ComboBox<Valeur> cbSexe = (ComboBox<Valeur>) hmIdentite.get("cbSexe"); |
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; |
|
ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets"); |
cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet"))); |
|
//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")); |
|
((ChampMultiValeursMultiTypes) hmIdentite.get("telephones")).peupler(personne.getString("truk_telephone")); |
|
//Courriel |
((ChampMultiValeurs) hmIdentite.get("courriels")).peupler(personne.getCourriel()); |
|
//Sites web |
((ChampMultiValeurs) hmIdentite.get("sites")).peupler(personne.getString("truk_url")); |
|
|
// Sexe |
String strSexe = personne.get("ce_sexe"); |
ComboBox<Valeur> cbSexe = (ComboBox<Valeur>) hmIdentite.get("cbSexe"); |
|
if (cbSexe.getStore().findModel("id_valeur", strSexe) != null) { |
cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe)); |
} else { |
cbSexe.setRawValue(strSexe); |
} |
if (cbSexe.getStore().findModel("id_valeur", strSexe) != null) { |
cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe)); |
} else { |
cbSexe.setRawValue(strSexe); |
} |
|
((TextArea) hmIdentite.get("taDescription")).setRawValue((String) personne.get("description")); |
|
//Logo |
((ChampMultiValeurs) hmIdentite.get("logos")).peupler(personne.getString("truk_logo")); |
|
/*-------------------------------------------------- |
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); |
|
((TextArea) hmIdentite.get("taDescription")).setRawValue((String) personne.get("description")); |
|
//Logo |
((ChampMultiValeurs) hmIdentite.get("logos")).peupler(personne.getString("truk_logo")); |
|
/*-------------------------------------------------- |
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)); |
if (cbRegion.getStore().findModel("nom", strRegion) != null) { |
cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion)); |
} else { |
cbPays.setRawValue(strPays); |
cbRegion.setRawValue(strRegion); |
} |
|
|
//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")); |
|
|
gererEtatActivationBouton(); |
|
nouvellesDonnees = null; |
} else { |
Info.display("messages", info.getMessages().toString()); |
} |
|
//Cp |
((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal")); |
|
//Ville |
((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville")); |
|
gererEtatActivationBouton(); |
|
nouvellesDonnees = null; |
} else { |
Info.display("messages", info.getMessages().toString()); |
} |
} |
|
if (nouvellesDonnees == null) |
{ |
if (nouvellesDonnees == null) { |
ComboBox cb= (ComboBox) hmIdentite.get("cbPrefixe"); |
|
//Met à jour le nom Complet du formulaire |
985,7 → 889,6 |
prefixe = (String) ((ComboBox) hmIdentite.get("cbPrefixe")).getRawValue(); |
} |
|
|
// Prénom |
String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue(); |
|
1022,9 → 925,8 |
} |
} |
|
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; |
1039,12 → 941,9 |
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); |
1052,11 → 951,9 |
enregistrer.setEnabled(true); |
enregistrerEtRevenir.setEnabled(true); |
} |
|
} |
|
public void reinitialiser() { |
|
mediateur.afficherPopinChargement(); |
|
binderPersonne(personneSauvegarde); |
1065,11 → 962,7 |
mediateur.masquerPopinChargement(); |
} |
|
|
|
public void binderPersonne(Personne personne) { |
|
binding = new FormBinding(this); |
|
personneSelectionnee = personne; |
binding.autoBind(); |
1083,7 → 976,6 |
* |
*/ |
public boolean enregistrer() { |
|
boolean success = false; |
LinkedList lstMessageErreur = new LinkedList<String>(); |
|
1197,7 → 1089,6 |
} |
|
private String obtenirValeurCombo(String strComboName) { |
|
String strValeur = ""; |
Valeur valeur; |
|