Subversion Repositories eFlore/Applications.coel

Rev

Rev 468 | Rev 630 | 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.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.Collection;
import org.tela_botanica.client.modeles.ProjetListe;
import org.tela_botanica.client.modeles.Structure;
import org.tela_botanica.client.modeles.ValeurListe;

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.AnchorLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.core.client.GWT;

public class CollectionDetailVue extends DetailVue implements Rafraichissable {

        private Structure structure = null;
        
        private String enteteTpl = null;
        private String generalTpl = null;
        
        private Collection collection = null;
        
        private ContentPanel panneauPrincipal = null;
        private Html entete = null;
        private TabPanel onglets = null;
        private TabItem generalOnglet = null;
        
        public CollectionDetailVue(Mediateur mediateurCourant) {
                super(mediateurCourant);
                initialiserTousLesTpl();
                chargerOntologie();
                
                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.setBodyBorder(false);

                generalOnglet = new TabItem(i18nC.structureInfoGeneral());
                generalOnglet.setLayout(new AnchorLayout());
                generalOnglet.setScrollMode(Scroll.AUTO);
                onglets.add(generalOnglet);
                
                panneauPrincipal.add(onglets);
                add(panneauPrincipal);
        }
        
        private void initialiserTousLesTpl() {
                initialiserEnteteHtmlTpl();
                initialiserGeneralTpl();
        }
        
        private void initialiserEnteteHtmlTpl() {
                enteteTpl =     
                        "<div id='{css_id}'>"+
                        "       <h1>{nom}</h1>"+
                        "       <h2>{structure}<span class='{css_meta}'>{projet} - {id} - {guid}</span></h2>" +
                        "       " +
                        "</div>";
        }
        
        private void initialiserGeneralTpl() {
                generalTpl =
                        "<div class='{css_corps}'>"+
                        "       <div class='{css_fieldset}'>"+
                        "               <h2>{i18n_titre_identification}</h2>"+
                        "               <span class='{css_label}'>{i18n_acronyme} :</span> {acronyme}<br />"+
                        "               <span class='{css_label}'>{i18n_code} :</span> {code}<br />"+
                        "       </div>"+
                        "       <div class='{css_fieldset}'>"+
                        "               <h2>{i18n_description_collection_titre}</h2>"+
                        "               <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
                        "               <span class='{css_label}'>{i18n_description_specialiste} :</span> {description_specialiste}<br />"+
                        "       </div>"+
                        "       <hr class='{css_clear}'/>"+
                        "</div>";
        }
        
        private void chargerOntologie() {
                
        }
        
        public void rafraichir(Object nouvelleDonnees) {
                if (nouvelleDonnees instanceof Collection) {
                        collection = (Collection) nouvelleDonnees;
                        afficherDetail();
                } else if (nouvelleDonnees instanceof ProjetListe) {
                        projets = (ProjetListe) nouvelleDonnees;
                } else if (nouvelleDonnees instanceof ValeurListe) {
                        ValeurListe ontologieReceptionnee = (ValeurListe) nouvelleDonnees;
                        ajouterListeValeursAOntologie(ontologieReceptionnee);
                } else {
                        GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
                }
        }
        
        private void afficherDetail() {
                if (collection != null) {
                        afficherEntete();
                        afficherIdentification();
                }
                layout();
        }
        
        private void afficherEntete() {
                Params enteteParams = new Params();
                enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
                enteteParams.set("css_meta", ComposantClass.META);
                
                enteteParams.set("nom", collection.getNom());
                enteteParams.set("structure", collection.getStructureNom());
                enteteParams.set("id", collection.getId());
                enteteParams.set("guid", collection.getGuid());
                enteteParams.set("projet", construireTxtProjet(collection.getIdProjet()));
                
                String eHtml = Format.substitute(enteteTpl, enteteParams);
                entete.getElement().setInnerHTML(eHtml);
        }
        
        private void afficherIdentification() {
                Params generalParams = new Params();
                generalParams.set("i18n_titre_identification", i18nC.titreAdministratif());
                generalParams.set("i18n_acronyme", i18nC.acronyme());
                generalParams.set("i18n_code", i18nC.code());
                generalParams.set("i18n_cote", i18nC.cote());
                generalParams.set("i18n_mere", i18nC.collectionMere());
                generalParams.set("i18n_description_collection_titre", i18nC.collectionDescriptionTitre());
                generalParams.set("i18n_description", i18nC.description());
                generalParams.set("i18n_description_specialiste", i18nC.descriptionSpecialiste());
                generalParams.set("i18n_historique", i18nC.historique());
                generalParams.set("i18n_web", i18nC.siteWeb());
                generalParams.set("i18n_groupement_principe", i18nC.groupementPrincipe());
                generalParams.set("i18n_groupement_but", i18nC.groupementBut());
                generalParams.set("i18n_type_ncd", i18nC.typeCollectionNcd());
                generalParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique());
                
                String acronyme = construireTxtTruck(collection.getIdAlternatif());

                generalParams.set("acronyme", acronyme);
                generalParams.set("code", collection.getCode());
                //generalParams.set("cote", collection.getCote());
                //generalParams.set("mere", collection.getCollectionMereNom());
                generalParams.set("description", collection.getDescription());
                generalParams.set("description_specialiste", collection.getDescriptionSpecialiste());
                //generalParams.set("historique", collection.getHistorique());
                //generalParams.set("web", collection.getUrls());
                //generalParams.set("groupement_principe", collection.getGroupementPrincipe());
                //generalParams.set("groupement_but", collection.getGroupementBut());
                //generalParams.set("type_ncd", collection.getTypeNcd());
                //generalParams.set("type_botanique", collection.getTypeBotanique());
                
                
                afficherOnglet(generalTpl, generalParams, generalOnglet);
        }
        
        protected String getNomStructure() {
                String nomStructure = "";
                if (structure != null) {
                        nomStructure = structure.getNom();
                } else {
                        nomStructure = collection.getIdStructure();
                }
                return nomStructure;
        }
}