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