Subversion Repositories eFlore/Applications.coel

Rev

Rev 69 | 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.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Structure;
import org.tela_botanica.client.modeles.ListeStructure;

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.layout.FitLayout;

public class StructureDetailPanneauVue extends ContentPanel implements Rafraichissable {

        private ContentPanel content;
        private Html header;
        private String enteteHTML = "<div class='coel-detail'><h1>{0}</h1><h2>{1}</h2></div>";
        private String contenuHTML = "<div style='padding: 12px;'><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>";
        private String structureNom = null;
        private String structureVille = null;
        private String structureDescription = null;

        public StructureDetailPanneauVue() {
                Registry.register(RegistreId.PANNEAU_INSTITUTION_DETAIL, this);
                
                setHeaderVisible(false);
                setLayout(new FitLayout());

                content = new ContentPanel();
                content.setBodyBorder(false);
                content.setHeaderVisible(false);
                content.setScrollMode(Scroll.AUTO);

                header = new Html();
                header.setStyleName("coel-detail");
                content.setTopComponent(header);

                add(content);
        }

        public void afficherDetailInstitution(Structure structure) {
                if (structure != null) {
                        content.removeAll();
                        
                        structureNom = structure.getNom();
                        structureVille = structure.getVille();
                        structureDescription = structure.getDescription();

                        Params enteteParams = new Params();
                        enteteParams.add(structureNom);
                        enteteParams.add(structureVille);

                        String eHtml = Format.substitute(enteteHTML, enteteParams);
                        header.getElement().setInnerHTML(eHtml);

                        Params contenuParams = new Params();
                        contenuParams.add(structureDescription);
                        contenuParams.add(structure.getAdresse01());
                        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());
                        
                        String cHtml = Format.substitute(contenuHTML, contenuParams);
                        content.addText(cHtml);

                        layout();
                } else {
                        header.setHtml("");
                        content.removeAll();
                }
        }

        public void rafraichir(Object nouvelleDonnees) {
                if (nouvelleDonnees instanceof Structure) {
                        afficherDetailInstitution((Structure) nouvelleDonnees);
                } else if (nouvelleDonnees instanceof ListeStructure) {
                        ListeStructure listeInstitutions = (ListeStructure) nouvelleDonnees;
                        // Test pour savoir si la liste contient des éléments
                        if (listeInstitutions.size() == 0) {
                                afficherDetailInstitution(null);
                        }
                }
        }

}