Rev 374 | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.client.vues;import java.util.Iterator;import java.util.Map.Entry;import org.tela_botanica.client.ComposantClass;import org.tela_botanica.client.ComposantId;import org.tela_botanica.client.Mediateur;import org.tela_botanica.client.interfaces.Rafraichissable;import org.tela_botanica.client.modeles.Information;import org.tela_botanica.client.modeles.Structure;import org.tela_botanica.client.modeles.StructureAPersonne;import org.tela_botanica.client.modeles.StructureAPersonneListe;import org.tela_botanica.client.modeles.StructureConservation;import org.tela_botanica.client.modeles.StructureValorisation;import com.extjs.gxt.ui.client.Events;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.HorizontalPanel;import com.extjs.gxt.ui.client.widget.Html;import com.extjs.gxt.ui.client.widget.HtmlContainer;import com.extjs.gxt.ui.client.widget.LayoutContainer;import com.extjs.gxt.ui.client.widget.TabItem;import com.extjs.gxt.ui.client.widget.TabPanel;import com.extjs.gxt.ui.client.widget.layout.FitLayout;import com.extjs.gxt.ui.client.widget.layout.FlowLayout;import com.google.gwt.core.client.GWT;public class StructureDetailPanneauVue extends LayoutContainer implements Rafraichissable {private Mediateur mediateur = null;private String enteteTpl = null;private String identificationTpl = null;private String personnelTpl = null;private String lignePersonnelTpl = null;private Structure structure = null;private StructureAPersonneListe personnel = null;private StructureValorisation valorisation = null;private StructureConservation conservation = null;private ContentPanel panneauPrincipal = null;private Html entete = null;private TabPanel onglets = null;private TabItem identificationOnglet = null;private TabItem personnelOnglet = null;public StructureDetailPanneauVue(Mediateur mediateurCourant) {mediateur = mediateurCourant;initialiserTousLesTpl();setLayout(new FitLayout());setBorders(false);setScrollMode(Scroll.AUTO);panneauPrincipal = new ContentPanel();panneauPrincipal.setLayout(new FlowLayout());panneauPrincipal.setHeaderVisible(false);panneauPrincipal.setBodyBorder(false);entete = new Html();entete.setId(ComposantId.ZONE_DETAIL_ENTETE);panneauPrincipal.setTopComponent(entete);onglets = new TabPanel();onglets.setId(ComposantId.ZONE_DETAIL_CORPS);onglets.setHeight("100%");onglets.setBorders(false);onglets.setBodyBorder(false);identificationOnglet = new TabItem("Général");identificationOnglet.setBorders(false);identificationOnglet.setScrollMode(Scroll.AUTO);onglets.add(identificationOnglet);personnelOnglet = new TabItem("Personnel");personnelOnglet.setBorders(false);personnelOnglet.setScrollMode(Scroll.AUTO);onglets.add(personnelOnglet);panneauPrincipal.add(onglets);add(panneauPrincipal);}private void afficherDetailInstitution(Structure structureCourante) {if (structureCourante != null) {structure = structureCourante;personnel = structure.getPersonnel();valorisation = structure.getValorisation();conservation = structure.getConservation();afficherEntete();afficherIdentification();}layout();}private void afficherEntete() {Params enteteParams = new Params();enteteParams.set("id", ComposantId.ZONE_DETAIL_ENTETE);enteteParams.set("nom", structure.getNom());enteteParams.set("ville", structure.getVille());String eHtml = Format.substitute(enteteTpl, enteteParams);entete.getElement().setInnerHTML(eHtml);}private void afficherIdentification() {Params contenuParams = new Params();contenuParams.set("css_class", ComposantClass.DETAIL_CORPS_CONTENU);contenuParams.set("description", structure.getDescription());contenuParams.set("adresse", structure.getAdresse());contenuParams.set("code_postal", structure.getCodePostal());contenuParams.set("ville", structure.getVille());contenuParams.set("region", structure.getRegion());contenuParams.set("pays", structure.getPays());contenuParams.set("tel", structure.getTelephone());contenuParams.set("fax", structure.getFax());contenuParams.set("courriel", structure.getCourriel());contenuParams.set("acces", structure.getConditionAcces());String cHtml = Format.substitute(identificationTpl, contenuParams);HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);identificationOnglet.removeAll();identificationOnglet.add(corpsConteneurDuHtml);}private void afficherPersonnel() {Params contenuParams = new Params();contenuParams.set("css_class", ComposantClass.DETAIL_CORPS_CONTENU);contenuParams.set("fonction", mediateur.i18nC.fonction());contenuParams.set("prenom", mediateur.i18nC.prenom());contenuParams.set("nom", mediateur.i18nC.nom());contenuParams.set("tel", mediateur.i18nC.telephoneFixe());contenuParams.set("fax", mediateur.i18nC.fax());contenuParams.set("courriel", mediateur.i18nC.courrielPrincipal());contenuParams.set("statut", mediateur.i18nC.statut());contenuParams.set("tps_w", mediateur.i18nC.tpsTravail());contenuParams.set("specialite", mediateur.i18nC.specialite());contenuParams.set("contact", mediateur.i18nC.boolContact());String lignesPersonnel = "";personnel = structure.getPersonnel();Iterator<String> it = personnel.keySet().iterator();while (it.hasNext()) {StructureAPersonne personne = personnel.get(it.next());Params ligneParams = new Params();ligneParams.set("fonction", personne.getFonction());ligneParams.set("prenom", personne.getPrenom());ligneParams.set("nom", personne.getNom());ligneParams.set("tel", personne.getTelephone());ligneParams.set("fax", personne.getFax());ligneParams.set("courriel", personne.getCourriel());ligneParams.set("statut", personne.getStatut());ligneParams.set("tps_w", personne.getBotaTravailHebdoTps());ligneParams.set("specialite", personne.afficherSpecialite());ligneParams.set("contact", personne.getContact());lignesPersonnel += Format.substitute(lignePersonnelTpl, ligneParams);}contenuParams.set("lignes", lignesPersonnel);String cHtml = Format.substitute(personnelTpl, contenuParams);HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);personnelOnglet.removeAll();personnelOnglet.add(corpsConteneurDuHtml);}private void initialiserTousLesTpl() {initialiserEnteteHtmlTpl();initialiserIdentificationTpl();initialiserPersonnelTpl();initialiserLignePersonnelTpl();}private void initialiserEnteteHtmlTpl() {enteteTpl = "<div id='{id}'>"+" <h1>{nom}</h1>"+" <h2>{ville}</h2>" +"</div>";}private void initialiserIdentificationTpl() {identificationTpl ="<div class='{css_class}'>"+" <h2>Renseignements administratifs</h2>"+" <span style='font-weight:bold;'>Condition d'accès :</span> {acces}<br />"+" <span style='font-weight:bold;'>Adresse :</span> {adresse}, {code_postal} {ville}, {region}, {pays}<br />"+" <span style='font-weight:bold;'>Téléphone :</span> {tel}<br />"+" <span style='font-weight:bold;'>Fax :</span> {fax}<br />"+" <span style='font-weight:bold;'>Courriel :</span> {courriel}<br />"+" {description}"+"</div>";}private void initialiserPersonnelTpl() {personnelTpl ="<div class='{css_class}'>"+" <h2>Personnel</h2>"+" <table>"+" <thead>"+" <tr>" +" <th>{fonction}</th>" +" <th>{prenom}</th>" +" <th>{nom}</th>" +" <th>{tel}</th>" +" <th>{fax}</th>" +" <th>{courriel}</th>" +" <th>{statut}</th>" +" <th>{tps_w}</th>" +" <th>{specialite}</th>" +" <th>{contact}</th>" +" </tr>"+" </thead>"+" <tbody>"+" {lignes}"+" </tbody>"+" </table>"+"</div>";}private void initialiserLignePersonnelTpl() {lignePersonnelTpl ="<tr>"+" <td>{fonction}</td>"+" <td>{prenom}</td>"+" <td>{nom}</td>"+" <td>{tel}</td>" +" <td>{fax}</td>" +" <td>{courriel}</td>" +" <td>{statut}</td>" +" <td>{tps_w}</td>" +" <td>{specialite}</td>" +" <td>{contact}</td>" +"</tr>";}public void rafraichir(Object nouvelleDonnees) {if (nouvelleDonnees instanceof Structure) {afficherDetailInstitution((Structure) nouvelleDonnees);} if (nouvelleDonnees instanceof Information) {Information info = (Information) nouvelleDonnees;if (info.getType().equals("liste_structure_a_personne")) {allouerPersonnelAStructure((StructureAPersonneListe) info.getDonnee(0));afficherPersonnel();layout();}} else {GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);}}private void allouerPersonnelAStructure(StructureAPersonneListe personnel) {structure.setPersonnel(personnel);}}