Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 933 → Rev 934

/trunk/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java
New file
0,0 → 1,500
package org.tela_botanica.client.vues.collection;
 
import java.util.Iterator;
 
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.CollectionAPersonne;
import org.tela_botanica.client.modeles.CollectionAPersonneListe;
import org.tela_botanica.client.modeles.CollectionAPublication;
import org.tela_botanica.client.modeles.CollectionAPublicationListe;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Personne;
import org.tela_botanica.client.modeles.ProjetListe;
import org.tela_botanica.client.modeles.Publication;
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 Collection collection = null;
private boolean collectionChargementOk = false;
private boolean personnesLieesChargementOk = false;
private boolean publicationsLieesChargementOk = false;
private Structure structure = null;
 
private String enteteTpl = null;
private String generalTpl = null;
private String personneTpl = null;
private String tableauPersonnesLieesTpl = null;
private String lignePersonneLieeTpl = null;
private String publicationTpl = null;
private String tableauPublicationsLieesTpl = null;
private String lignePublicationLieeTpl = null;
private String descriptionTpl = null;
private String contenuTpl = null;
private String inventaireTpl = null;
private ContentPanel panneauPrincipal = null;
private Html entete = null;
private TabPanel onglets = null;
private TabItem generalOnglet = null;
private TabItem personneOnglet = null;
private TabItem publicationOnglet = null;
private TabItem descriptionOnglet = null;
private TabItem contenuOnglet = null;
private TabItem inventaireOnglet = 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);
personneOnglet = new TabItem(i18nC.collectionPersonne());
personneOnglet.setLayout(new AnchorLayout());
personneOnglet.setScrollMode(Scroll.AUTO);
onglets.add(personneOnglet);
publicationOnglet = new TabItem(i18nC.collectionPublication());
publicationOnglet.setLayout(new AnchorLayout());
publicationOnglet.setScrollMode(Scroll.AUTO);
onglets.add(publicationOnglet);
descriptionOnglet = new TabItem(i18nC.collectionDescription());
descriptionOnglet.setLayout(new AnchorLayout());
descriptionOnglet.setScrollMode(Scroll.AUTO);
onglets.add(descriptionOnglet);
contenuOnglet = new TabItem(i18nC.collectionContenu());
contenuOnglet.setLayout(new AnchorLayout());
contenuOnglet.setScrollMode(Scroll.AUTO);
onglets.add(contenuOnglet);
inventaireOnglet = new TabItem(i18nC.collectionInventaire());
inventaireOnglet.setLayout(new AnchorLayout());
inventaireOnglet.setScrollMode(Scroll.AUTO);
onglets.add(inventaireOnglet);
panneauPrincipal.add(onglets);
add(panneauPrincipal);
}
private void initialiserTousLesTpl() {
initialiserEnteteHtmlTpl();
initialiserGeneralTpl();
initialiserPersonneTpl();
initialiserTableauPersonnesLieesTpl();
initialiserLignePersonneLieeTpl();
initialiserPublicationTpl();
initialiserTableauPublicationsLieesTpl();
initialiserLignePublicationLieeTpl();
initialiserContenuTpl();
initialiserDescriptionTpl();
initialiserInventaireTpl();
}
private void initialiserEnteteHtmlTpl() {
enteteTpl =
"<div id='{css_id}'>"+
" <h1>{nom}</h1>"+
" <h2>{structure}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{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_nom_alternatif} :</span> {nom_alternatif}<br />"+
" <span class='{css_label}'>{i18n_acronyme} :</span> {acronyme}<br />"+
" <span class='{css_label}'>{i18n_code} :</span> {code}<br />"+
" <span class='{css_label}'>{i18n_cote} :</span> {cote}<br />"+
" <span class='{css_label}'>{i18n_mere} :</span> {mere}<br />"+
" <span class='{css_label}'>{i18n_type_ncd} :</span> {type_ncd}<br />"+
" <span class='{css_label}'>{i18n_type_depot} :</span> {type_depot}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_general_collection_titre}</h2>"+
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
" <span class='{css_label}'>{i18n_description_specialiste} :</span> {description_specialiste}<br />"+
" <span class='{css_label}'>{i18n_historique} :</span> {historique}<br />"+
" <span class='{css_label}'>{i18n_web} :</span> {web}<br />"+
" <span class='{css_label}'>{i18n_groupement_principe} :</span> {groupement_principe}<br />"+
" <span class='{css_label}'>{i18n_groupement_but} :</span> {groupement_but}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserPersonneTpl() {
personneTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_personne}</h2>"+
" {tableau_personnes_liees}"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserTableauPersonnesLieesTpl() {
tableauPersonnesLieesTpl =
"<h3>{i18n_titre_membre}</h3>"+
"<table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_prenom}</th>" +
" <th>{i18n_nom}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLignePersonneLieeTpl() {
lignePersonneLieeTpl =
"<tr>"+
" <td>{prenom}</td>"+
" <td>{nom}</td>"+
"</tr>";
}
private void initialiserPublicationTpl() {
publicationTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_publication}</h2>"+
" {tableau_publications_liees}"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserTableauPublicationsLieesTpl() {
tableauPublicationsLieesTpl =
"<table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_auteur}</th>" +
" <th>{i18n_titre}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLignePublicationLieeTpl() {
lignePublicationLieeTpl =
"<tr>"+
" <td>{auteur}</td>"+
" <td>{titre}</td>"+
"</tr>";
}
private void initialiserDescriptionTpl() {
descriptionTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_description}</h2>"+
" <span class='{css_label}'>{i18n_type_botanique} :</span> {type_botanique}<br />"+
" <span class='{css_label}'>{i18n_nbre_echantillon} :</span> {nbre_echantillon}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserContenuTpl() {
contenuTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_contenu}</h2>"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserInventaireTpl() {
inventaireTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_inventaire}</h2>"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void chargerOntologie() {
String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot", "groupementPrincipe", "realisationBut"};
lancerChargementListesValeurs(listesCodes);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Collection) {
collection = (Collection) nouvellesDonnees;
collectionChargementOk = true;
} else if (nouvellesDonnees instanceof ProjetListe) {
projets = (ProjetListe) nouvellesDonnees;
projetsChargementOk = true;
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
receptionerListeValeurs(listeValeursReceptionnee);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("liste_collection_a_personne")) {
lierCollectionAPersonne((CollectionAPersonneListe) info.getDonnee(0));
} else if (info.getType().equals("liste_collection_a_publication")) {
lierCollectionAPublication((CollectionAPublicationListe) info.getDonnee(0));
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
if (avoirDonneesChargees()) {
afficherDetail();
}
}
protected void lierCollectionAPersonne(CollectionAPersonneListe personnes) {
collection.setPersonnesLiees(personnes);
personnesLieesChargementOk = true;
}
protected void lierCollectionAPublication(CollectionAPublicationListe publications) {
collection.setPublicationsLiees(publications);
publicationsLieesChargementOk = true;
}
private boolean avoirDonneesChargees() {
boolean ok = false;
if (projetsChargementOk && collectionChargementOk && ontologieChargementOk && personnesLieesChargementOk && publicationsLieesChargementOk) {
ok = true;
}
return ok;
}
private void afficherDetail() {
if (collection != null) {
afficherEntete();
afficherIdentification();
afficherPersonne();
afficherPublication();
afficherDescription();
afficherContenu();
afficherInventaire();
}
layout();
}
private void afficherEntete() {
Params enteteParams = new Params();
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
enteteParams.set("css_meta", ComposantClass.META);
enteteParams.set("i18n_id", i18nC.id());
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_nom_alternatif", i18nC.nomAlternatif());
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_type_ncd", i18nC.typeCollectionNcd());
generalParams.set("i18n_type_depot", i18nC.typeDepot());
 
generalParams.set("i18n_general_collection_titre", i18nC.collectionGeneralTitre());
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());
String acronyme = construireTxtTruck(collection.getIdAlternatif());
String code = construireTxtTruck(collection.getCode());
String nomAlternatif = construireTxtTruck(collection.getNomAlternatif());
String urls = construireTxtTruck(collection.getUrls());
String typeNcd = construireTxtListeOntologie(collection.getTypeNcd());
String typeDepot = construireTxtListeOntologie(collection.getTypeDepot());
String groupementBut = construireTxtListeOntologie(collection.getGroupementBut());
String groupementPrincipe = construireTxtListeOntologie(collection.getGroupementPrincipe());
generalParams.set("nom_alternatif", nomAlternatif);
generalParams.set("acronyme", acronyme);
generalParams.set("code", code);
generalParams.set("cote", collection.getCote());
generalParams.set("mere", collection.getCollectionMereNom());
generalParams.set("type_ncd", typeNcd);
generalParams.set("type_depot", typeDepot);
 
generalParams.set("description", collection.getDescription());
generalParams.set("description_specialiste", collection.getDescriptionSpecialiste());
generalParams.set("historique", collection.getHistorique());
generalParams.set("web", urls);
generalParams.set("groupement_principe", groupementPrincipe);
generalParams.set("groupement_but", groupementBut);
afficherOnglet(generalTpl, generalParams, generalOnglet);
}
private void afficherPersonne() {
String tableauPersonneHtml = "";
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) {
tableauPersonneHtml = construireTableauPersonnesLiees();
}
Params personneParams = new Params();
personneParams.set("i18n_titre_personne", i18nC.collectionPersonneTitre());
personneParams.set("tableau_personnes_liees", tableauPersonneHtml);
afficherOnglet(personneTpl, personneParams, personneOnglet);
}
private String construireTableauPersonnesLiees() {
Params contenuParams = new Params();
contenuParams.set("i18n_prenom", i18nC.personnePrenom());
contenuParams.set("i18n_nom", i18nC.personneNom());
String lignesPersonnel = "";
Iterator<String> it = collection.getPersonnesLiees().keySet().iterator();
while (it.hasNext()) {
CollectionAPersonne relationCollectionAPersonne = collection.getPersonnesLiees().get(it.next());
Personne personne = relationCollectionAPersonne.getPersonne();
Params ligneParams = new Params();
ligneParams.set("prenom", personne.getPrenom());
ligneParams.set("nom", personne.getNom());
lignesPersonnel += Format.substitute(lignePersonneLieeTpl, ligneParams);
}
contenuParams.set("lignes", lignesPersonnel);
String cHtml = Format.substitute(tableauPersonnesLieesTpl, contenuParams);
return cHtml;
}
private void afficherPublication() {
Params publicationParams = new Params();
publicationParams.set("i18n_titre_publication", i18nC.collectionPublicationTitre());
String tableauPublicationHtml = "";
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) {
tableauPublicationHtml = construireTableauPublicationsLiees();
}
publicationParams.set("tableau_publications_liees", tableauPublicationHtml);
afficherOnglet(publicationTpl, publicationParams, publicationOnglet);
}
private String construireTableauPublicationsLiees() {
Params contenuParams = new Params();
contenuParams.set("i18n_auteur", i18nC.publicationAuteurs());
contenuParams.set("i18n_titre", i18nC.publicationTitre());
String lignesPublication = "";
Iterator<String> it = collection.getPublicationsLiees().keySet().iterator();
while (it.hasNext()) {
CollectionAPublication relationCollectionAPublication = collection.getPublicationsLiees().get(it.next());
Publication publication = relationCollectionAPublication.getPublication();
Params ligneParams = new Params();
ligneParams.set("auteur", publication.getAuteur());
ligneParams.set("titre", publication.getTitre());
lignesPublication += Format.substitute(lignePublicationLieeTpl, ligneParams);
}
contenuParams.set("lignes", lignesPublication);
String cHtml = Format.substitute(tableauPublicationsLieesTpl, contenuParams);
return cHtml;
}
private void afficherDescription() {
Params descriptionParams = new Params();
descriptionParams.set("i18n_titre_description", i18nC.collectionDescriptionTitre());
descriptionParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique());
descriptionParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon());
String typeBota = construireTxtListeOntologie(collection.getBotanique().getType());
descriptionParams.set("type_botanique", typeBota);
descriptionParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon());
afficherOnglet(descriptionTpl, descriptionParams, descriptionOnglet);
}
private void afficherContenu() {
Params contenuParams = new Params();
contenuParams.set("i18n_titre_contenu", i18nC.collectionContenuTitre());
afficherOnglet(contenuTpl, contenuParams, contenuOnglet);
}
private void afficherInventaire() {
Params inventaireParams = new Params();
inventaireParams.set("i18n_titre_inventaire", i18nC.collectionInventaireTitre());
afficherOnglet(inventaireTpl, inventaireParams, inventaireOnglet);
}
protected String getNomStructure() {
String nomStructure = "";
if (structure != null) {
nomStructure = structure.getNom();
} else {
nomStructure = collection.getIdStructure();
}
return nomStructure;
}
}