Rev 183 | Go to most recent revision | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.client.vues;
import java.util.List;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Personne;
import org.tela_botanica.client.modeles.Projet;
import org.tela_botanica.client.modeles.ProjetsListeAsyncDao;
import org.tela_botanica.client.modeles.Structure;
import org.tela_botanica.client.modeles.StructureListe;
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.layout.FitLayout;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
public class PersonneDetailPanneauVue extends TabPanel implements Rafraichissable {
private Html header;
//TABS
// Informations générales : nom, prénom, adresse, cp, ville, adresse email, sexe, projet
private TabItem infoGenerales;
private String contenuInfo = "<div style='padding: 12px;'><h1>{0}</h1><a href=\"{1}\">{1}</a><br /><br /><p><b>Adresse: </b>{2}<br />{3}<br />{4} {5}<br /> {7}</p><br />{6}</div>";
private TabItem infoBio;
private String contenuBio = "";
// <div style='padding: 12px;'><h1>{0} {1} {2}</h1><h2>{3}</h2><br><b>Date de naissance: </b>{4}<br /><b>Date de décès:{5}</b><p>{6}</p></div>";
public PersonneDetailPanneauVue() {
Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
setLayout(new FitLayout());
infoGenerales = new TabItem("Informations Générales");
this.add(infoGenerales);
infoBio = new TabItem("Biographie");
infoBio.disable();
this.add(infoBio);
}
private void ajouterParam(Params parametres, String nomChamp, Personne personne) {
Object valeur = personne.obtenirValeurChamp(nomChamp);
parametres.add(valeur);
}
public void afficherDetailPersonne(Personne personne) {
if (personne != null) {
infoGenerales.removeAll();
infoBio.removeAll();
infoBio.disable();
//Contenu
Params infoGenParams = new Params();
ajouterParam(infoGenParams, "fmt_nom_complet", personne);
ajouterParam(infoGenParams, "truk_courriel", personne);
ajouterParam(infoGenParams, "adresse_01", personne);
ajouterParam(infoGenParams, "adresse_02", personne);
ajouterParam(infoGenParams, "code_postal", personne);
ajouterParam(infoGenParams, "ville", personne);
ajouterParam(infoGenParams, "description", personne);
ajouterParam(infoGenParams, "cp_truk_fax", personne);
//Info générales
infoGenerales.addText(Format.substitute(contenuInfo, infoGenParams));
Params bioParams = new Params();
// Nécessaire que si une biographie existe...
// FIXME : remplacer par un id role?
if ((personne.obtenirValeurChamp("biographie")!=null)&&(!((String) personne.obtenirValeurChamp("biographie")).trim().equals(""))) {
contenuBio = "<div style='padding: 12px;'><h1>{0} {1} {2}</h1><h2>{3}</h2><br><b>Date de naissance: </b>{4}<br /><b>Date de décès:{5}</b><p>a{6}a</p></div>";
ajouterParam(bioParams, "ce_truk_prefix", personne);
ajouterParam(bioParams, "fmt_nom_complet", personne);
ajouterParam(bioParams, "ce_truk_suffix", personne);
ajouterParam(bioParams, "abreviation", personne);
ajouterParam(bioParams, "naissance_date", personne);
ajouterParam(bioParams, "deces_date", personne);
ajouterParam(bioParams, "biographie", personne);
infoBio.enable();
}
infoBio.addText(Format.substitute(contenuBio, bioParams));
layout();
} else {
header.setHtml("");
}
}
public void rafraichir(Object nouvelleDonnees) {
if (nouvelleDonnees instanceof Personne) {
afficherDetailPersonne((Personne) nouvelleDonnees);
} else if (nouvelleDonnees instanceof StructureListe) {
StructureListe listeInstitutions = (StructureListe) nouvelleDonnees;
// Test pour savoir si la liste contient des éléments
if (listeInstitutions.size() == 0) {
afficherDetailPersonne(null);
}
}
}
}