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 |
" <h2>{i18n_titre_detail}</h2>"+
|
|
|
67 |
" <span class='{css_label}'>{i18n_nom_complet} :</span> {nom_complet}<br />"+
|
|
|
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 />"+
|
803 |
jpm |
76 |
"</div>";
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public void afficherDetail() {
|
106 |
aurelien |
80 |
if (publication != null) {
|
803 |
jpm |
81 |
afficherEntete();
|
|
|
82 |
afficherDetailPublication();
|
106 |
aurelien |
83 |
}
|
803 |
jpm |
84 |
layout();
|
106 |
aurelien |
85 |
}
|
803 |
jpm |
86 |
|
|
|
87 |
private void afficherEntete() {
|
|
|
88 |
Params enteteParams = new Params();
|
|
|
89 |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
90 |
enteteParams.set("css_meta", ComposantClass.META);
|
716 |
aurelien |
91 |
|
813 |
jpm |
92 |
enteteParams.set("i18n_id", i18nC.id());
|
|
|
93 |
|
803 |
jpm |
94 |
enteteParams.set("titre", publication.getTitre());
|
|
|
95 |
enteteParams.set("auteurs", publication.getAuteur());
|
|
|
96 |
enteteParams.set("annee", publication.getAnneeParution());
|
|
|
97 |
enteteParams.set("id", publication.getId());
|
|
|
98 |
enteteParams.set("guid", getGuid());
|
|
|
99 |
enteteParams.set("projet", construireTxtProjet(publication.getIdProjet()));
|
813 |
jpm |
100 |
GWT.log("entete généré", null);
|
803 |
jpm |
101 |
String eHtml = Format.substitute(enteteTpl, enteteParams);
|
|
|
102 |
entete.getElement().setInnerHTML(eHtml);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public String getGuid() {
|
|
|
106 |
String guid = "URN:tela-botanica.org:";
|
|
|
107 |
guid += "coel"+publication.getIdProjet()+":";
|
|
|
108 |
guid += "pub"+publication.getId();
|
|
|
109 |
return guid;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
public void afficherDetailPublication() {
|
|
|
113 |
Params contenuParams = new Params();
|
|
|
114 |
|
|
|
115 |
contenuParams.set("i18n_titre_detail", i18nC.publicationTitre());
|
1124 |
jpm |
116 |
contenuParams.set("i18n_nom_complet", i18nC.publicationNomComplet());
|
803 |
jpm |
117 |
contenuParams.set("i18n_auteurs", i18nC.publicationAuteurs());
|
|
|
118 |
contenuParams.set("i18n_titre", i18nC.publicationTitre());
|
|
|
119 |
contenuParams.set("i18n_collection", i18nC.publicationRevueCollection());
|
|
|
120 |
contenuParams.set("i18n_editeur", i18nC.publicationEditeur());
|
|
|
121 |
contenuParams.set("i18n_annee", i18nC.publicationDateParution());
|
|
|
122 |
contenuParams.set("i18n_nvt", i18nC.publicationNvt());
|
|
|
123 |
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule());
|
|
|
124 |
contenuParams.set("i18n_pages", i18nC.publicationPage());
|
|
|
125 |
|
1124 |
jpm |
126 |
contenuParams.set("nom_complet", publication.getNomComplet());
|
803 |
jpm |
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 |
}
|