Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 975 → Rev 976

/trunk/src/org/tela_botanica/client/vues/personne/PersonneForm.java
16,7 → 16,6
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
import org.tela_botanica.client.composants.HashMapComposants;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import org.tela_botanica.client.modeles.Information;
33,11 → 32,9
 
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
 
import com.extjs.gxt.ui.client.binding.FieldBinding;
import com.extjs.gxt.ui.client.binding.FormBinding;
 
import com.extjs.gxt.ui.client.event.ButtonEvent;
77,7 → 74,6
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
 
public class PersonneForm extends Formulaire implements Rafraichissable {
89,7 → 85,7
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
private HashMapComposants hmIdentite = new HashMapComposants();
private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
private HashMapComposants hmAdresse = new HashMapComposants();
private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
private FormData fd100 = new FormData("95%");
609,7 → 605,8
fsInfosNat.add(specialite);
hmInfosNat.put("specialite", specialite);
ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte());
ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte(), 200, 200);
recolte.initialiserType("pays");
hmInfosNat.put("recolte", recolte);
617,55 → 614,7
tiInfosNat.add(fsInfosNat);
}
/**
* Ajouter le bouton Sauvegarder et revenir à la liste à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
* */
private void ajouterBoutonEnregistrerEtRevenir(ButtonBar barreOutils) {
//Le bouton réintialiser recharge la page sans sauvegarder les informations
enregistrerEtRevenir = new Button("Enregistrer et revenir à la liste");
enregistrerEtRevenir.setIcon(Images.ICONES.scriptGo());
enregistrerEtRevenir.setIconAlign(IconAlign.LEFT);
enregistrerEtRevenir.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
if (enregistrer() == true) {
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
}
}
});
hmIdentite.put("btnEnregistrerRevenir", enregistrerEtRevenir);
barreOutils.add(enregistrerEtRevenir);
enregistrerEtRevenir.setEnabled(false);
}
/**
* Ajouter le bouton Sauvegarder à la barre d'outils donnée
*
* @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());
enregistrer.setIconAlign(IconAlign.LEFT);
enregistrer.setId("main-button");
enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
enregistrer();
}
});
enregistrer.setEnabled(false);
hmIdentite.put("btnEnregistrer", enregistrer);
barreOutils.add(enregistrer);
}
/**
* Ajouter le bouton annuler à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
716,7 → 665,7
remplirCombobox("cbPays", liste, "hmAdresse");
} else if (listeValeurs.getId().equals(config.getListeId("region"))) {
remplirCombobox("cbRegion", liste, "hmAdresse");
((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
hmAdresse.getComboBox("cbRegion").setVisible(true);
}
} else if (nouvellesDonnees instanceof ProjetListe) {
ProjetListe projets = (ProjetListe) nouvellesDonnees;
909,19 → 858,18
---------------------------------------------------*/
// Adresse
((TextField<String>) hmAdresse.get("tfAdresse1")).setValue((String) personne.get("adresse_01"));
hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
 
// Complément
((TextField<String>) hmAdresse.get("tfAdresse2")).setValue((String) personne.get("adresse_02"));
hmAdresse.getTextField("tfAdresse2").setValue((String) personne.get("adresse_02"));
//Boite postale
((TextField<String>) hmAdresse.get("tfBoitePostale")).setValue((String) personne.get("bp"));
hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
//Pays
String strPays = personne.get("pays");
ComboBox<Valeur> cbPays = (ComboBox<Valeur>) hmAdresse.get("cbPays");
ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
if (cbPays.getStore().findModel("nom", strPays) != null) {
cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
} else {
931,7 → 879,7
//Région
String strRegion = personne.get("region");
if ((strRegion!=null)&&(!strRegion.equals(""))) {
ComboBox<Valeur> cbRegion = (ComboBox<Valeur>) hmAdresse.get("cbRegion");
ComboBox<Valeur> cbRegion = hmAdresse.getComboBoxValeur("cbRegion");
cbRegion.setVisible(true);
if (cbRegion.getStore().findModel("nom", strRegion) != null) {
942,10 → 890,10
}
//Cp
((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal"));
hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
//Ville
((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville"));
hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
/*--------------------------------------------------------
* Infos naturalistes
952,7 → 900,8
* -----------------------------------------------------*/
((ChampMultiValeurs) hmInfosNat.get("specialite")).peupler(personne.getString("ce_truk_specialite"));
((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).peupler(personne.getString("truk_recolte"));
String tr = personne.getString("truk_recolte");
((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).peupler(tr);
gererEtatActivationBouton();
}
998,134 → 947,7
binding.bind(personneSelectionnee);
layout();
}
 
/**
* Enregistre les information de la personne en cours
*
*/
public boolean enregistrer() {
boolean success = false;
LinkedList lstMessageErreur = new LinkedList<String>();
ComboBox<Projet> cbProjets = hmIdentite.getComboBox("cbProjets");
Projet projet = cbProjets.getValue();
if (projet == null) {
lstMessageErreur.add("Le projet n'a pas été renseigné");
} else {
personneSelectionnee.set("ce_projet", projet.getId());
}
String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
if ((strTfNom == null)||(strTfNom.trim().equals(""))) {
lstMessageErreur.add("Le nom n'a pas été saisi");
} else {
strTfNom = UtilString.ucFirst(strTfNom);
personneSelectionnee.set("nom", strTfNom);
}
String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
//Préparer les données
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
Valeur valeur;
String strValeur = "";
valeur = combo.getValue();
if (valeur!=null) {
personneSelectionnee.set("ce_sexe", valeur.getId());
}
strValeur = obtenirValeurCombo("cbPrefixe");
personneSelectionnee.set("ce_truk_prefix", strValeur);
strValeur = obtenirValeurCombo("cbSuffixe");
personneSelectionnee.set("ce_truk_suffix", strValeur);
String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
personneSelectionnee.set("truk_nom_autre", nomAutre);
String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
String strPrefixe = "";
combo = hmIdentite.getComboBoxValeur("cbPrefixe");
valeur = combo.getValue();
if (valeur != null) {
strPrefixe = valeur.getNom();
} else {
strPrefixe = combo.getRawValue();
}
String strSuffixe = "";
combo = hmIdentite.getComboBoxValeur("cbSuffixe");
valeur = combo.getValue();
if (valeur != null) {
strSuffixe = valeur.getNom() + " ";
} else {
strSuffixe = combo.getRawValue() +" ";
}
personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
DateField dfDateNaissance = hmIdentite.getDateField("dfDateNaissance");
Date naissanceDate = dfDateNaissance.getValue();
personneSelectionnee.setNaissanceDate(naissanceDate);
Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
if (rbEstDecedee.getValue() == true) {
DateField dfDecesDate = hmIdentite.getDateField("dfDateDeces");
String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu);
} else {
personneSelectionnee.setNonDecedee();
}
strValeur = obtenirValeurCombo("cbPays");
personneSelectionnee.set("ce_truk_pays", strValeur);
strValeur = obtenirValeurCombo("cbRegion");
personneSelectionnee.set("ce_truk_region", strValeur);
personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
personneSelectionnee.set("truk_logo", logoUrls);
personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
//Infos Naturalistes
String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs();
personneSelectionnee.set("truk_recolte", recolte);
String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
personneSelectionnee.set("ce_truk_specialite", specialite);
if (lstMessageErreur.size() == 0) {
System.out.println("2." + personne);
mediateur.enregistrerPersonne(this, personneSelectionnee);
success = true;
} else {
String strMessagesErreur = "<span><br />";
Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
while (itMessagesErreur.hasNext()) {
strMessagesErreur += "<br /> - " + itMessagesErreur.next();
}
strMessagesErreur += "</span>";
MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
success = false;
}
return success;
}
private String obtenirValeurCombo(String strComboName) {
String strValeur = "";
Valeur valeur;
1132,7 → 954,7
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
if (combo == null) {
combo = (ComboBox) hmAdresse.get(strComboName);
combo = hmAdresse.getComboBoxValeur(strComboName);
}
strValeur = combo.getRawValue();
valeur = combo.getStore().findModel(strValeur);
1140,13 → 962,6
strValeur = valeur.getId();
}
/*if (combo.getValue()!=null) {
valeur = (Valeur) combo.getValue();
strValeur = valeur.getId();
} else {
strValeur = combo.getRawValue();
}*/
return strValeur;
}