834 |
aurelien |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.ComposantClass;
|
|
|
4 |
import org.tela_botanica.client.ComposantId;
|
|
|
5 |
import org.tela_botanica.client.Mediateur;
|
|
|
6 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
7 |
import org.tela_botanica.client.modeles.ProjetListe;
|
|
|
8 |
import org.tela_botanica.client.modeles.Projet;
|
|
|
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;
|
|
|
15 |
import com.google.gwt.core.client.GWT;
|
|
|
16 |
|
|
|
17 |
public class ProjetDetailVue extends DetailVue implements Rafraichissable {
|
|
|
18 |
|
|
|
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;
|
|
|
25 |
|
|
|
26 |
private Projet projet = null;
|
|
|
27 |
private boolean projetChargementOk = false;
|
|
|
28 |
|
|
|
29 |
public ProjetDetailVue(Mediateur mediateurCourant) {
|
|
|
30 |
super(mediateurCourant);
|
|
|
31 |
|
|
|
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 |
}
|
|
|
48 |
|
|
|
49 |
private void initialiserTousLesTpl() {
|
|
|
50 |
initialiserEnteteHtmlTpl();
|
|
|
51 |
initialiserGeneralTpl();
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
private void initialiserEnteteHtmlTpl() {
|
|
|
55 |
enteteTpl =
|
|
|
56 |
"<div id='{css_id}'>"+
|
|
|
57 |
" <h1>{titre}</h1>"+
|
|
|
58 |
" <h2>{auteurs} ({annee})<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" +
|
|
|
59 |
"</div>";
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
private void initialiserGeneralTpl() {
|
|
|
63 |
contenuTpl =
|
|
|
64 |
"<div class='{css_corps}'>"+
|
|
|
65 |
" <div class='{css_fieldset}'>"+
|
|
|
66 |
" <h2>{i18n_titre_detail}</h2>"+
|
|
|
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 />"+
|
|
|
75 |
" </div>"+
|
|
|
76 |
" <hr class='{css_clear}'/>"+
|
|
|
77 |
"</div>";
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
public void afficherDetail() {
|
|
|
81 |
if (projet != null) {
|
|
|
82 |
afficherEntete();
|
|
|
83 |
afficherDetailProjet();
|
|
|
84 |
}
|
|
|
85 |
layout();
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
private void afficherEntete() {
|
|
|
89 |
Params enteteParams = new Params();
|
|
|
90 |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
91 |
enteteParams.set("css_meta", ComposantClass.META);
|
|
|
92 |
|
|
|
93 |
enteteParams.set("i18n_id", i18nC.id());
|
|
|
94 |
|
|
|
95 |
enteteParams.set("id", projet.getId());
|
|
|
96 |
enteteParams.set("guid", getGuid());
|
|
|
97 |
enteteParams.set("projet", construireTxtProjet(projet.getId()));
|
|
|
98 |
GWT.log("entete généré", null);
|
|
|
99 |
String eHtml = Format.substitute(enteteTpl, enteteParams);
|
|
|
100 |
entete.getElement().setInnerHTML(eHtml);
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public String getGuid() {
|
|
|
104 |
String guid = "URN:tela-botanica.org:";
|
|
|
105 |
guid += "coel"+projet.getId()+":";
|
|
|
106 |
guid += "pro"+projet.getId();
|
|
|
107 |
return guid;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
public void afficherDetailProjet() {
|
|
|
111 |
Params contenuParams = new Params();
|
|
|
112 |
|
|
|
113 |
contenuParams.set("i18n_titre_detail", i18nC.id());
|
|
|
114 |
|
|
|
115 |
String gHtml = formaterContenu(contenuTpl, contenuParams);
|
|
|
116 |
contenu.getElement().setInnerHTML(gHtml);
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
120 |
if (nouvellesDonnees instanceof Projet) {
|
|
|
121 |
projet = (Projet) nouvellesDonnees;
|
|
|
122 |
projetChargementOk = true;
|
|
|
123 |
} else if (nouvellesDonnees instanceof ProjetListe) {
|
|
|
124 |
projets = (ProjetListe) nouvellesDonnees;
|
|
|
125 |
projetsChargementOk = true;
|
|
|
126 |
GWT.log("projets recu", null);
|
|
|
127 |
} else {
|
|
|
128 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
if (avoirDonneesChargees()) {
|
|
|
132 |
afficherDetail();
|
|
|
133 |
}
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
private boolean avoirDonneesChargees() {
|
|
|
137 |
boolean ok = false;
|
|
|
138 |
if (projetsChargementOk && projetChargementOk) {
|
|
|
139 |
ok = true;
|
|
|
140 |
}
|
|
|
141 |
return ok;
|
|
|
142 |
}
|
|
|
143 |
}
|