Rev 373 | Rev 379 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.vues;
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.Structure;
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 contenuTpl = null;
private Structure structure = null;
private ContentPanel panneauPrincipal = null;
private Html entete = null;
private TabPanel onglets = null;
private TabItem identificationOnglet = null;
public StructureDetailPanneauVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
initialiserEnteteHtmlTpl();
initialiserContenuHtmlTpl();
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);
panneauPrincipal.setTopComponent(entete);
onglets = new TabPanel();
onglets.setHeight("100%");
onglets.setBorders(false);
onglets.setBodyBorder(false);
identificationOnglet = new TabItem("Général");
onglets.add(identificationOnglet);
panneauPrincipal.add(onglets);
add(panneauPrincipal);
}
private void afficherDetailInstitution(Structure structureCourante) {
if (structureCourante != null) {
structure = structureCourante;
afficherEntete();
afficherIdentification();
}
layout();
}
private void afficherEntete() {
Params enteteParams = new Params();
enteteParams.add(ComposantId.ZONE_DETAIL);
enteteParams.add(structure.getNom());
enteteParams.add(structure.getVille());
String eHtml = Format.substitute(enteteTpl, enteteParams);
entete.getElement().setInnerHTML(eHtml);
}
private void afficherIdentification() {
Params contenuParams = new Params();
contenuParams.add(structure.getDescription());
contenuParams.add(structure.getAdresse());
contenuParams.add(structure.getCodePostal());
contenuParams.add(structure.getVille());
contenuParams.add(structure.getRegion());
contenuParams.add(structure.getPays());
contenuParams.add(structure.getTelephone());
contenuParams.add(structure.getFax());
contenuParams.add(structure.getCourriel());
contenuParams.add(structure.getConditionAcces());
contenuParams.add(ComposantId.ZONE_DETAIL_CORPS);
String cHtml = Format.substitute(contenuTpl, contenuParams);
HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
identificationOnglet.removeAll();
identificationOnglet.add(corpsConteneurDuHtml);
}
private void initialiserEnteteHtmlTpl() {
enteteTpl = "<div id='{0}'>"+
" <h1>{1}</h1>"+
" <h2>{2}</h2>" +
"</div>";
}
private void initialiserContenuHtmlTpl() {
contenuTpl = "<div id='{10}'>"+
" <h2>Renseignements administratifs</h2>"+
" <span style='font-weight:bold;'>Condition d'accès :</span> {9}<br />"+
" <span style='font-weight:bold;'>Adresse :</span> {1}, {2} {3}, {4}, {5}<br />"+
" <span style='font-weight:bold;'>Téléphone :</span> {6}<br />"+
" <span style='font-weight:bold;'>Fax :</span> {7}<br />"+
" <span style='font-weight:bold;'>Courriel :</span> {8}<br />"+
" {0}"+
"</div>";
}
public void rafraichir(Object nouvelleDonnees) {
if (nouvelleDonnees instanceof Structure) {
afficherDetailInstitution((Structure) nouvelleDonnees);
} else {
GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
}
}
}