106 |
aurelien |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
553 |
jp_milcent |
3 |
import org.tela_botanica.client.Mediateur;
|
|
|
4 |
import org.tela_botanica.client.i18n.Constantes;
|
106 |
aurelien |
5 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
6 |
import org.tela_botanica.client.modeles.Publication;
|
|
|
7 |
import org.tela_botanica.client.modeles.PublicationListe;
|
|
|
8 |
|
|
|
9 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
|
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 |
|
444 |
jp_milcent |
16 |
public class PublicationDetailVue extends ContentPanel implements Rafraichissable {
|
553 |
jp_milcent |
17 |
|
|
|
18 |
private Mediateur mediateur = null;
|
|
|
19 |
private Constantes i18nC = null;
|
|
|
20 |
|
106 |
aurelien |
21 |
private ContentPanel content;
|
|
|
22 |
private Html header;
|
|
|
23 |
private String enteteHTML = "<div class='coel-detail'><h1>{0}</h1><h2>{1}</h2><h2>{2}</h2></div>";
|
|
|
24 |
private String contenuHTML = "<div style='padding: 12px;'><h2>Détails de la publication</h2><span style='font-weight:bold;'>Nom de la revue :</span> {0}<br /><span style='font-weight:bold;'>Editeur :</span> {1}<br /><span style='font-weight:bold;'>Année :</span> {2}<br /><span style='font-weight:bold;'>Tome :</span> {3}<br /><span style='font-weight:bold;'>Fascicule :</span> {4}<br /><span style='font-weight:bold;'>Pages :</span> {5}</div>";
|
|
|
25 |
private String publicationNom = null;
|
|
|
26 |
private String publicationAuteur = null;
|
|
|
27 |
private String publicationDateParution = null;
|
|
|
28 |
|
553 |
jp_milcent |
29 |
public PublicationDetailVue(Mediateur mediateurCourant) {
|
|
|
30 |
mediateur = mediateurCourant;
|
|
|
31 |
i18nC = mediateur.i18nC;
|
|
|
32 |
|
106 |
aurelien |
33 |
setHeaderVisible(false);
|
|
|
34 |
setLayout(new FitLayout());
|
|
|
35 |
|
|
|
36 |
content = new ContentPanel();
|
|
|
37 |
content.setBodyBorder(false);
|
|
|
38 |
content.setHeaderVisible(false);
|
|
|
39 |
content.setScrollMode(Scroll.AUTO);
|
|
|
40 |
|
|
|
41 |
header = new Html();
|
|
|
42 |
header.setStyleName("coel-detail");
|
|
|
43 |
content.setTopComponent(header);
|
|
|
44 |
|
|
|
45 |
add(content);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public void afficherDetailPublication(Publication publication) {
|
|
|
49 |
if (publication != null) {
|
|
|
50 |
content.removeAll();
|
|
|
51 |
|
|
|
52 |
publicationNom = publication.getTitre();
|
227 |
aurelien |
53 |
publicationAuteur = publication.getAuteur().replaceAll("\\|", ", ");;
|
106 |
aurelien |
54 |
publicationDateParution = publication.getDateParution();
|
|
|
55 |
|
|
|
56 |
Params enteteParams = new Params();
|
|
|
57 |
enteteParams.add(publicationNom);
|
|
|
58 |
enteteParams.add(publicationAuteur);
|
|
|
59 |
enteteParams.add(publicationDateParution);
|
|
|
60 |
|
|
|
61 |
String eHtml = Format.substitute(enteteHTML, enteteParams);
|
|
|
62 |
header.getElement().setInnerHTML(eHtml);
|
|
|
63 |
|
|
|
64 |
Params contenuParams = new Params();
|
|
|
65 |
contenuParams.add(publication.getCollection());
|
|
|
66 |
contenuParams.add(publication.getEditeur());
|
|
|
67 |
contenuParams.add(publication.getDateParution());
|
|
|
68 |
contenuParams.add(publication.getIndicationNvt());
|
|
|
69 |
contenuParams.add(publication.getFascicule());
|
|
|
70 |
contenuParams.add(publication.getPages());
|
|
|
71 |
|
|
|
72 |
String cHtml = Format.substitute(contenuHTML, contenuParams);
|
|
|
73 |
content.addText(cHtml);
|
|
|
74 |
|
|
|
75 |
layout();
|
|
|
76 |
} else {
|
|
|
77 |
header.setHtml("");
|
|
|
78 |
content.removeAll();
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
public void rafraichir(Object nouvelleDonnees) {
|
|
|
83 |
if (nouvelleDonnees instanceof Publication) {
|
|
|
84 |
afficherDetailPublication((Publication) nouvelleDonnees);
|
|
|
85 |
} else if (nouvelleDonnees instanceof PublicationListe) {
|
|
|
86 |
PublicationListe listePublication = (PublicationListe) nouvelleDonnees;
|
|
|
87 |
// Test pour savoir si la liste contient des éléments
|
|
|
88 |
if (listePublication.size() == 0) {
|
|
|
89 |
afficherDetailPublication(null);
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
}
|