12,6 → 12,7 |
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.Personne; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
20,7 → 21,6 |
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.BaseEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
27,17 → 27,17 |
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.store.StoreListener; |
|
import com.extjs.gxt.ui.client.widget.ContentPanel; |
|
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
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.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.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; |
47,6 → 47,7 |
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.FormLayout; |
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.user.client.Window; |
93,6 → 94,7 |
initialiserOnglets(); |
|
creerComposantsIdentite(); |
creerComposantsAdresse(); |
|
} |
|
130,6 → 132,7 |
tiIdentite.setScrollMode(Scroll.AUTO); |
formulaireOnglets.add(tiIdentite); |
|
hmIdentite.put("tiIdentite", tiIdentite); |
|
|
//Tab 2 : Adresse |
152,8 → 155,10 |
* |
* */ |
|
//hmIdentite référence par une chaine de caractère tous les composants de l'onglet Identite |
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite |
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>(); |
|
public void creerComposantsIdentite() { |
|
173,10 → 178,9 |
main.setLayout(new ColumnLayout()); |
|
// Ajout au principal |
main.add(left, new ColumnData(.5)); |
main.add(right, new ColumnData(.5)); |
main.add(left, new ColumnData(.49)); |
main.add(right, new ColumnData(.49)); |
|
|
// Création des champs |
|
//FormLayout sera utilisé à plusieurs reprises |
314,53 → 318,130 |
|
tiIdentite.add(main); |
|
// Autres informations |
FieldSet fsAutresInfos = new FieldSet(); |
fsAutresInfos.setHeading("Autres informations"); |
// Contact - Téléphone |
FieldSet fsContactTel = new FieldSet(); |
fsContactTel.setHeading("Contact - Téléphones"); |
fsContactTel.setLayout(new TableLayout(3)); |
hmIdentite.put("fsContactTel", fsContactTel); |
|
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.LEFT); |
fsAutresInfos.setLayout(formLayout); |
right.add(fsContactTel); |
|
right.add(fsAutresInfos); |
//Téléphone |
TextField tfTelephone = new TextField(); |
tfTelephone.setFieldLabel("tel"); |
fsContactTel.add(tfTelephone); |
|
//Civilité |
hmIdentite.put("tfTelephone", tfTelephone); |
|
ComboBox<Valeur> cbCivilite = new ComboBox<Valeur>(); |
ListStore<Valeur> storeCivilite = new ListStore<Valeur>(); |
cbCivilite.setStore(storeCivilite); |
cbCivilite.setFieldLabel("Civilité"); |
cbCivilite.setDisplayField("nom"); |
cbCivilite.setEmptyText("Choisissez une civilité:"); |
//Type de téléphone |
ComboBox<Valeur> cbTelephone = new ComboBox<Valeur>(); |
|
fsAutresInfos.add(cbCivilite); |
cbTelephone.setDisplayField("nom"); |
cbTelephone.setEmptyText("Choisissez:"); |
ListStore<Valeur> storeTel = new ListStore<Valeur>(); |
cbTelephone.setStore(storeTel); |
|
hmIdentite.put("cbCivilite", cbCivilite); |
fsContactTel.add(cbTelephone); |
|
// TODO : récupérer la liste des civilités en BDD |
hmIdentite.put("cbTelephone", cbTelephone); |
|
mediateur.obtenirListeValeurEtRafraichir(this, "tel"); |
|
//Description |
TextArea taDescription = new TextArea(); |
taDescription.setEmptyText("Saisissez une description"); |
taDescription.setFieldLabel("Description"); |
fsAutresInfos.add(taDescription); |
// Bouton ajouter |
Button bAjouter = new Button(); |
bAjouter.setText("+"); |
|
hmIdentite.put("taDescription", taDescription); |
// Evenement bouton |
bAjouter.addSelectionListener( |
new SelectionListener<ComponentEvent>() { |
|
public void componentSelected(ComponentEvent ce) { |
|
String strTelephone = ((TextField<String>) hmIdentite.get("tfTelephone")).getValue(); |
if ((strTelephone==null)||(strTelephone.trim().equals(""))) { |
Window.alert("Vous devez saisir un numéro de téléphone"); |
} else if (hmIdentite.get("tel-" + strTelephone) != null){ |
Window.alert("Le numéro saisi est déjà présent dans la liste"); |
} 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("")) { |
Window.alert("Vous devez saisir un type de téléphone"); |
} 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); |
|
Button bSupprimer = new Button(); |
bSupprimer.setId(strTelephone); |
bSupprimer.setText("-"); |
|
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(); |
} |
|
} |
|
|
} |
} |
); |
|
// Logo |
TextArea taLogo = new TextArea(); |
taLogo.setFieldLabel("Logos"); |
taLogo.setEmptyText("Saisissez les adresses des logos séparées par un saut de ligne"); |
fsAutresInfos.add(taLogo); |
fsContactTel.add(bAjouter); |
|
hmIdentite.put("taLogo", taLogo); |
|
|
|
//Contact |
//Contact - autres |
FieldSet fsContact = new FieldSet(); |
fsContact.setHeading("Contact"); |
fsContact.setHeading("Contact - Autres"); |
|
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.LEFT); |
385,6 → 466,49 |
hmIdentite.put("taUrl", taUrl); |
|
|
// Autres informations |
FieldSet 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); |
|
hmIdentite.put("cbSexe", cbSexe); |
|
mediateur.obtenirListeValeurEtRafraichir(this, "sexe"); |
|
//Description |
TextArea taDescription = new TextArea(); |
taDescription.setEmptyText("Saisissez une description"); |
taDescription.setFieldLabel("Description"); |
fsAutresInfos.add(taDescription); |
|
hmIdentite.put("taDescription", taDescription); |
|
// Logo |
TextArea taLogo = new TextArea(); |
taLogo.setFieldLabel("Logos"); |
taLogo.setEmptyText("Saisissez les adresses des logos séparées par un saut de ligne"); |
fsAutresInfos.add(taLogo); |
|
hmIdentite.put("taLogo", taLogo); |
|
|
|
// Ajout des évènements saisi |
KeyListener klNoms = new KeyListener() { |
public void componentKeyUp(ComponentEvent ev) { |
406,6 → 530,91 |
|
} |
|
public void creerComposantsAdresse() { |
|
// Gauche |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
|
// Droite |
LayoutContainer right = new LayoutContainer(); |
right.setLayout(new FormLayout()); |
|
// Principal |
LayoutContainer main = new LayoutContainer(); |
main.setLayout(new ColumnLayout()); |
|
// Ajout au principal |
main.add(left, new ColumnData(.49)); |
main.add(right, new ColumnData(.49)); |
|
TextField<String> tfAdresse1 = new TextField(); |
tfAdresse1.setFieldLabel("Adresse"); |
left.add(tfAdresse1); |
hmAdresse.put("tfAdresse1", tfAdresse1); |
|
TextField<String> tfAdresse2 = new TextField(); |
tfAdresse2.setFieldLabel("Complément d'adresse"); |
left.add(tfAdresse2); |
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); |
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); |
hmAdresse.put("cbRegion", cbRegion); |
|
TextField<String> tfBoitePostale = new TextField<String>(); |
tfBoitePostale.setFieldLabel("Boite postale"); |
left.add(tfBoitePostale); |
hmAdresse.put("tfBoitePostale", tfBoitePostale); |
|
TextField<Integer> tfCodePostal = new TextField<Integer>(); |
tfCodePostal.setFieldLabel("Code postal"); |
right.add(tfCodePostal); |
hmAdresse.put("tfCodePostal", tfCodePostal); |
|
TextField tfVille = new TextField(); |
tfVille.setFieldLabel("Ville"); |
|
right.add(tfVille); |
hmAdresse.put("tfVille", tfVille); |
|
// MAJ ComboBox |
mediateur.obtenirListeValeurEtRafraichir(this, "pays"); |
|
tiAdresses.add(main); |
|
} |
|
/** |
* Ajouter le bouton réinitialiser à la barre d'outils donnée |
* |
460,8 → 669,12 |
barreOutils.add(annuler); |
} |
|
public void obtenirListeRegionParPays(String strPays) { |
mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays); |
} |
|
|
|
/*--------------------------------------------------------------------------------------- |
* RAFRAICHISSEMENT DU PANNEAU |
* -------------------------------------------------------------------------------------- |
472,8 → 685,6 |
|
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
|
|
|
// Créer une liste de valeurs |
List<Valeur> liste = new ArrayList<Valeur>(); |
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) { |
482,26 → 693,34 |
|
if (listeValeurs.getId().equals(config.getListeId("prefixe"))) { |
|
//Remplir la liste Prefixe |
remplirCombobox("cbPrefix", 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"); |
|
} else if (listeValeurs.getId().equals(config.getListeId("pays"))) { |
|
ListStore<Valeur> stPrefixe = ((ComboBox) hmIdentite.get("cbPrefix")).getStore(); |
stPrefixe.removeAll(); |
stPrefixe.add(liste); |
((ComboBox) hmIdentite.get("cbPrefix")).setStore(stPrefixe); |
remplirCombobox("cbPays", liste, "hmAdresse"); |
|
} else if (listeValeurs.getId().equals(config.getListeId("region"))) { |
|
} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) { |
|
//Remplir la liste Suffixe |
ListStore<Valeur> stSuffix = ((ComboBox) hmIdentite.get("cbSuffixe")).getStore(); |
stSuffix.removeAll(); |
stSuffix.add(liste); |
((ComboBox) hmIdentite.get("cbSuffixe")).setStore(stSuffix); |
remplirCombobox("cbRegion", liste, "hmAdresse"); |
|
|
((ComboBox) hmAdresse.get("cbRegion")).setVisible(true); |
} |
|
|
} else if (nouvellesDonnees instanceof Personne) { |
|
|
|
//Mise à jour de la personne |
515,19 → 734,19 |
((TextField) hmIdentite.get("tfAbreviation")).setValue(personne.get("abreviation")); |
((TextField) hmIdentite.get("tfAbreviationAutre")).setValue(personne.get("truk_abreviation_autre")); |
|
//FIXME : DATES |
//((DateField) hmIdentite.get("dfDateNaissance")).setValue(new Date((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")); |
|
} |
} |
|
if (nouvellesDonnees == null) |
{ |
ComboBox cb= (ComboBox) hmIdentite.get("cbPrefix"); |
/* |
* Met à jour le nom Complet du formulaire |
* */ |
|
//Met à jour le nom Complet du formulaire |
String valeurRetour = ""; |
|
// Prefixe |
536,8 → 755,11 |
|
if (valPrefixe != null) { |
prefixe = valPrefixe.getNom(); |
} |
} else { |
prefixe = (String) ((ComboBox) hmIdentite.get("cbPrefix")).getRawValue(); |
} |
|
|
// Prénom |
String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue(); |
|
550,6 → 772,8 |
|
if (valSuffixe != null) { |
suffixe = valSuffixe.getNom(); |
} else { |
suffixe = (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getRawValue(); |
} |
|
// Mettre à jour la valeur |
566,6 → 790,22 |
} |
} |
|
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); |
} |
|
|
|