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;
|
934 |
jpm |
9 |
import org.tela_botanica.client.vues.collection.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}'>"+
|
|
|
66 |
" <div class='{css_fieldset}'>"+
|
|
|
67 |
" <h2>{i18n_titre_detail}</h2>"+
|
|
|
68 |
" <span class='{css_label}'>{i18n_auteurs} :</span> {auteurs}<br />"+
|
|
|
69 |
" <span class='{css_label}'>{i18n_titre} :</span> {titre}<br />"+
|
|
|
70 |
" <span class='{css_label}'>{i18n_collection} :</span> {collection}<br />"+
|
|
|
71 |
" <span class='{css_label}'>{i18n_editeur} :</span> {editeur}<br />"+
|
|
|
72 |
" <span class='{css_label}'>{i18n_annee} :</span> {annee}<br />"+
|
|
|
73 |
" <span class='{css_label}'>{i18n_nvt} :</span> {nvt}<br />"+
|
|
|
74 |
" <span class='{css_label}'>{i18n_fascicule} :</span> {fascicule}<br />"+
|
|
|
75 |
" <span class='{css_label}'>{i18n_pages} :</span> {pages}<br />"+
|
|
|
76 |
" </div>"+
|
|
|
77 |
" <hr class='{css_clear}'/>"+
|
|
|
78 |
"</div>";
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public void afficherDetail() {
|
106 |
aurelien |
82 |
if (publication != null) {
|
803 |
jpm |
83 |
afficherEntete();
|
|
|
84 |
afficherDetailPublication();
|
106 |
aurelien |
85 |
}
|
803 |
jpm |
86 |
layout();
|
106 |
aurelien |
87 |
}
|
803 |
jpm |
88 |
|
|
|
89 |
private void afficherEntete() {
|
|
|
90 |
Params enteteParams = new Params();
|
|
|
91 |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
92 |
enteteParams.set("css_meta", ComposantClass.META);
|
716 |
aurelien |
93 |
|
813 |
jpm |
94 |
enteteParams.set("i18n_id", i18nC.id());
|
|
|
95 |
|
803 |
jpm |
96 |
enteteParams.set("titre", publication.getTitre());
|
|
|
97 |
enteteParams.set("auteurs", publication.getAuteur());
|
|
|
98 |
enteteParams.set("annee", publication.getAnneeParution());
|
|
|
99 |
enteteParams.set("id", publication.getId());
|
|
|
100 |
enteteParams.set("guid", getGuid());
|
|
|
101 |
enteteParams.set("projet", construireTxtProjet(publication.getIdProjet()));
|
813 |
jpm |
102 |
GWT.log("entete généré", null);
|
803 |
jpm |
103 |
String eHtml = Format.substitute(enteteTpl, enteteParams);
|
|
|
104 |
entete.getElement().setInnerHTML(eHtml);
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
public String getGuid() {
|
|
|
108 |
String guid = "URN:tela-botanica.org:";
|
|
|
109 |
guid += "coel"+publication.getIdProjet()+":";
|
|
|
110 |
guid += "pub"+publication.getId();
|
|
|
111 |
return guid;
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
public void afficherDetailPublication() {
|
|
|
115 |
Params contenuParams = new Params();
|
|
|
116 |
|
|
|
117 |
contenuParams.set("i18n_titre_detail", i18nC.publicationTitre());
|
|
|
118 |
contenuParams.set("i18n_auteurs", i18nC.publicationAuteurs());
|
|
|
119 |
contenuParams.set("i18n_titre", i18nC.publicationTitre());
|
|
|
120 |
contenuParams.set("i18n_collection", i18nC.publicationRevueCollection());
|
|
|
121 |
contenuParams.set("i18n_editeur", i18nC.publicationEditeur());
|
|
|
122 |
contenuParams.set("i18n_annee", i18nC.publicationDateParution());
|
|
|
123 |
contenuParams.set("i18n_nvt", i18nC.publicationNvt());
|
|
|
124 |
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule());
|
|
|
125 |
contenuParams.set("i18n_pages", i18nC.publicationPage());
|
|
|
126 |
|
|
|
127 |
contenuParams.set("auteurs", publication.getAuteur());
|
|
|
128 |
contenuParams.set("titre", publication.getTitre());
|
|
|
129 |
contenuParams.set("collection", publication.getCollection());
|
|
|
130 |
contenuParams.set("editeur", publication.getNomEditeur());
|
|
|
131 |
contenuParams.set("annee", publication.getAnneeParution());
|
|
|
132 |
contenuParams.set("nvt", publication.getIndicationNvt());
|
|
|
133 |
contenuParams.set("fascicule", publication.getFascicule());
|
|
|
134 |
contenuParams.set("pages", publication.getPages());
|
|
|
135 |
|
|
|
136 |
String gHtml = formaterContenu(contenuTpl, contenuParams);
|
|
|
137 |
contenu.getElement().setInnerHTML(gHtml);
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
141 |
if (nouvellesDonnees instanceof Publication) {
|
|
|
142 |
publication = (Publication) nouvellesDonnees;
|
813 |
jpm |
143 |
publicationChargementOk = true;
|
|
|
144 |
} else if (nouvellesDonnees instanceof ProjetListe) {
|
|
|
145 |
projets = (ProjetListe) nouvellesDonnees;
|
|
|
146 |
projetsChargementOk = true;
|
|
|
147 |
GWT.log("projets recu", null);
|
803 |
jpm |
148 |
} else {
|
|
|
149 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
106 |
aurelien |
150 |
}
|
813 |
jpm |
151 |
|
|
|
152 |
if (avoirDonneesChargees()) {
|
|
|
153 |
afficherDetail();
|
|
|
154 |
}
|
106 |
aurelien |
155 |
}
|
813 |
jpm |
156 |
|
|
|
157 |
private boolean avoirDonneesChargees() {
|
|
|
158 |
boolean ok = false;
|
|
|
159 |
if (projetsChargementOk && publicationChargementOk) {
|
|
|
160 |
ok = true;
|
|
|
161 |
}
|
|
|
162 |
return ok;
|
|
|
163 |
}
|
|
|
164 |
}
|