New file |
0,0 → 1,156 |
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.StructureListe; |
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 StructureListe structures = 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_sigle} :</span> {sigle}<br />"+ |
" </div>"+ |
"</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", construireTxtStructure(collection.getIdStructure())); |
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()); |
|
String acronyme = construireTxtTruck(collection.getIdAlternatif()); |
|
generalParams.set("acronyme", acronyme); |
|
afficherOnglet(generalTpl, generalParams, generalOnglet); |
} |
|
protected String construireTxtStructure(String idStructure) { |
String chaineARetourner = idStructure; |
|
if (structures != null) { |
Structure structure = structures.get(idStructure); |
String nomStructure = structure.getNom(); |
if (!nomStructure.equals("")) { |
chaineARetourner = nomStructure; |
} |
} |
|
return chaineARetourner; |
} |
} |