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