/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneVue.java |
---|
New file |
0,0 → 1,84 |
package org.tela_botanica.client.vues.personne; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilString; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
import com.google.gwt.core.client.GWT; |
public class PersonneVue extends LayoutContainer implements Rafraichissable { |
private PersonneListeVue panneauPersonneListe; |
private PersonneDetailVue panneauPersonneDetail; |
private Mediateur mediateur = null; |
//Sequenceur pour la gestion du synchrone |
private Sequenceur sequenceur = new Sequenceur(); |
public PersonneVue(Mediateur mediateur) { |
this.mediateur = mediateur; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
panneauPersonneListe = new PersonneListeVue(); |
//Charger les ontologies nécessaires à l'affichage des personnes |
this.add(panneauPersonneListe, new BorderLayoutData(LayoutRegion.CENTER)); |
panneauPersonneDetail = new PersonneDetailVue(mediateur); |
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
southData.setSplit(true); |
southData.setMargins(new Margins(5, 0, 0, 0)); |
this.add(panneauPersonneDetail, southData); |
mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur); |
mediateur.obtenirListeValeurEtRafraichir(this, "tel", sequenceur); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Personne) { |
sequenceur.enfilerRafraichissement(panneauPersonneDetail, (Personne) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PersonneListe) { |
panneauPersonneListe.rafraichir((PersonneListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
// Affichage des éventuels messages de déboguage ou d'alerte |
if (!UtilString.isEmpty(info.getMessages())) { |
GWT.log(info.getMessages().toString(), null); |
} |
// Traitement en fonction des types d'information |
if (info.getType().equals("liste_personne")) { |
panneauPersonneListe.rafraichir((PersonneListe) info.getDonnee(0)); |
InfoLogger.display("Chargement d'une liste de personnes", ""); |
} else { |
panneauPersonneListe.rafraichir(info); |
} |
} else if (nouvellesDonnees instanceof ValeurListe) { |
panneauPersonneDetail.rafraichir((ValeurListe) nouvellesDonnees); |
} else { |
GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneVue.java:r1136-1368 |
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneVue.java:r11-934,1209-1382 |
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneVue.java:r1383-1511 |
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java |
---|
New file |
0,0 → 1,267 |
package org.tela_botanica.client.vues.personne; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.ChampFiltreRecherche; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.Utilisateur; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.GridEvent; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
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.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; |
import com.extjs.gxt.ui.client.widget.grid.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.i18n.client.Constants; |
import com.google.gwt.user.client.Window; |
public class PersonneListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null ; |
private Grid<Personne> grille = null; |
private ListStore<Personne> store = null; |
private ChampFiltreRecherche champFiltreRecherche = null; |
private BarrePaginationVue pagination = null; |
private ColumnModel modeleColonnes = null; |
private Button ajouter = null; |
private Button modifier = null; |
private Button supprimer = null; |
private int indexElementSelectionne = 0; |
private Personne personneSelectionnee = null; |
public PersonneListeVue() { |
mediateur = Registry.get(RegistreId.MEDIATEUR); |
Constants i18nC = mediateur.i18nC; |
setHeaderVisible(false); |
setLayout(new FitLayout()); |
//Définition de la barre d'outil |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(Mediateur.i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicAjouterPersonne(); |
} |
}); |
ajouter.setToolTip(mediateur.i18nC.indicationCreerUneFiche()+" "+mediateur.i18nC.collectionSingulier()); |
toolBar.add(ajouter); |
modifier = new Button(Mediateur.i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicModifierPersonne(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
modifier.setToolTip(mediateur.i18nC.indicationModifierUneFiche()); |
toolBar.add(modifier); |
supprimer = new Button(Mediateur.i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
clicSupprimerPersonne(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
supprimer.setToolTip(mediateur.i18nC.indicationSupprimerUneFiche()); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
// Définition des colomnes de la grille: |
List<ColumnConfig> lstColumns = new ArrayList<ColumnConfig>(); |
lstColumns.add(new ColumnConfig("id_personne", "Id", 45)); |
lstColumns.add(new ColumnConfig("nom", "Nom", 100)); |
lstColumns.add(new ColumnConfig("prenom", "Prénom", 100)); |
lstColumns.add(new ColumnConfig("fmt_nom_complet", "Nom Complet", 200)); |
lstColumns.add(new ColumnConfig("code_postal", "Code postal", 100)); |
lstColumns.add(new ColumnConfig("ville", "Ville", 100)); |
lstColumns.add(new ColumnConfig("_courriel_princ_", "Courriel", 200)); |
lstColumns.get(0).setHidden(true); |
lstColumns.get(1).setHidden(true); |
lstColumns.get(2).setHidden(true); |
modeleColonnes = new ColumnModel(lstColumns); |
// Définition de la grille |
GridSelectionModel<Personne> gsmSelectionGrille = new GridSelectionModel<Personne>(); |
gsmSelectionGrille.addSelectionChangedListener(new SelectionChangedListener<Personne>() { |
public void selectionChanged(SelectionChangedEvent<Personne> event) { |
personneSelectionnee = (Personne) event.getSelectedItem(); |
indexElementSelectionne = store.indexOf(personneSelectionnee); |
clicListe(personneSelectionnee); |
} |
}); |
store = new ListStore<Personne>(); |
grille = new Grid<Personne>(store, modeleColonnes); |
grille.setSelectionModel(gsmSelectionGrille); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("fmt_nom_complet"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){ |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
grille.addListener(Events.SortChange, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
GridEvent ge = (GridEvent<Personne>) be; |
ge.preventDefault(); |
// TODO rajouter un test sur le sort state pour trier par nom par défaut |
// bref, on verra plus tard parce que c'est chiant et qu'on en a marre de coel |
String tri = ge.getSortInfo().getSortField(); |
if(tri.equals("_courriel_princ_")) { |
tri = "truk_courriel"; |
} |
if(tri.equals("fmt_nom_complet")) { |
tri = "nom"; |
} |
PersonneAsyncDao.tri = Personne.PREFIXE+"_"+tri+" "+ge.getSortInfo().getSortDir().toString(); |
pagination.changePage(); |
} |
}); |
add(grille); |
PersonneListe personneListe = new PersonneListe(); |
champFiltreRecherche = new ChampFiltreRecherche(mediateur, toolBar, personneListe); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(personneListe, mediateur, champFiltreRecherche); |
setBottomComponent(pagination); |
} |
private void clicListe(Personne personne) { |
if (personne != null && store.getCount() > 0) { |
mediateur.clicListePersonne(personne); |
} |
} |
private void clicSupprimerPersonne(List<Personne> personnesASupprimer) { |
if (store.getCount() > 0) { |
mediateur.clicSupprimerPersonne(this, personnesASupprimer); |
} |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin == 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof PersonneListe) { |
PersonneListe listePersonnes = (PersonneListe) nouvellesDonnees; |
// la grille de gxt est case sensitive, on harmonise donc tous les noms en majuscule et sans espaces |
// au début et à la fin afin de pouvoir trier correctement |
// (la colonne nom ne sert qu'au tri et n'est pas affichée) |
for (Iterator<Personne> iterator = listePersonnes.toList().iterator(); iterator.hasNext();) { |
Personne personne = iterator.next(); |
personne.setNom(personne.getNom().toUpperCase().trim()); |
} |
champFiltreRecherche.setListePaginable(listePersonnes); |
pagination.setlistePaginable(listePersonnes); |
pagination.rafraichir(listePersonnes.getPageTable()); |
if (listePersonnes != null) { |
List<Personne> liste = (List<Personne>) listePersonnes.toList(); |
store.removeAll(); |
store.add(liste); |
mediateur.actualiserPanneauCentral(); |
grille.fireEvent(Events.ViewReady); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if(info.getType().equals("personne_modifiee")) { |
// curieusement la suppression efface aussi l'index de l'élément |
// car elle redéclenche l'évenement de selection (on le stocke donc temporairement) |
int temporaire = indexElementSelectionne; |
if(personneSelectionnee != null) { |
store.remove(indexElementSelectionne); |
personneSelectionnee = null; |
} |
Personne personneModifiee = (Personne)info.getDonnee(0); |
// au cas ou le bouton appliquer aurait été cliqué avant de valider |
store.remove(personneModifiee); |
indexElementSelectionne = temporaire; |
store.insert(personneModifiee, temporaire); |
personneSelectionnee = personneModifiee; |
int indexElementSelectionne = store.indexOf(personneSelectionnee); |
grille.getSelectionModel().select(indexElementSelectionne, false); |
grille.getView().focusRow(indexElementSelectionne); |
clicListe(personneSelectionnee); |
} else if (info.getType().equals("suppression_personne")) { |
InfoLogger.display("Suppression de personne", info.getMessages().toString()); |
pagination.getlistePaginable().recharger(); |
gererEtatActivationBouton(); |
} else if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else { |
InfoLogger.display("Erreur", info.getMessages().toString(), true); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
layout(); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java:r1136-1368 |
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java:r11-934,1209-1382 |
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java:r1383-1511 |
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java |
---|
New file |
0,0 → 1,407 |
package org.tela_botanica.client.vues.personne; |
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.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.configuration.Configuration; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.DetailVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.util.Format; |
import com.extjs.gxt.ui.client.util.Params; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Html; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.LabelField; |
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout; |
import com.google.gwt.user.client.ui.Image; |
public class PersonneDetailVue extends DetailVue implements Rafraichissable { |
private TabPanel tabPanel; |
private Html entete; |
private TabItem tabIdentite; |
private TabItem tabAdresse; |
private TabItem tabInfosNat; |
private TabItem tabLogos; |
private TabItem tabPublications; |
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG); |
private Personne personneAAfficher = null; |
private String tableauPublicationsLieesTpl = ""; |
private String lignePublicationLieeTpl = ""; |
private Sequenceur sequenceur = new Sequenceur(); |
public PersonneDetailVue(Mediateur mediateur) { |
super(mediateur); |
setLayout(new FitLayout()); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
ContentPanel panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(true); |
panneauPrincipal.setTopComponent(entete); |
tabIdentite = new TabItem(i18nC.personneIdentite()); |
tabIdentite.setTitle(i18nC.personneIdentite()); |
tabIdentite.setLayout(new AnchorLayout()); |
tabIdentite.setScrollMode(Scroll.AUTO); |
tabAdresse = new TabItem(i18nC.personneAdresses()); |
tabAdresse.setTitle(i18nC.personneAdresses()); |
tabAdresse.setLayout(new FitLayout()); |
tabAdresse.setScrollMode(Scroll.AUTO); |
tabInfosNat = new TabItem(i18nC.personneInfoNat()); |
tabInfosNat.setTitle(i18nC.personneInfoNat()); |
tabInfosNat.setScrollMode(Scroll.AUTO); |
tabPublications = new TabItem(i18nC.tabPublications()); |
tabPublications.setTitle(i18nC.tabPublications()); |
tabPublications.setScrollMode(Scroll.AUTO); |
tabPublications.setLayout(new FlowLayout()); |
tabLogos = new TabItem(i18nC.personneLogos()); |
tabLogos.setTitle(i18nC.personneLogos()); |
tabLogos.setScrollMode(Scroll.AUTO); |
tabLogos.setLayout(new FlowLayout()); |
tabPanel = new TabPanel(); |
tabPanel.setId(ComposantId.ZONE_DETAIL_CORPS); |
tabPanel.setBodyBorder(false); |
tabPanel.add(tabIdentite); |
tabPanel.add(tabAdresse); |
tabPanel.add(tabInfosNat); |
tabPanel.add(tabPublications); |
tabPanel.add(tabLogos); |
panneauPrincipal.add(tabPanel); |
add(panneauPrincipal); |
} |
public void afficherDetailPersonne(Personne personne) { |
if (personne != null) { |
String tplEntete = initialiserTplEntete(); |
//Sélection des publication à personne |
mediateur.selectionnerPublicationAPersonne(this, null, personne.getId(), new LinkedList(), null); |
Params enteteParams = new Params(); |
enteteParams.set("nom", (String) personne.get("fmt_nom_complet")); |
enteteParams.set("mail", (String) personne.getCourrielPrinc()); |
tabLogos.removeAll(); |
LinkedList lstLogos = (LinkedList) personne |
.getChaineDenormaliseAsMapOrList("truk_logo"); |
if (lstLogos != null && lstLogos.size() > 0) { |
String urlLogoPrinc = (String) lstLogos.get(0); |
if (!urlLogoPrinc.trim().equals("")) { |
tplEntete = "<div id='personne-logo-div'><img src='{image}' alt='logo' /></div>" |
+ tplEntete; |
enteteParams.set("image", urlLogoPrinc); |
} |
Iterator<String> itLogo = lstLogos.iterator(); |
while (itLogo.hasNext()) { |
String urlLogoCourant = itLogo.next(); |
Image imgCourante = new Image(urlLogoCourant); |
tabLogos.add(imgCourante); |
} |
tabLogos.enable(); |
} else { |
enteteParams.set("image", ""); |
tabLogos.disable(); |
} |
entete.el().setInnerHtml(Format.substitute(tplEntete, enteteParams)); |
String tplIdentite = initialiserTplIdentite(); |
Params tabIdentiteParams = new Params(); |
tabIdentiteParams.set("nom_complet", personne.getString("fmt_nom_complet")); |
tabIdentiteParams.set("abreviation", personne.getString("abreviation")); |
tabIdentiteParams.set("naissance_date", personne.getAnneeOuDateNaiss().equals("") ? "" : personne.getAnneeOuDateNaiss()); |
tabIdentiteParams.set("naissance_lieu", personne.getString("naissance_lieu")); |
String tplDeces = ""; |
if (personne.estDecedee()) { |
tplDeces = " <h2>Décès:</h2>" |
+ " <span><b>" |
+ i18nC.personneDateDeces() |
+ ":</b></span> {deces_date}<br />" |
+ " <span><b>" |
+ i18nC.personneLieuDeces() |
+ ":</b></span> {deces_lieu}<br /><br />"; |
tabIdentiteParams.set("deces_date", personne.getAnneeOuDateDeces().equals("") ? "" : personne.getAnneeOuDateDeces()); |
tabIdentiteParams.set("deces_lieu", personne.getString("deces_lieu")); |
} |
Params paramsDeces = new Params(); |
paramsDeces.set("tplDeces", tplDeces); |
tplIdentite = Format.substitute(tplIdentite, paramsDeces); |
tabIdentiteParams.set("description", personne.getString("description")); |
tabInfosNat.removeAll(); |
tabIdentiteParams.set("nom_autre", construireTxtTruck(personne.getString("truk_nom_autre"))); |
tabIdentiteParams.set("abreviation_autre", construireTxtTruck(personne.getString("truk_abreviation_autre"))); |
tplIdentite += construireTxtListeOntologie(personne.getString("truk_telephone")); |
// Courriel :Champ truk de la forme |
// "Adresse@adr.com;; adr2@adr.fr ..." |
LinkedList<String> listeCourriel = (LinkedList<String>) personne |
.getChaineDenormaliseAsMapOrList("truk_courriel"); |
if ((listeCourriel != null) && (listeCourriel.size() > 0)) { |
String strLabelCourriel = "Courriel"; |
if (listeCourriel.size() > 1) { |
strLabelCourriel += "s"; |
} |
String valeurCourriel = ""; |
Iterator<String> itCourriel = listeCourriel.iterator(); |
while (itCourriel.hasNext()) { |
String valeurCourante = itCourriel.next(); |
valeurCourriel += "<br /><a href=\"mailto:" |
+ valeurCourante + "\">" + valeurCourante + "</a>"; |
} |
tplIdentite += valeurCourriel; |
} |
// Url Site Webs |
LinkedList listeUrl = (LinkedList) personne |
.getChaineDenormaliseAsMapOrList("truk_url"); |
if (listeUrl != null && listeUrl.size() > 0) { |
tplIdentite += "<br /><br /><b>Sites web:</b><br /><span style='display:inline-block'>"; |
String strUrl = ""; |
Iterator<String> urlIt = listeUrl.iterator(); |
while (urlIt.hasNext()) { |
String urlCourante = urlIt.next(); |
strUrl += "<a href=\"" + urlCourante + "\">" + urlCourante |
+ "</a> <br/>"; |
} |
tplIdentite += strUrl + "</span><br />"; |
} |
tplIdentite += "</div>"; |
afficherOnglet(tplIdentite, tabIdentiteParams, tabIdentite); |
String tabAdresseTpl = "<div class='{css_corps}'>" |
+ " <div class='{css_fieldset}'>" |
+ " <h2>Adresse personnelle:</h2>" |
+ " <b>Adresse:</b> {adresse01} <br />" |
+ " <b>Boite postale: </b>{boitePostale}<br />" |
+ " <b>Code postal:</b>{codePostal} <br />" |
+ " <b>Pays :</b><span style='uppercase'>{pays}</span><br />" |
+ "</div>"; |
// Adresses : |
Params paramAdresseTpl = new Params(); |
paramAdresseTpl.set("adresse01", (String) personne |
.obtenirValeurChamp("adresse_01")); |
paramAdresseTpl.set("boitePostale", (String) personne |
.obtenirValeurChamp("bp")); |
paramAdresseTpl.set("codePostal", (String) personne |
.obtenirValeurChamp("code_postal")); |
paramAdresseTpl.set("ville", (String) personne |
.obtenirValeurChamp("ville")); |
paramAdresseTpl.set("pays", construireTxtListeOntologie((String) personne |
.obtenirValeurChamp("ce_truk_pays"))); |
afficherOnglet(tabAdresseTpl, paramAdresseTpl, tabAdresse); |
tabAdresse.setStyleAttribute("padding", "15px"); |
// Infos naturalistes :Biographie, Spécialité (typé) |
String tplInfosNat = "<div class='{css_corps}'>" |
+ " <div class='{css_fieldset}'>" + " <h2>" |
+ i18nC.personneBiographie() + "</h2>" |
+ " {biographie}" + " " |
+ "<h2>" + i18nC.personneSpecialite() + "</h2>" |
+ " {specialites}" + " <h2>" |
+ i18nC.personneRecolte() + "</h2>" |
+ " {recoltes}" + " </div>" + "</div>"; |
Params prmInfosNat = new Params(); |
prmInfosNat.set("biographie", personne.get("biographie")); |
String specialite = construireTxtTruck(personne.getSpecialite()); |
prmInfosNat.set("specialites", specialite); |
String recolte = construireTxtListeOntologie(personne.getString("truk_recolte")); |
prmInfosNat.set("recoltes", recolte); |
afficherOnglet(tplInfosNat, prmInfosNat, tabInfosNat); |
tabAdresse.setStyleAttribute("padding", "15px"); |
layout(); |
} |
} |
public String initialiserTplEntete() { |
return "<div id='{css_id}'>" + "<h1>{nom}</h1>" |
+ "<h2><a href='{mail}'>{mail}</a></h2>" + "</div>"; |
} |
public String initialiserTplIdentite() { |
return "<div class='{css_corps}'>" + " <div class='{css_fieldset}'>" |
+ " <h2>Noms:</h2>" + " <span><b>" |
+ i18nC.personneNomComplet() |
+ ":</b></span> {nom_complet}<br />" |
+ " <span><b>" |
+ i18nC.personneNomAutre() |
+ ":</b></span> {nom_autre}<br />" |
+ " <span><b>" |
+ i18nC.personneAbreviation() |
+ ":</b></span> {abreviation}<br />" |
+ " <span><b>" |
+ i18nC.personneAbreviationAutre() |
+ ":</b></b></span> {abreviation_autre}<br /><br />" |
+ " <h2>Naissance:</h2>" |
+ " <span><b>" |
+ i18nC.personneDateNaissance() |
+ ":</b></span> {naissance_date}<br />" |
+ " <span><b>" |
+ i18nC.personneLieuNaissance() |
+ ":</b></span> {naissance_lieu}<br /><br />" |
+ "{tplDeces}" |
+ " </div>" |
+ "</div>" |
+ "<div class='{css_corps}'>" |
+ " <div class='css_fieldset'> " |
+ " <h2>Description:</h2>" |
+ " {description}<br />" + " </div>" + "<br />"; |
} |
private void initialiserTableauPublicationsLieesTpl() { |
tableauPublicationsLieesTpl = |
"<div class='{css_corps}'>" + |
" <h2>{i18n_titre_publication}</h2>"+ |
" <table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_relation}</th>" + |
" <th>{i18n_auteur}</th>" + |
" <th>{i18n_titre}</th>" + |
" <th>{i18n_revue}</th>" + |
" <th>{i18n_editeur}</th>" + |
" <th>{i18n_annee}</th>" + |
" <th>{i18n_nvt}</th>" + |
" <th>{i18n_fascicule}</th>" + |
" <th>{i18n_page}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLignePublicationLieeTpl() { |
lignePublicationLieeTpl = |
"<tr>"+ |
" <td>{relation}</td>"+ |
" <td>{auteur}</td>"+ |
" <td>{titre}</td>"+ |
" <td>{revue}</td>"+ |
" <td>{editeur}</td>"+ |
" <td>{annee}</td>"+ |
" <td>{nvt}</td>"+ |
" <td>{fascicule}</td>"+ |
" <td>{page}</td>"+ |
"</tr>"; |
} |
/** |
* @author greg |
* Rempli l'onglet des publications liées |
* @param listePublications la liste des publications |
*/ |
private void afficherPublications(PublicationAPersonneListe listePublications) { |
List<PublicationAPersonne> publicationsLiees = listePublications.toList(); |
Iterator<PublicationAPersonne> iterateur = publicationsLiees.iterator(); |
//Onglet Publications |
initialiserTableauPublicationsLieesTpl(); |
Params paramsPublis = new Params(); |
String contenuLignes = ""; |
while (iterateur.hasNext()) { |
initialiserLignePublicationLieeTpl(); |
PublicationAPersonne publicationAPersonneCourante = iterateur.next(); |
Publication publication = publicationAPersonneCourante.getPublicationLiee(); |
Params ligneParams = new Params(); |
ligneParams.set("relation", construireTxtListeOntologie(publicationAPersonneCourante.getRole())); |
ligneParams.set("auteur", publication.getAuteur()); |
ligneParams.set("titre", publication.getTitre()); |
ligneParams.set("revue", publication.getCollection()); |
ligneParams.set("editeur", publication.getEditeur()); |
ligneParams.set("annee", publication.getAnneeParution()); |
ligneParams.set("nvt", publication.getIndicationNvt()); |
ligneParams.set("fascicule", publication.getFascicule()); |
ligneParams.set("page", publication.getPages()); |
contenuLignes += Format.substitute(lignePublicationLieeTpl, ligneParams); |
} |
paramsPublis.set("lignes", contenuLignes); |
paramsPublis.set("i18n_titre_publication", i18nC.tabPublications()); |
paramsPublis.set("i18n_relation", i18nC.publicationAuteurs()); |
paramsPublis.set("i18n_auteur", i18nC.publicationAuteurs()); |
paramsPublis.set("i18n_titre", i18nC.publicationTitre()); |
paramsPublis.set("i18n_revue", i18nC.publicationRevueCollection()); |
paramsPublis.set("i18n_editeur", i18nC.publicationEditeur()); |
paramsPublis.set("i18n_annee", i18nC.publicationDateParution()); |
paramsPublis.set("i18n_nvt", i18nC.publicationNvt()); |
paramsPublis.set("i18n_fascicule", i18nC.publicationFascicule()); |
paramsPublis.set("i18n_page", i18nC.publicationPage()); |
afficherOnglet(tableauPublicationsLieesTpl, paramsPublis, tabPublications); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ajouterListeValeursAOntologie((ValeurListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof Personne) { |
afficherDetailPersonne((Personne) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) { |
afficherPublications((PublicationAPersonneListe) nouvellesDonnees); |
layout(); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java:r1136-1368 |
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java:r11-934,1209-1382 |
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java:r1383-1511 |
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneForm.java |
---|
New file |
0,0 → 1,1412 |
package org.tela_botanica.client.vues.personne; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.LinkedList; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.ChampMultiValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeursImage; |
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes; |
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable; |
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; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilDate; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import com.extjs.gxt.ui.client.data.ModelData; |
import com.extjs.gxt.ui.client.data.ModelType; |
import com.extjs.gxt.ui.client.data.PagingLoadResult; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.Style.SortDir; |
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.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.event.WidgetListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.composants.pagination.Proxy; |
import org.tela_botanica.client.composants.pagination.ProxyValeur; |
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; |
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.Field; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
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; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
import com.extjs.gxt.ui.client.widget.form.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.layout.ColumnData; |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.FormLayout; |
import com.extjs.gxt.ui.client.widget.layout.RowLayout; |
import com.extjs.gxt.ui.client.widget.layout.TableData; |
import com.extjs.gxt.ui.client.widget.layout.TableLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.Callback; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
import com.google.gwt.user.client.Window; |
public class PersonneForm extends Formulaire implements Rafraichissable { |
// VARIABLES |
private TabItem tiIdentite, tiAdresses, tiInfosNat; |
PersonneFormPublication tiPubli; |
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG); |
protected Personne personneSelectionnee, personneSauvegarde = null; |
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite |
private HashMapComposants hmIdentite = new HashMapComposants(); |
private HashMapComposants hmAdresse = new HashMapComposants(); |
private HashMapComposants hmInfosNat = new HashMapComposants(); |
private HashMap<String, Valeur> hmCbSelectionnee = new HashMap(); |
private FormData fd100 = new FormData("95%"); |
private Button enregistrer, enregistrerEtRevenir; |
private Personne personne = null; |
private String personneId = null; |
private FormBinding binding = null; |
//Gestion du mode synchrone |
private Sequenceur sequenceur; |
//Publi |
private ComboBox<Publication> cbPubli; |
private ListStore<Publication> storePubli; |
// Gestion de la vérification des doublons |
private boolean verificationDoublonEffectuee = false; |
// CONSTRUCTEUR |
public PersonneForm(Mediateur mediateurCourrant, String personneId) { |
initialiserPersonneForm(mediateurCourrant, personneId); |
} |
public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) { |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation; |
initialiserPersonneForm(mediateurCourrant, personneId); |
} |
private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) { |
//Initialisation du séquenceur |
sequenceur = new Sequenceur(); |
personne = new Personne(); |
personne.setId(personneIdCourrant); |
personneId = personneIdCourrant; |
String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE); |
initialiserComposants(); |
genererTitreFormulaire(); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", null); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerPersonne(this, personne.getId(), sequenceur); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.personneModeAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId; |
} |
panneauFormulaire.setHeadingHtml(titre); |
} |
public void initialiserComposants() { |
personneSelectionnee = new Personne(); |
personneSauvegarde = new Personne(); |
initialiserOnglets(); |
creerComposantsIdentite(); |
creerComposantsAdresse(); |
creerComposantsInfosNat(); |
//creerComposantsPubli(); |
binderPersonne(personneSelectionnee); |
} |
/** |
* Crée les onglets identité, adresse et informations naturaliste |
* |
* */ |
public void initialiserOnglets() { |
//TabPanel |
TabPanel formulaireOnglets = new TabPanel(); |
//Tab 1 : identite |
tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite"); |
tiIdentite.setStyleAttribute("padding", "0"); |
formulaireOnglets.add(tiIdentite); |
//Tab 2 : Adresse |
tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses"); |
formulaireOnglets.add(tiAdresses); |
//Tab 3 : Infos Naturalistes |
tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat"); |
formulaireOnglets.add(tiInfosNat); |
//Tab 4 : Publications |
tiPubli = new PersonneFormPublication(this); |
formulaireOnglets.add(tiPubli); |
getFormulaire().add(formulaireOnglets); |
} |
/** |
* Crée les widgets pour l'onglet identité |
* |
* */ |
public void creerComposantsIdentite() { |
// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
left.setStyleAttribute("padding", "15px"); |
LayoutContainer right = new LayoutContainer(); |
right.setLayout(new FormLayout()); |
right.setStyleAttribute("padding", "15px"); |
LayoutContainer main = new LayoutContainer(); |
main.add(left, new ColumnData(.45)); |
main.add(right, new ColumnData(.50)); |
main.setLayout(new ColumnLayout()); |
main.setHeight("100%"); |
main.setScrollMode(Scroll.AUTO); |
// Création des champs |
FormLayout formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.LEFT); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset NOM |
FieldSet fsNoms = new FieldSet(); |
fsNoms.setHeadingHtml("Noms"); |
fsNoms.setLayout(formLayout); |
// Nom complet : Affiché que si valeurs saisies |
LabelField nomComplet = new LabelField(); |
nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :"); |
nomComplet.hide(); |
fsNoms.add(nomComplet); |
hmIdentite.put("nomComplet", nomComplet); |
//Préfixe |
ListStore<Valeur> storePrefixe = new ListStore<Valeur>(); |
ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>(); |
cbPrefixe.setStore(storePrefixe); |
cbPrefixe.setDisplayField("nom"); |
cbPrefixe.setEmptyText("Choisissez le préfixe:"); |
cbPrefixe.setFieldLabel("Prefix"); |
fsNoms.add(cbPrefixe); |
hmIdentite.put("cbPrefixe", cbPrefixe); |
mediateur.obtenirListeValeurEtRafraichir(this, "prefixe", sequenceur); |
//Prénom |
TextField<String> tfPrenom = new TextField<String>(); |
tfPrenom.setFieldLabel("Prénom"); |
tfPrenom.setName("prenom"); |
fsNoms.add(tfPrenom, new FormData(300, 0)); |
hmIdentite.put("tfPrenom", tfPrenom); |
tfPrenom.addListener(Events.Blur, creerEcouteurNomPrenomExistant()); |
tfPrenom.addListener(Events.Change, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
verificationDoublonEffectuee = false; |
} |
}); |
//Nom |
TextField<String> tfNom = new TextField<String>(); |
tfNom.setFieldLabel("Nom"); |
tfNom.setAllowBlank(false); |
tfNom.setName("nom"); |
tfNom.addStyleName(ComposantClass.OBLIGATOIRE); |
tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
tfNom.addListener(Events.Blur, creerEcouteurNomPrenomExistant()); |
tfNom.addListener(Events.Change, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
verificationDoublonEffectuee = false; |
} |
}); |
fsNoms.add(tfNom, new FormData(300, 0)); |
hmIdentite.put("tfNom", tfNom); |
//Suffixe |
ListStore<Valeur> storeSuffixe = new ListStore<Valeur>(); |
ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>(); |
cbSuffixe.setStore(storeSuffixe); |
cbSuffixe.setFieldLabel("Suffixe"); |
cbSuffixe.setDisplayField("nom"); |
cbSuffixe.setEmptyText("Choisissez un suffixe:"); |
fsNoms.add(cbSuffixe); |
hmIdentite.put("cbSuffixe", cbSuffixe); |
mediateur.obtenirListeValeurEtRafraichir(this, "suffixes", sequenceur); |
TextField<String> tfAbreviation = new TextField<String>(); |
tfAbreviation.setFieldLabel("Abréviation"); |
tfAbreviation.setName("abreviation"); |
fsNoms.add(tfAbreviation); |
hmIdentite.put("tfAbreviation", tfAbreviation); |
TableLayout layoutAutreNoms = new TableLayout(2); |
layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP); |
LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms); |
ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150); |
hmIdentite.put("nomAutre", nomAutre); |
autresNoms.add(nomAutre, new TableData("200px", "15px")); |
ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150); |
hmIdentite.put("abreviationAutre", abreviationAutre); |
autresNoms.add(abreviationAutre, new TableData("200px", "15px")); |
fsNoms.add(autresNoms); |
left.add(fsNoms); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset NAISSANCE ET DÉCÈS |
FieldSet fsNaissanceEtDeces = new FieldSet(); |
fsNaissanceEtDeces.setHeadingHtml("Naissance et Décès"); |
fsNaissanceEtDeces.setLayout(new ColumnLayout()); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.TOP); |
LayoutContainer containerNaissance = new LayoutContainer(formLayout); |
//Remplacement du DateField par un champ texte |
TextField tfDateNaissance = new TextField(); |
tfDateNaissance.setFieldLabel("Date de naissance"); |
containerNaissance.add(tfDateNaissance); |
hmIdentite.put("tfDateNaissance", tfDateNaissance); |
// Lieu naissance |
TextField<String> tfLieuNaissance = new TextField<String>(); |
tfLieuNaissance.setFieldLabel("Lieu de naissance"); |
tfLieuNaissance.setName("naissance_lieu"); |
containerNaissance.add(tfLieuNaissance); |
hmIdentite.put("tfLieuNaissance", tfLieuNaissance); |
fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5)); |
left.add(fsNaissanceEtDeces); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.TOP); |
LayoutContainer containerDeces = new LayoutContainer(formLayout); |
Radio rbEstDecedee = new Radio(); |
rbEstDecedee.setId("ce_deces"); |
rbEstDecedee.setBoxLabel("oui"); |
rbEstDecedee.setValueAttribute("1"); |
rbEstDecedee.setId("rbEstD"); |
rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
if(((Radio) be.getComponent()).getValue().equals(true)) { |
hmIdentite.getTextField("tfDateDeces").setVisible(true); |
hmIdentite.getTextField("tfLieuDeces").setVisible(true); |
} else { |
TextField tfDateDeces = hmIdentite.getTextField("tfDateDeces"); |
tfDateDeces.setValue(null); |
tfDateDeces.setVisible(false); |
TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces"); |
tfLieuDeces.setValue(null); |
tfLieuDeces.setVisible(false); |
} |
} |
}); |
TextField tfDateDeces = new TextField(); |
tfDateDeces.setFieldLabel("Date de décès"); |
tfDateDeces.setVisible(false); |
containerDeces.add(tfDateDeces); |
hmIdentite.put("tfDateDeces", tfDateDeces); |
TextField<String> tfLieuDeces = new TextField<String>(); |
tfLieuDeces.setFieldLabel("Lieu de décès"); |
tfLieuDeces.setName("deces_lieu"); |
tfLieuDeces.setVisible(false); |
containerDeces.add(tfLieuDeces); |
hmIdentite.put("tfLieuDeces", tfLieuDeces); |
hmIdentite.put("rbEstDecedee", rbEstDecedee); |
Radio rbNestPasDecedee = new Radio(); |
rbNestPasDecedee.setValueAttribute("0"); |
rbNestPasDecedee.setBoxLabel("non"); |
rbNestPasDecedee.setValue(true); |
RadioGroup rbgDeces = new RadioGroup(); |
rbgDeces.setId("rbgDeces"); |
rbgDeces.setFieldLabel("Est décédée"); |
rbgDeces.add(rbEstDecedee); |
rbgDeces.add(rbNestPasDecedee); |
hmIdentite.put("rbgDeces", rbgDeces); |
containerDeces.add(rbgDeces); |
fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5)); |
tiIdentite.add(main); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset CONTACT |
FieldSet fsContact = new FieldSet(); |
fsContact.setHeadingHtml("Contact"); |
fsContact.setWidth("95%"); |
fsContact.setLayout(new RowLayout()); |
ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100); |
telephones.initialiserType("tel"); |
fsContact.add(telephones, new FormData(450, 0)); |
hmIdentite.put("telephones", telephones); |
ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280); |
courriels.setValidation(Pattern.email, "moi@domaine.fr"); |
fsContact.add(courriels, new FormData(450, 0)); |
hmIdentite.put("courriels", courriels); |
LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout()); |
fsContact.add(lcCourrielContainer); |
hmIdentite.put("lcCourrielContainer", lcCourrielContainer); |
fsContact.add(new Text("")); |
ChampMultiValeurs sites = new ChampMultiValeurs("Sites web"); |
sites.setWidth("95%"); |
sites.setValeurParDefaut("http://"); |
sites.setValidation(Pattern.url, "http://www.monsite.com"); |
fsContact.add(sites); |
hmIdentite.put("sites", sites); |
right.add(fsContact); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset AUTRES INFOS |
FieldSet fsAutresInfos = new FieldSet(); |
fsAutresInfos.setHeadingHtml("Autres informations"); |
fsAutresInfos.setWidth("95%"); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.LEFT); |
fsAutresInfos.setLayout(formLayout); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.TOP); |
LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout); |
ListStore<Valeur> storeSexe = new ListStore<Valeur>(); |
ComboBox<Valeur> cbSexe = new ComboBox<Valeur>(); |
cbSexe.setStore(storeSexe); |
cbSexe.setFieldLabel("Sexe"); |
cbSexe.setDisplayField("nom"); |
cbSexe.setEmptyText("Choisissez le sexe:"); |
cbSexe.setTypeAhead(true); |
cbSexe.setTriggerAction(TriggerAction.ALL); |
FormData fd = new FormData(); |
fd.setWidth(100); |
lcAutreInformations1.add(cbSexe, fd); |
hmIdentite.put("cbSexe", cbSexe); |
mediateur.obtenirListeValeurEtRafraichir(this, "sexe", sequenceur); |
//Description |
final TextArea taDescription = new TextArea(); |
taDescription.setEmptyText("Saisissez une description"); |
taDescription.setFieldLabel("Description"); |
taDescription.setName("description"); |
lcAutreInformations1.add(taDescription, new FormData(300, 200)); |
hmIdentite.put("taDescription", taDescription); |
fsAutresInfos.add(lcAutreInformations1); |
// Logo |
LayoutContainer lcLogoUrl = new LayoutContainer(); |
hmIdentite.put("lcLogoUrl", lcLogoUrl); |
final ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos()); |
logo.setImageHeight("150px"); |
logo.setValeurParDefaut("http://"); |
logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg"); |
logo.setValeurBoutonSupprimer("Supprimer"); |
logo.setWidth("95%"); |
hmIdentite.put("logos", logo); |
lcLogoUrl.add(logo); |
fsAutresInfos.add(logo); |
LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout()); |
hmIdentite.put("lcAutreInformations2", lcAutreInformations2); |
fsAutresInfos.add(lcAutreInformations2); |
right.add(fsAutresInfos); |
//+------------------------------------------------------------------------------------------------------------+ |
// Ajout des évènements saisi |
KeyListener klNoms = new KeyListener() { |
public void componentKeyUp(ComponentEvent ev) { |
rafraichir(null); |
} |
}; |
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() { |
public void selectionChanged(SelectionChangedEvent se) { |
rafraichir(null); |
} |
}; |
cbPrefixe.addSelectionChangedListener(selectionChange); |
cbPrefixe.addKeyListener(klNoms); |
tfPrenom.addKeyListener(klNoms); |
tfNom.addKeyListener(klNoms); |
cbSuffixe.addSelectionChangedListener(selectionChange); |
} |
public void creerComposantsAdresse() { |
// Gauche |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
left.setStyleAttribute("padding", "15px"); |
// Droite |
LayoutContainer right = new LayoutContainer(); |
right.setLayout(new FormLayout()); |
// Principal |
LayoutContainer main = new LayoutContainer(); |
main.setLayout(new TableLayout(2)); |
// Ajout au principal |
main.add(left); |
main.add(right); |
TextField<String> tfAdresse1 = new TextField(); |
tfAdresse1.setFieldLabel("Adresse"); |
tfAdresse1.setName("adresse_01"); |
left.add(tfAdresse1, fd100); |
hmAdresse.put("tfAdresse1", tfAdresse1); |
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, fd100); |
hmAdresse.put("cbPays", cbPays); |
TextField<String> tfBoitePostale = new TextField<String>(); |
tfBoitePostale.setFieldLabel("Boite postale"); |
tfBoitePostale.setName("bp"); |
left.add(tfBoitePostale, fd100); |
hmAdresse.put("tfBoitePostale", tfBoitePostale); |
TextField<Integer> tfCodePostal = new TextField<Integer>(); |
tfCodePostal.setFieldLabel("Code postal"); |
tfCodePostal.setName("code_postal"); |
right.add(tfCodePostal, fd100); |
hmAdresse.put("tfCodePostal", tfCodePostal); |
TextField tfVille = new TextField(); |
tfVille.setFieldLabel("Ville"); |
tfVille.setName("ville"); |
right.add(tfVille, fd100); |
hmAdresse.put("tfVille", tfVille); |
// MAJ ComboBox |
mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur); |
FieldSet fsAdresse = new FieldSet(); |
fsAdresse.setHeadingHtml("Adresse personnelle"); |
fsAdresse.add(main); |
tiAdresses.add(fsAdresse); |
} |
public void creerComposantsInfosNat() { |
FormLayout fl = new FormLayout(); |
fl.setLabelAlign(LabelAlign.TOP); |
FieldSet fsInfosNat = new FieldSet(); |
fsInfosNat.setLayout(fl); |
fsInfosNat.setTitle("Informations Naturaliste"); |
TextArea taBiographie = new TextArea(); |
taBiographie.setFieldLabel("Vie et renommée de l'auteur"); |
taBiographie.setWidth("400"); |
taBiographie.setName("biographie"); |
fsInfosNat.add(taBiographie, new FormData(800, 200)); |
ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite()); |
fsInfosNat.add(specialite); |
hmInfosNat.put("specialite", specialite); |
ModelType typeTypes = new ModelType(); |
typeTypes.setRoot("valeurs"); |
typeTypes.setTotalName("nbElements"); |
typeTypes.addField("cmlv_nom"); |
typeTypes.addField("cmlv_id_valeur"); |
typeTypes.addField("cmlv_abreviation"); |
typeTypes.addField("cmlv_description"); |
String displayNameTypes = "cmlv_nom"; |
String nomListeTypes = "pays"; |
ProxyValeur<ModelData> proxyTypes = new ProxyValeur<ModelData>(nomListeTypes, null); |
ChampMultiValeursMultiTypesPaginable recolte = new ChampMultiValeursMultiTypesPaginable(i18nC.personneRecolte(), 450, false, null, null, null, typeTypes, proxyTypes, displayNameTypes); |
hmInfosNat.put("recolte", recolte); |
fsInfosNat.add(recolte); |
tiInfosNat.add(fsInfosNat); |
} |
public void creerComposantsPubli(){ |
//Création des composants de l'onglet publication |
ContentPanel cp = new ContentPanel(); |
cp.setHeadingHtml("Publications dont la personne est le sujet"); |
cp.setIcon(Images.ICONES.table()); |
cp.setLayout(new FitLayout()); |
cp.setFrame(true); |
ToolBar toolBar = new ToolBar(); |
Button ajouterPubli = new Button("Ajouter"); |
ajouterPubli.setIcon(Images.ICONES.vcardAjouter()); |
ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel);*/ |
} |
}); |
toolBar.add(ajouterPubli); |
toolBar.add(new SeparatorToolItem()); |
Button supprimerPubli = new Button("Supprimer"); |
supprimerPubli.setIcon(Images.ICONES.vcardSupprimer()); |
supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem(); |
if (personne != null) { |
// Ajout de la personne supprimée à la liste |
if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) { |
personnelSupprime.put(personne.getId(), personne); |
} |
// Suppression de l'enregistrement de la grille |
grillePersonnel.getStore().remove(personne); |
// Désactivation du bouton supprimer si la grille contient plus d'élément |
if (grillePersonnel.getStore().getCount() == 0) { |
//TODO : check : Item -> component |
ce.getComponent().disable(); |
} |
}*/ |
Window.alert("supprimer"); |
} |
}); |
toolBar.add(supprimerPubli); |
toolBar.add(new SeparatorToolItem()); |
Button rafraichirPersonnelBtn = new Button("Rafraichir"); |
rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir()); |
rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
//rafraichirPersonnel(); |
Window.alert("rafraichir"); |
} |
}); |
toolBar.add(rafraichirPersonnelBtn); |
//Ajout d'une ComboBox |
storePubli = new ListStore<Publication>(); |
storePubli.add(new ArrayList<Publication>()); |
cbPubli = new ComboBox<Publication>(); |
cbPubli.setWidth(200); |
cbPubli.setEmptyText("Chercher une publication existante..."); |
cbPubli.setTriggerAction(TriggerAction.ALL); |
cbPubli.setEditable(true); |
cbPubli.setDisplayField("fmt_nom_complet"); |
cbPubli.setStore(storePubli); |
cbPubli.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) { |
rafraichirPublicationsExistante(cbPubli.getRawValue()); |
} |
} |
}); |
toolBar.add(cbPubli); |
toolBar.add(new SeparatorToolItem()); |
cp.setTopComponent(toolBar); |
tiPubli.add(cp); |
} |
public void rafraichirPublicationsExistante(String nomPubli) { |
nomPubli +="%"; |
mediateur.selectionnerPublicationParNomComplet(this, nomPubli); |
} |
/** |
* Ajouter le bouton annuler à la barre d'outils donnée |
* |
* @param barreOutils la barre d'outils à modifier |
* */ |
public static void ajouterBoutonAnnuler(ButtonBar barreOutils) { |
// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente |
Button annuler = new Button("Revenir à la liste"); |
annuler.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes"); |
} |
}); |
annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER); |
barreOutils.add(annuler); |
} |
// RAFRAICHISSEMENT DU PANNEAU |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof PublicationAPersonneListe) { |
Information info = new Information(); |
info.setType("publication_liees"); |
info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees); |
tiPubli.rafraichir(info); |
} else if (nouvellesDonnees instanceof ValeurListe) { |
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();) { |
liste.add(listeValeurs.get(it.next())); |
} |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) { |
tiPubli.rafraichir(nouvellesDonnees); |
} else 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"))) { |
//Ajout de la valeur "Inconnu" |
ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe"); |
Valeur inconnu = new Valeur(); |
inconnu.set("nom", "Inconnu"); |
inconnu.set("id", "0"); |
liste.add(0, inconnu); |
remplirCombobox("cbSexe", liste, "hmIdentite"); |
/*List<Valeur> selection = new LinkedList<Valeur>(); |
selection.add(inconnu); |
cbSexe.setSelection(s);*/ |
} else if (listeValeurs.getId().equals(config.getListeId("tel"))) { |
remplirCombobox("cbTelephone", liste, "hmIdentite"); |
//Préselection du tél |
ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone"); |
cbTelephone.setValue(liste.get(1)); |
} else if (listeValeurs.getId().equals(config.getListeId("pays"))) { |
remplirCombobox("cbPays", liste, "hmAdresse"); |
} |
} else if (nouvellesDonnees instanceof PublicationListe) { |
PublicationListe publicationListe = (PublicationListe) nouvellesDonnees; |
List<Publication> liste = publicationListe.toList(); |
storePubli.removeAll(); |
storePubli.add(liste); |
cbPubli.setStore(storePubli); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("ajout_personne")) { |
if (info.getDonnee(0) != null) { |
personneSelectionnee.setId(info.getDonnee(0).toString()); |
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null); |
this.personne = personneSelectionnee; |
this.personneId = personneSelectionnee.getId(); |
InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")"); |
repandreRafraichissement(); |
if (clicBoutonvalidation) { |
mediateur.clicMenu(menuIdCourant); |
} else { |
this.mode = MODE_MODIFIER; |
} |
} else { |
InfoLogger.display("Enregistrement", info.getMessages().toString()); |
} |
} else if (info.getType().equals("modification_personne")) { |
InfoLogger.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées."); |
repandreRafraichissement(); |
controlerFermeture(); |
} 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(); |
//TODO : Je vois pas l'intérêt des lignes ci dessous.. |
personneSauvegarde = new Personne(); |
personneSauvegarde = (Personne) personne.cloner(personneSauvegarde); |
binderPersonne(personne); |
mettreAJourPersonne(personne); |
this.personne = personne; |
this.personneId = personne.getId(); |
tiPubli.rafraichirInformation(new Information("personne")); |
nouvellesDonnees = null; |
} else { |
InfoLogger.display("messages", info.getMessages().toString()); |
} |
} |
if (nouvellesDonnees == null) { |
ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe"); |
//Met à jour le nom Complet du formulaire |
String valeurRetour = ""; |
// Prefixe |
String prefixe = ""; |
Valeur valPrefixe = cb.getValue(); |
if (valPrefixe != null) { |
prefixe = valPrefixe.getNom(); |
} else { |
prefixe = (String) cb.getRawValue(); |
} |
// Prénom |
String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue(); |
// Nom |
String nom = (String) hmIdentite.getTextField("tfNom").getValue(); |
// Suffixe |
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe"); |
String suffixe = ""; |
Valeur valSuffixe = cbSuffixe.getValue(); |
if (valSuffixe != null) { |
suffixe = valSuffixe.getNom(); |
} else { |
suffixe = (String) cbSuffixe.getRawValue(); |
} |
// Mettre à jour la valeur |
valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe; |
valeurRetour = valeurRetour.replaceAll("null", ""); |
hmIdentite.getLabelField("nomComplet").setValue(valeurRetour); |
if (!valeurRetour.trim().equals("")) { |
hmIdentite.getLabelField("nomComplet").show(); |
} else { |
hmIdentite.getLabelField("nomComplet").hide(); |
} |
} |
mediateur.masquerPopinChargement(); |
if (this.mode.equals(MODE_AJOUTER)) { |
gererEtatActivationBouton(); |
} |
} |
private void repandreRafraichissement() { |
if (vueExterneARafraichirApresValidation != null) { |
String type = "personne_modifiee"; |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
type = "personne_ajoutee"; |
} |
Information info = new Information(type); |
info.setDonnee(0, personneSelectionnee); |
vueExterneARafraichirApresValidation.rafraichir(info); |
} |
} |
private void mettreAJourPersonne(Personne personne) { |
//Mise à jour de la personne |
//Prefixe |
String prefixe = personne.get("ce_truk_prefix"); |
ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("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); |
} |
hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom")); |
hmIdentite.getTextField("tfNom").setValue(personne.get("nom")); |
//Suffixe |
String suffixe = personne.get("ce_truk_suffixe"); |
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("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); |
} |
hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre")); |
hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation")); |
hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre")); |
hmIdentite.getTextField("tfDateNaissance").setValue(personne.getAnneeOuDateNaiss()); |
hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu")); |
if (personne.estDecedee()) { |
hmIdentite.getTextField("tfDateDeces").setValue(personne.getAnneeOuDateDeces()); |
hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu")); |
Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee"); |
rbEstDecede.setValue(true); |
} |
hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone")); |
//Courriel |
hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel()); |
//Sites web |
hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url")); |
// Sexe |
String strSexe = personne.get("ce_sexe"); |
ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe"); |
if (cbSexe.getStore().findModel("id_valeur", strSexe) != null) { |
cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe)); |
} |
hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description")); |
//Logo |
hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo")); |
/*-------------------------------------------------- |
Adresse |
---------------------------------------------------*/ |
// Adresse |
hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01")); |
//Boite postale |
hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp")); |
//Pays |
String strPays = personne.get("ce_truk_pays"); |
ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays"); |
cbPays.getStore().sort("nom", SortDir.ASC); |
if (cbPays.getStore().findModel("id_valeur", strPays) != null) { |
cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays)); |
cbPays.fireEvent(Events.OnChange); |
} else { |
cbPays.setRawValue(strPays); |
} |
//Cp |
hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal")); |
//Ville |
hmAdresse.getTextField("tfVille").setValue(personne.get("ville")); |
/*-------------------------------------------------------- |
* Infos naturalistes |
* -----------------------------------------------------*/ |
hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite")); |
String tr = personne.getString("truk_recolte"); |
hmInfosNat.getChampMultiValeursMultiTypesPaginable("recolte").peupler(tr); |
//Onglet publi |
tiPubli.mettreAJourPersonne(); |
gererEtatActivationBouton(); |
} |
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); |
} |
private void gererEtatActivationBouton() { |
/* if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false) { |
enregistrer.setEnabled(false); |
enregistrerEtRevenir.setEnabled(false); |
} else { |
enregistrer.setEnabled(true); |
enregistrerEtRevenir.setEnabled(true); |
}*/ |
} |
public void binderPersonne(Personne personne) { |
binding = new FormBinding(getFormulaire()); |
personneSelectionnee = personne; |
FieldBinding f = new FieldBinding((RadioGroup) hmIdentite.get("rbgDeces"), null); |
binding.autoBind(); |
binding.removeFieldBinding(f); |
binding.bind(personneSelectionnee); |
layout(); |
} |
private String obtenirValeurCombo(String strComboName) { |
String strValeur = ""; |
Valeur valeur; |
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName); |
if (combo == null) { |
combo = hmAdresse.getComboBoxValeur(strComboName); |
} |
strValeur = combo.getRawValue(); |
valeur = combo.getValue(); |
if (valeur != null) { |
strValeur = valeur.getId(); |
} |
return strValeur; |
} |
public boolean soumettreFormulaire() { |
tiPubli.collecter(); |
if (verifierFormulaire()) { |
tiPubli.soumettre(); |
mediateur.enregistrerPersonne(this, personneSelectionnee); |
return true; |
} |
else return false; |
} |
public boolean verifierFormulaire() { |
boolean success = true; |
LinkedList<String> lstMessageErreur = new LinkedList<String>(); |
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.getComboBox("cbSuffixe"); |
valeur = combo.getValue(); |
if (valeur != null) { |
strSuffixe = valeur.getNom() + " "; |
} else { |
strSuffixe = combo.getRawValue() +" "; |
} |
personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe); |
/** NAISSANCE **/ |
String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue(); |
traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur); |
/** DECES **/ |
Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee"); |
if (rbEstDecedee.getValue() == true) { |
// date |
String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue(); |
traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur); |
// lieu |
String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue(); |
personneSelectionnee.setDecesLieu(decesLieu); |
} else { |
personneSelectionnee.setNonDecedee(); |
} |
strValeur = obtenirValeurCombo("cbPays"); |
personneSelectionnee.set("ce_truk_pays", strValeur); |
success = hmIdentite.getChampMultiValeursMultiTypes("telephones").estValide(true); |
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 = ((ChampMultiValeursMultiTypesPaginable) hmInfosNat.get("recolte")).getValeurs(); |
personneSelectionnee.set("truk_recolte", recolte); |
String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs(); |
personneSelectionnee.set("ce_truk_specialite", specialite); |
lstMessageErreur.addAll(tiPubli.verifier()); |
if (lstMessageErreur.size() != 0) { |
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 void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) { |
String valeurDate = date; |
if (!UtilString.isEmpty(valeurDate)){ |
String jour = ""; |
String mois = ""; |
String annee = ""; |
String dateComplete = ""; |
String messageErreur = null; |
/** JJ/MM/AAAA **/ |
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) { |
jour = valeurDate.substring(0,2); |
mois = valeurDate.substring(3,5); |
annee = valeurDate.substring(6,10); |
if (jour.equals("00") || mois.equals("00") || annee.equals("0000")) { |
messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."; |
} else { |
dateComplete = annee+"-"+mois+"-"+jour; |
} |
/** MM/AAAA **/ |
} else if (valeurDate.matches("\\d{2}/\\d{4}")) { |
jour = "00"; |
mois = valeurDate.substring(0,2); |
annee = valeurDate.substring(3,7); |
if (mois.equals("00") || annee.equals("0000")) { |
messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."; |
} else { |
dateComplete = annee+"-"+mois+"-"+jour; |
} |
} |
/** AAAA **/ |
else if (valeurDate.matches("\\d{4}")) { |
if (valeurDate.equals("0000")) { |
messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."; |
} |
else { |
dateComplete = valeurDate + "-00-00"; |
} |
} |
else { |
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."); |
} |
if (messageErreur == null) { |
if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete); |
else if (typeDate=="décès") { |
personneSelectionnee.set("deces_date", dateComplete); |
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE); |
} |
} else { |
lstMessageErreur.add(messageErreur); |
} |
if(typeDate.equals("décès")) { |
String valeurDateDeces = hmIdentite.getTextField("tfDateDeces").getRawValue(); |
String valeurDateNaissance = hmIdentite.getTextField("tfDateNaissance").getRawValue(); |
if(valeurDateDeces != null && valeurDateNaissance != null && |
!valeurDateDeces.isEmpty() && !valeurDateNaissance.isEmpty()) { |
Date dateNaissance = parserDate(valeurDateNaissance); |
Date dateDeces = parserDate(valeurDateDeces); |
if(dateDeces.compareTo(dateNaissance) < 0) { |
lstMessageErreur.add("La date de décès ne peut pas précéder la date de naissance"); |
} |
} |
} |
/** Date vide **/ |
} else { |
if (typeDate=="naissance") { |
personneSelectionnee.setNaissanceDate(null); |
} else if (typeDate=="décès") { |
personneSelectionnee.setDecesDate(null); |
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE); |
} |
} |
} |
private Date parserDate(String valeurDate) { |
Date dateParsee = new Date(); |
String[] composantsDate = valeurDate.split("/"); |
// Attention : la fonction setYear ajoute 1900 à l'année |
int annee = Integer.parseInt(composantsDate[(composantsDate.length-1)]) - 1900; |
// Attention : les mois commencent à 0, donc janvier = 0, février = 1 |
int mois = (composantsDate.length > 1) ? Integer.parseInt(composantsDate[(composantsDate.length-2)]) - 1 : 0; |
int jour = (composantsDate.length > 2) ? Integer.parseInt(composantsDate[0]) : 1; |
dateParsee.setYear(annee); |
dateParsee.setMonth(mois); |
dateParsee.setDate(jour); |
return dateParsee; |
} |
public Personne getPersonne() { |
return this.personne; |
} |
public String getPersonneId() { |
return this.personneId; |
} |
private Listener<BaseEvent> creerEcouteurNomPrenomExistant() { |
return new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
if(mode.equals(MODE_AJOUTER) && !verificationDoublonEffectuee) { |
TextField<String> nom = (TextField<String>) hmIdentite.get("tfNom"); |
TextField<String> prenom = (TextField<String>) hmIdentite.get("tfPrenom"); |
LabelField nomComplet = (LabelField) hmIdentite.get("nomComplet"); |
if(nom.getValue() != null && !nom.getValue().isEmpty()) { |
PersonneAsyncDao dao = new PersonneAsyncDao(PersonneForm.this); |
// Suppression d'éventuels doubles espaces (ou plus) et ajout d'un joker devant |
// (pour gérer la recherche lorsqu'on a qu'un nom de famille) |
String nomCompletStr = "%"+nomComplet.getValue().toString().trim().replaceAll(" +", " "); |
if(prenom.getValue() != null && !prenom.getValue().isEmpty()) { |
// Ajouter un % derrière le prénom permet de gérer facilement le cas de l'initiale |
// et également de rechercher des noms potentiels si l'on a saisi qu'une initiale |
nomCompletStr = nomCompletStr.replaceAll(prenom+" ", prenom+"%"); |
} |
dao.testerExistencePersonne(nomCompletStr, new Callback<JSONObject, String>() { |
@Override |
public void onSuccess(JSONObject objet) { |
String message = formaterMessageAvertissementDoublon(objet); |
verificationDoublonEffectuee = true; |
if(!message.isEmpty()) { |
Window.alert(message); |
} |
} |
@Override |
public void onFailure(String reason) { |
// TODO Auto-generated method stub |
} |
}); |
} |
} |
} |
}; |
} |
private String formaterMessageAvertissementDoublon(JSONObject objet) { |
double nbPers = objet.get("nbElements").isNumber().getValue(); |
JSONArray personnes = objet.isObject().get("personnes").isArray(); |
String message = ""; |
if(nbPers > 0) { |
String pers = nbPers == 1 ? "personne" : "personnes"; |
String exist = nbPers == 1 ? "existe" : "existent"; |
message = "Attention : "+(int)nbPers+" "+pers+" portant ce nom "+exist+" déjà"+"\n"; |
for(int i = 0; i < personnes.size(); i++) { |
message += "- "+personnes.get(i).isObject().get("cp_fmt_nom_complet").isString().stringValue(); |
if(personnes.get(i).isObject().get("cp_ville") != null && personnes.get(i).isObject().get("cp_ville").isString() != null) { |
message += " à "+personnes.get(i).isObject().get("cp_ville").isString().stringValue(); |
} |
if(personnes.get(i).isObject().get("cp_naissance_date") != null |
&& personnes.get(i).isObject().get("cp_naissance_date").isString()!= null |
&& !personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue().equals("0000-00-00")) { |
String dateChaine = personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue(); |
String dateNaissance = ""; |
// Quelque fois on ne possède que l'année de naissance de la personne, |
// dans ce cas là la date est de la forme XXXX-00-00 |
if(dateChaine.endsWith("-00-00")) { |
dateNaissance = dateChaine.substring(0, 4); |
} else { |
dateNaissance = UtilDate.formaterEnStringFormatFr(UtilString.formaterEnDate(dateChaine)); |
} |
message += ", date de naissance : "+dateNaissance; |
} |
message += "\n"; |
} |
} |
return message; |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r1136-1368 |
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r11-934,1209-1382 |
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r1383-1511 |
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java |
---|
New file |
0,0 → 1,728 |
package org.tela_botanica.client.vues.personne; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.LinkedList; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable; |
import org.tela_botanica.client.composants.GrillePaginable; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPublication; |
import org.tela_botanica.client.composants.pagination.ProxyPublications; |
import org.tela_botanica.client.composants.pagination.ProxyPublicationsAPersonne; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.FenetreForm; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireBarreValidation; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import org.tela_botanica.client.vues.publication.PublicationForm; |
import com.extjs.gxt.ui.client.core.XTemplate; |
import com.extjs.gxt.ui.client.data.ModelData; |
import com.extjs.gxt.ui.client.data.ModelType; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.store.Store; |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
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; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.Field; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; |
import com.extjs.gxt.ui.client.widget.grid.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.RowExpander; |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class PersonneFormPublication extends FormulaireOnglet implements Rafraichissable { |
private Personne personneSelectionnee = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private GrillePaginable<ModelData> grille; |
private PublicationAPersonneListe publicationsAjoutees = null; |
private PublicationAPersonneListe publicationsSupprimees = null; |
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null; |
private Button publicationsBoutonSupprimer = null; |
private Button publicationsBoutonModifier = null; |
private ComboBox<Valeur> typeRelationCombo = null; |
private List<Valeur> roles = null; |
private PublicationAPersonneListe listePublicationsLiees = new PublicationAPersonneListe(); |
boolean personneRecue = false; |
boolean rolesRecus = false; |
private FenetreForm fenetreFormulaire = null; |
public PersonneFormPublication(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId("publication"); |
setText(Mediateur.i18nC.personneOngletPublication()); |
setStyleAttribute("padding", "0"); |
initialiser(); |
panneauPrincipal = creerPanneauContenantGrille(); |
setLayout(new FitLayout()); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
panneauPrincipal.setLayout(new FitLayout()); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
add(panneauPrincipal); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
idGenere = 1; |
publicationsAjoutees = new PublicationAPersonneListe(); |
publicationsSupprimees = new PublicationAPersonneListe(); |
} |
public void mettreAJourPersonne() { |
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeadingHtml(i18nC.personneOngletPublication()+" " + i18nC.personnePublication()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis(); |
barreOutils.add(publicationsSaisiesComboBox); |
barreOutils.add(new Text(" ou ")); |
Button ajouterBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonModifier = creerBoutonModifier(); |
barreOutils.add(publicationsBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(publicationsBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
} |
private Button creerBoutonModifier() { |
Button bouton = new Button(i18nC.modifier()); |
bouton.setIcon(Images.ICONES.vcardModifier()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
ModelData publicationSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String publicationId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
PublicationAPersonne publicationSaisiSelectionne = new PublicationAPersonne(grille.getGrille().getSelectionModel().getSelectedItem(), false); |
publicationId = publicationSaisiSelectionne.getIdPublication(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) { |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this); |
FormPanel panneauFormulaire = formulairePublication.getFormulaire(); |
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre. |
panneauFormulaire.getBottomComponent().hide(); |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulairePublication; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
List<ModelData> listeDonneesSelectionnees = grille.getGrille().getSelectionModel().getSelectedItems(); |
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) { |
PublicationAPersonne publicationSaisieSelectionnee = new PublicationAPersonne(donneeSelectionnee, false); |
supprimerDansGrille(publicationSaisieSelectionnee, donneeSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), "%", null); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() { |
ModelType modelTypePublications = new ModelType(); |
modelTypePublications.setRoot("publications"); |
modelTypePublications.setTotalName("nbElements"); |
modelTypePublications.addField("ccapu_id_personne"); |
modelTypePublications.addField("ccapu_id_publication"); |
modelTypePublications.addField("cpu_id_publication"); |
modelTypePublications.addField("cpu_fmt_nom_complet"); |
modelTypePublications.addField("cpu_titre"); |
modelTypePublications.addField("cpu_nom"); |
modelTypePublications.addField("cpu_fmt_auteur"); |
modelTypePublications.addField("cpu_indication_nvt"); |
modelTypePublications.addField("cpu_truk_pages"); |
modelTypePublications.addField("cpu_fascicule"); |
modelTypePublications.addField("cpu_date_parution"); |
modelTypePublications.addField("cpu_ce_truk_editeur"); |
modelTypePublications.addField("cpu_collection"); |
String displayNamePublications = "cpu_fmt_nom_complet"; |
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null); |
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications); |
publicationsCombo.getCombo().setTabIndex(tabIndex++); |
publicationsCombo.getCombo().setForceSelection(true); |
publicationsCombo.getCombo().setValidator(new Validator() { |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
publicationsCombo.getCombo().setEmptyText("Rechercher et sélectionner une publication existante dans la base"); |
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) { |
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur(), false); |
ajouterDansGrille(publicationSaisieSelectionne); |
publicationsSaisiesComboBox.getCombo().setValue(null); |
} |
} |
}); |
return publicationsCombo; |
} |
private void ajouterDansGrille(Publication publication) { |
ajouterDansGrille(publication, 0); |
} |
private void ajouterDansGrille(Publication publication, int index) { |
if (publication != null) { |
if (!listePublicationsLiees.containsKey(publication.getId())) { |
PublicationAPersonne publicationLiee = new PublicationAPersonne(false); |
publicationLiee.setPersonne(personneSelectionnee); |
publicationLiee.setPublicationLiee(publication); |
publicationLiee.setIdPublication(publication.getId()); |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE); |
listePublicationsLiees.put(publication.getId(), publicationLiee); |
// Ajout à la grille |
grille.getGrille().stopEditing(); |
grille.getGrille().getStore().insert(publicationLiee, 0); |
grille.getGrille().startEditing(index, 0); |
grille.getGrille().getSelectionModel().select(index, false); |
} else { |
InfoLogger.display("Information", "La publication choisie existe déjà dans la liste."); |
} |
} |
} |
/** |
* Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees |
*/ |
private void mettreAJourGrille() { |
grille.getStore().removeAll(); |
grille.getStore().add(listePublicationsLiees.toList()); |
} |
private void supprimerDansGrille(PublicationAPersonne publicationLiee, ModelData publicationLieeModele) { |
if (publicationLiee != null) { |
// Ajout de la personne supprimée à la liste |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& publicationLiee.getId() != null |
&& !publicationLiee.getId().equals("")) { |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(publicationLieeModele); |
} |
} |
private GrillePaginable<ModelData> creerGrille() { |
GrillePaginable<ModelData> grillePublications = null; |
// ModelType |
ModelType modelTypePublicationAPersonne = new ModelType(); |
modelTypePublicationAPersonne.setRoot("publicationsAPersonne"); |
modelTypePublicationAPersonne.setTotalName("nbElements"); |
modelTypePublicationAPersonne.addField("cpuap_id_personne"); |
modelTypePublicationAPersonne.addField("cpuap_id_publication"); |
modelTypePublicationAPersonne.addField("cpuap_id_role"); |
modelTypePublicationAPersonne.addField("cpu_id_publication"); |
modelTypePublicationAPersonne.addField("cpu_fmt_auteur"); |
modelTypePublicationAPersonne.addField("cpu_titre"); |
modelTypePublicationAPersonne.addField("cpu_collection"); |
modelTypePublicationAPersonne.addField("cpu_ce_truk_editeur"); |
modelTypePublicationAPersonne.addField("cpu_date_parution"); |
modelTypePublicationAPersonne.addField("cpu_fascicule"); |
modelTypePublicationAPersonne.addField("cpu_truk_pages"); |
modelTypePublicationAPersonne.addField("cpu_indication_nvt"); |
// Proxy |
ProxyPublicationsAPersonne<ModelData> proxyPublicationsAPersonne = new ProxyPublicationsAPersonne<ModelData>(null, null, null); |
// Colonnes |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
RowNumberer numeroPlugin = new RowNumberer(); |
numeroPlugin.setHeaderHtml("#"); |
XTemplate infoTpl = XTemplate.create("<p>"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {cpu_fmt_auteur}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {cpu_titre}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {cpu_collection}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+ |
"</p>"); |
RowExpander expansionPlugin = new RowExpander(); |
expansionPlugin.setTemplate(infoTpl); |
colonnes.add(expansionPlugin); |
colonnes.add(numeroPlugin); |
colonnes.add(creerColonneTypeRelation()); |
colonnes.add(new ColumnConfig("cpu_fmt_auteur", i18nC.publicationAuteurs(), 150)); |
colonnes.add(new ColumnConfig("cpu_titre", i18nC.publicationTitre(), 150)); |
colonnes.add(new ColumnConfig("cpu_collection", i18nC.publicationRevueCollection(), 75)); |
colonnes.add(creerColonneEditeur()); |
colonnes.add(creerColonneAnneePublication()); |
colonnes.add(new ColumnConfig("cpu_indication_nvt", i18nC.publicationNvt(), 75)); |
colonnes.add(new ColumnConfig("cpu_fascicule", i18nC.publicationFascicule(), 75)); |
colonnes.add(new ColumnConfig("cpu_truk_pages", i18nC.publicationPage(), 50)); |
HashMap<String, String> virtualFields = new HashMap<String, String>(); |
virtualFields.put("_editeur_", "cpu_ce_truk_editeur"); |
virtualFields.put("_annee_", "cpu_date_parution"); |
virtualFields.put("_role_", "cpuap_id_role"); |
virtualFields.put("_etat_", ""); |
// Modele de selection |
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info"); |
// Grille |
grillePublications = new GrillePaginable<ModelData>(modelTypePublicationAPersonne, virtualFields, proxyPublicationsAPersonne, colonnes, modeleDeColonnes); |
grillePublications.getGrille().setBorders(true); |
grillePublications.getGrille().setSelectionModel(modeleDeSelection); |
grillePublications.getGrille().addPlugin(expansionPlugin); |
grillePublications.getGrille().addPlugin(numeroPlugin); |
grillePublications.getGrille().getView().setForceFit(true); |
grillePublications.getGrille().setAutoExpandColumn("titre"); |
grillePublications.getGrille().setStripeRows(true); |
grillePublications.getGrille().setTrackMouseOver(true); |
// Rajouter des écouteurs |
grillePublications.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() { |
public void handleEvent(StoreEvent<ModelData> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
grillePublications.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() { |
public void handleEvent(StoreEvent<ModelData> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
grillePublications.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() { |
public void handleEvent(StoreEvent<ModelData> ce) { |
if (ce.getModel().get("_role_") != null && ce.getRecord().isModified("_role_") && ce.getModel().get("_etat_") != null && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE); |
} |
} |
}); |
return grillePublications; |
} |
private ColumnConfig creerColonneEditeur() { |
GridCellRenderer<ModelData> editeurRendu = new GridCellRenderer<ModelData>() { |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) { |
PublicationAPersonne pap = new PublicationAPersonne(model, true); |
String editeur = pap.getPublicationLiee().getNomEditeur(); |
model.set("_editeur_", editeur); |
return editeur; |
} |
}; |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135); |
editeurColonne.setRenderer(editeurRendu); |
return editeurColonne; |
} |
private ColumnConfig creerColonneAnneePublication() { |
GridCellRenderer<ModelData> datePublicationRendu = new GridCellRenderer<ModelData>() { |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) { |
PublicationAPersonne pap = new PublicationAPersonne(model, true); |
String annee = pap.getPublicationLiee().getAnneeParution(); |
model.set("_annee_", annee); |
return annee; |
} |
}; |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75); |
datePublicationColonne.setRenderer(datePublicationRendu); |
return datePublicationColonne; |
} |
private ColumnConfig creerColonneTypeRelation() { |
typeRelationCombo = new ComboBox<Valeur>(); |
typeRelationCombo.setForceSelection(true); |
typeRelationCombo.setTriggerAction(TriggerAction.ALL); |
typeRelationCombo.setDisplayField("nom"); |
typeRelationCombo.setStore(new ListStore<Valeur>()); |
typeRelationCombo.setEditable(false); |
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire()); |
CellEditor editeurRelation = new CellEditor(typeRelationCombo) { |
public Object preProcessValue(Object valeur) { |
Valeur retour = null; |
if (valeur != null ) { |
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()); |
} |
} |
return retour; |
} |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof Valeur) { |
Valeur valeurOntologie = (Valeur) valeur; |
retour = valeurOntologie.getId(); |
} |
} |
return retour; |
} |
}; |
GridCellRenderer<ModelData> relationRendu = new GridCellRenderer<ModelData>() { |
public String render(ModelData modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grille) { |
// Gestion du texte afficher dans la cellule |
String role = modele.get("_role_"); |
String roleNom = ""; |
if (typeRelationCombo.getStore() != null && role!=null && role.matches("[0-9]+")) { |
if (typeRelationCombo.getStore().findModel("id_valeur", role) != null) { |
roleNom = typeRelationCombo.getStore().findModel("id_valeur", role).getNom(); |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId(); |
} else { Debug.log("role recherche="+role); |
Debug.log("typeRelationCombo.getStore().getCount()="+typeRelationCombo.getStore().getCount()); |
for(int i=0; i<typeRelationCombo.getStore().getCount(); i++) { |
Debug.log(""+typeRelationCombo.getStore().getAt(i)); |
} |
} |
} |
modele.set("_role_", role); |
return roleNom; |
} |
}; |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonne(), 75); |
typeRelationColonne.setEditor(editeurRelation); |
typeRelationColonne.setRenderer(relationRendu); |
return typeRelationColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
publicationsBoutonSupprimer.enable(); |
publicationsBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
publicationsBoutonSupprimer.disable(); |
publicationsBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) |
{ |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} |
else if (nouvellesDonnees instanceof ValeurListe) |
{ |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo); |
roles = listeValeurs.toList(); |
rolesRecus = true; |
((ProxyPublicationsAPersonne)grille.getProxy()).setRolesId(roles); |
if (rolesRecus && personneRecue) grille.reload(); |
} |
} |
else if (nouvellesDonnees instanceof PublicationAPersonneListe) |
{ |
PublicationAPersonneListe papl = (PublicationAPersonneListe) nouvellesDonnees; |
List<PublicationAPersonne> paplListe = papl.toList(); |
if (paplListe.size()>0){ |
Iterator<PublicationAPersonne> it = paplListe.iterator(); |
while (it.hasNext()) { |
PublicationAPersonne pap = it.next(); |
listePublicationsLiees.put(pap.getPublicationLiee().getId(), pap); |
} |
mettreAJourGrille(); |
} |
} |
else |
{ |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (type.equals("personne")) { |
mettreAJourPersonne(); |
((ProxyPublicationsAPersonne)grille.getProxy()).setPersonneId(personneSelectionnee.getId()); |
personneRecue = true; |
if (rolesRecus && personneRecue) grille.reload(); |
} else if (type.equals("publication_liees")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
personneSelectionnee.setPublicationsLiees((PublicationAPersonneListe) info.getDonnee(0)); |
peupler(); |
} |
} else if (type.equals("publication_modifiee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
ModelData publicationDansGrille = grille.getStore().findModel("cpu_id_publication", publication.getId()); |
int index = grille.getStore().indexOf(publicationDansGrille); |
grille.getStore().remove(publicationDansGrille); |
ajouterDansGrille(publication, index); |
} |
} else if (type.equals("publication_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
ajouterDansGrille(publication); |
} |
} else if (type.equals("ajout_publication_a_personne")) { |
InfoLogger.display("Ajout publication à personne", info.getDonnees().toString()); |
} else if (type.equals("suppression_publication_a_personne")) { |
InfoLogger.display("Suppression publication à personne", info.getMessages().toString()); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null); |
} |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(personneSelectionnee.getPublicationsLiees().toList()); |
layout(); |
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok()); |
} |
public void collecter() { |
if (etreAccede()) { |
int nbrePublication = grille.getStore().getCount(); |
for (int i = 0; i < nbrePublication; i++) { |
ModelData publicationLiee = grille.getStore().getAt(i); |
PublicationAPersonne pap = new PublicationAPersonne(publicationLiee, false); |
if (publicationLiee.get("_etat_") != null) { |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role |
publicationsSupprimees.put("id"+idGenere++, pap); |
PublicationAPersonne relationAAjouter = pap; |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter); |
} |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
publicationsAjoutees.put("id"+idGenere++, pap); |
} |
// Initialisation de la grille |
publicationLiee.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
public List verifier() { |
List lstMessageErreur = new LinkedList<String>(); |
//Vérifier les roles |
List<ModelData> listePublis = grille.getStore().getModels(); |
Iterator<ModelData> itPublis = listePublis.iterator(); |
while (itPublis.hasNext()) { |
ModelData publi = itPublis.next(); |
if (UtilString.isEmpty((String) publi.get("_role_"))) { |
lstMessageErreur.add("Vous devez choisir le rôle de la relation " + (grille.getStore().indexOf(publi) + 1)); |
} |
} |
return lstMessageErreur; |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) { |
//InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
// Ajout des relations PublicationAPersonne |
if (publicationsAjoutees.size() != 0) { |
//TODO : utiliser le role d'une liste déroulante |
mediateur.ajouterPublicationAPersonne(this, publicationsAjoutees, personneSelectionnee.getId(), null, null); |
} |
// Suppression des relations PublicationAPersonne |
if (publicationsSupprimees.size() != 0) { |
mediateur.supprimerPublicationAPersonne(this, publicationsSupprimees); |
} |
} |
} |
} |
private void obtenirPublicationsSaisies(String nom) { |
mediateur.selectionnerPublicationParNomComplet(this, "%"+nom+"%"); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java:r1136-1368 |
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java:r11-990,1209-1382 |
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java:r1383-1511 |