935 |
jpm |
1 |
package org.tela_botanica.client.vues.publication;
|
106 |
aurelien |
2 |
|
803 |
jpm |
3 |
import org.tela_botanica.client.ComposantClass;
|
|
|
4 |
import org.tela_botanica.client.ComposantId;
|
553 |
jp_milcent |
5 |
import org.tela_botanica.client.Mediateur;
|
106 |
aurelien |
6 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
935 |
jpm |
7 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
|
|
8 |
import org.tela_botanica.client.modeles.publication.Publication;
|
936 |
jpm |
9 |
import org.tela_botanica.client.vues.DetailVue;
|
106 |
aurelien |
10 |
|
|
|
11 |
import com.extjs.gxt.ui.client.util.Format;
|
|
|
12 |
import com.extjs.gxt.ui.client.util.Params;
|
|
|
13 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
14 |
import com.extjs.gxt.ui.client.widget.Html;
|
|
|
15 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
803 |
jpm |
16 |
import com.google.gwt.core.client.GWT;
|
106 |
aurelien |
17 |
|
803 |
jpm |
18 |
public class PublicationDetailVue extends DetailVue implements Rafraichissable {
|
553 |
jp_milcent |
19 |
|
803 |
jpm |
20 |
private String enteteTpl = null;
|
|
|
21 |
private String contenuTpl = null;
|
|
|
22 |
|
|
|
23 |
private ContentPanel panneauPrincipal = null;
|
|
|
24 |
private Html entete = null;
|
|
|
25 |
private Html contenu = null;
|
553 |
jp_milcent |
26 |
|
803 |
jpm |
27 |
private Publication publication = null;
|
813 |
jpm |
28 |
private boolean publicationChargementOk = false;
|
106 |
aurelien |
29 |
|
553 |
jp_milcent |
30 |
public PublicationDetailVue(Mediateur mediateurCourant) {
|
803 |
jpm |
31 |
super(mediateurCourant);
|
553 |
jp_milcent |
32 |
|
803 |
jpm |
33 |
initialiserTousLesTpl();
|
|
|
34 |
|
|
|
35 |
panneauPrincipal = new ContentPanel();
|
|
|
36 |
panneauPrincipal.setLayout(new FitLayout());
|
|
|
37 |
panneauPrincipal.setHeaderVisible(false);
|
|
|
38 |
panneauPrincipal.setBodyBorder(false);
|
|
|
39 |
|
|
|
40 |
entete = new Html();
|
|
|
41 |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
42 |
panneauPrincipal.setTopComponent(entete);
|
|
|
43 |
|
|
|
44 |
contenu = new Html();
|
|
|
45 |
panneauPrincipal.add(contenu);
|
|
|
46 |
|
|
|
47 |
add(panneauPrincipal);
|
|
|
48 |
}
|
106 |
aurelien |
49 |
|
803 |
jpm |
50 |
private void initialiserTousLesTpl() {
|
|
|
51 |
initialiserEnteteHtmlTpl();
|
|
|
52 |
initialiserGeneralTpl();
|
106 |
aurelien |
53 |
}
|
803 |
jpm |
54 |
|
|
|
55 |
private void initialiserEnteteHtmlTpl() {
|
|
|
56 |
enteteTpl =
|
|
|
57 |
"<div id='{css_id}'>"+
|
|
|
58 |
" <h1>{titre}</h1>"+
|
813 |
jpm |
59 |
" <h2>{auteurs} ({annee})<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" +
|
803 |
jpm |
60 |
"</div>";
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
private void initialiserGeneralTpl() {
|
|
|
64 |
contenuTpl =
|
|
|
65 |
"<div class='{css_corps}'>"+
|
1124 |
jpm |
66 |
" <span class='{css_label}'>{i18n_nom_complet} :</span> {nom_complet}<br />"+
|
|
|
67 |
" <span class='{css_label}'>{i18n_auteurs} :</span> {auteurs}<br />"+
|
|
|
68 |
" <span class='{css_label}'>{i18n_titre} :</span> {titre}<br />"+
|
|
|
69 |
" <span class='{css_label}'>{i18n_collection} :</span> {collection}<br />"+
|
|
|
70 |
" <span class='{css_label}'>{i18n_editeur} :</span> {editeur}<br />"+
|
|
|
71 |
" <span class='{css_label}'>{i18n_annee} :</span> {annee}<br />"+
|
|
|
72 |
" <span class='{css_label}'>{i18n_nvt} :</span> {nvt}<br />"+
|
|
|
73 |
" <span class='{css_label}'>{i18n_fascicule} :</span> {fascicule}<br />"+
|
|
|
74 |
" <span class='{css_label}'>{i18n_pages} :</span> {pages}<br />"+
|
803 |
jpm |
75 |
"</div>";
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public void afficherDetail() {
|
106 |
aurelien |
79 |
if (publication != null) {
|
803 |
jpm |
80 |
afficherEntete();
|
|
|
81 |
afficherDetailPublication();
|
106 |
aurelien |
82 |
}
|
803 |
jpm |
83 |
layout();
|
106 |
aurelien |
84 |
}
|
803 |
jpm |
85 |
|
|
|
86 |
private void afficherEntete() {
|
|
|
87 |
Params enteteParams = new Params();
|
|
|
88 |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
89 |
enteteParams.set("css_meta", ComposantClass.META);
|
716 |
aurelien |
90 |
|
813 |
jpm |
91 |
enteteParams.set("i18n_id", i18nC.id());
|
|
|
92 |
|
803 |
jpm |
93 |
enteteParams.set("titre", publication.getTitre());
|
|
|
94 |
enteteParams.set("auteurs", publication.getAuteur());
|
|
|
95 |
enteteParams.set("annee", publication.getAnneeParution());
|
|
|
96 |
enteteParams.set("id", publication.getId());
|
|
|
97 |
enteteParams.set("guid", getGuid());
|
|
|
98 |
enteteParams.set("projet", construireTxtProjet(publication.getIdProjet()));
|
1327 |
cyprien |
99 |
|
803 |
jpm |
100 |
String eHtml = Format.substitute(enteteTpl, enteteParams);
|
|
|
101 |
entete.getElement().setInnerHTML(eHtml);
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
public String getGuid() {
|
|
|
105 |
String guid = "URN:tela-botanica.org:";
|
|
|
106 |
guid += "coel"+publication.getIdProjet()+":";
|
|
|
107 |
guid += "pub"+publication.getId();
|
|
|
108 |
return guid;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public void afficherDetailPublication() {
|
|
|
112 |
Params contenuParams = new Params();
|
|
|
113 |
|
1124 |
jpm |
114 |
contenuParams.set("i18n_nom_complet", i18nC.publicationNomComplet());
|
803 |
jpm |
115 |
contenuParams.set("i18n_auteurs", i18nC.publicationAuteurs());
|
|
|
116 |
contenuParams.set("i18n_titre", i18nC.publicationTitre());
|
|
|
117 |
contenuParams.set("i18n_collection", i18nC.publicationRevueCollection());
|
|
|
118 |
contenuParams.set("i18n_editeur", i18nC.publicationEditeur());
|
|
|
119 |
contenuParams.set("i18n_annee", i18nC.publicationDateParution());
|
|
|
120 |
contenuParams.set("i18n_nvt", i18nC.publicationNvt());
|
|
|
121 |
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule());
|
|
|
122 |
contenuParams.set("i18n_pages", i18nC.publicationPage());
|
|
|
123 |
|
1124 |
jpm |
124 |
contenuParams.set("nom_complet", publication.getNomComplet());
|
803 |
jpm |
125 |
contenuParams.set("auteurs", publication.getAuteur());
|
|
|
126 |
contenuParams.set("titre", publication.getTitre());
|
|
|
127 |
contenuParams.set("collection", publication.getCollection());
|
|
|
128 |
contenuParams.set("editeur", publication.getNomEditeur());
|
|
|
129 |
contenuParams.set("annee", publication.getAnneeParution());
|
|
|
130 |
contenuParams.set("nvt", publication.getIndicationNvt());
|
|
|
131 |
contenuParams.set("fascicule", publication.getFascicule());
|
|
|
132 |
contenuParams.set("pages", publication.getPages());
|
|
|
133 |
|
|
|
134 |
String gHtml = formaterContenu(contenuTpl, contenuParams);
|
|
|
135 |
contenu.getElement().setInnerHTML(gHtml);
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
139 |
if (nouvellesDonnees instanceof Publication) {
|
|
|
140 |
publication = (Publication) nouvellesDonnees;
|
813 |
jpm |
141 |
publicationChargementOk = true;
|
|
|
142 |
} else if (nouvellesDonnees instanceof ProjetListe) {
|
|
|
143 |
projets = (ProjetListe) nouvellesDonnees;
|
|
|
144 |
projetsChargementOk = true;
|
803 |
jpm |
145 |
} else {
|
|
|
146 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
106 |
aurelien |
147 |
}
|
813 |
jpm |
148 |
|
|
|
149 |
if (avoirDonneesChargees()) {
|
|
|
150 |
afficherDetail();
|
|
|
151 |
}
|
106 |
aurelien |
152 |
}
|
813 |
jpm |
153 |
|
|
|
154 |
private boolean avoirDonneesChargees() {
|
|
|
155 |
boolean ok = false;
|
|
|
156 |
if (projetsChargementOk && publicationChargementOk) {
|
|
|
157 |
ok = true;
|
|
|
158 |
}
|
|
|
159 |
return ok;
|
|
|
160 |
}
|
|
|
161 |
}
|