Subversion Repositories eFlore/Applications.coel

Compare Revisions

Regard whitespace Rev 729 → Rev 730

/trunk/src/org/tela_botanica/client/vues/PersonneForm.java
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;
103,21 → 96,10
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);
543,7 → 515,6
}
public void creerComposantsAdresse() {
// Gauche
LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout());
587,7 → 558,6
public void selectionChanged(SelectionChangedEvent se) {
// Rafraichir avec le pays sélectionné
obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
}
};
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,67 → 709,43
}
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();
862,35 → 798,6
(((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
939,7 → 846,6
cbPays.setRawValue(strPays);
}
//Région
String strRegion = personne.get("region");
if ((strRegion!=null)&&(!strRegion.equals(""))) {
959,7 → 865,6
//Ville
((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville"));
gererEtatActivationBouton();
nouvellesDonnees = null;
968,8 → 873,7
}
}
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,12 → 962,8
mediateur.masquerPopinChargement();
}
public void binderPersonne(Personne personne) {
binding = new FormBinding(this);
personneSelectionnee = personne;
binding.autoBind();
binding.bind(personneSelectionnee);
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;