Subversion Repositories eFlore/Applications.coel

Rev

Rev 834 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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}'>"+
877 aurelien 57
			"	<h1>{projet}</h1>"+
58
			"	<h2>{abreviation} <span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" +
834 aurelien 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>"+
877 aurelien 67
			"		<span class='{css_label}'>{i18n_nom} :</span> {nom}<br />"+
68
			"		<span class='{css_label}'>{i18n_abreviation} :</span> {abreviation}<br />"+
69
			"		<span class='{css_label}'>{i18n_resume} :</span> {resume}<br />"+
70
			"		<span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
71
			"		<span class='{css_label}'>{i18n_citation} :</span> {citation}<br />"+
72
			"		<span class='{css_label}'>{i18n_licence} :</span> {licence}<br />"+
73
			"		<span class='{css_label}'>{i18n_langue} :</span> {langue}<br />"+
74
			"		<span class='{css_label}'>{i18n_indexation_heure} :</span> {indexation_heure}<br />"+
75
			"		<span class='{css_label}'>{i18n_indexation_duree} :</span> {indexation_duree}<br />"+
76
			"		<span class='{css_label}'>{i18n_indexation_frequence} :</span> {indexation_frequence}<br />"+
77
			"		<span class='{css_label}'>{i18n_mark_public} :</span> {mark_public}<br />"+
834 aurelien 78
			"	</div>"+
79
			"	<hr class='{css_clear}'/>"+
80
			"</div>";
81
	}
82
 
83
	public void afficherDetail() {
84
		if (projet != null) {
85
			afficherEntete();
86
			afficherDetailProjet();
87
		}
88
		layout();
89
	}
90
 
91
	private void afficherEntete() {
92
		Params enteteParams = new Params();
93
		enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
94
		enteteParams.set("css_meta", ComposantClass.META);
95
 
96
		enteteParams.set("i18n_id", i18nC.id());
97
 
98
		enteteParams.set("id", projet.getId());
99
		enteteParams.set("guid", getGuid());
100
		enteteParams.set("projet", construireTxtProjet(projet.getId()));
877 aurelien 101
		enteteParams.set("abreviation", projet.getAbreviation());
834 aurelien 102
		GWT.log("entete généré", null);
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"+projet.getId()+":";
110
		guid += "pro"+projet.getId();
111
		return guid;
112
	}
113
 
114
	public void afficherDetailProjet() {
115
		Params contenuParams = new Params();
116
 
877 aurelien 117
		contenuParams.set("i18n_titre_detail", i18nC.projet());
834 aurelien 118
 
877 aurelien 119
		contenuParams.set("i18n_nom", i18nC.nom());
120
		contenuParams.set("nom", projet.getNom());
121
 
122
		contenuParams.set("i18n_abreviation", i18nC.projetAbreviation());
123
		contenuParams.set("abreviation", projet.getAbreviation());
124
 
125
		contenuParams.set("i18n_resume", i18nC.projetResume());
126
		contenuParams.set("resume", projet.getResume());
127
 
128
		contenuParams.set("i18n_description", i18nC.projetDescription());
129
		contenuParams.set("description", projet.getDescription());
130
 
131
		contenuParams.set("i18n_mots_cles", i18nC.projetMotsCles());
132
		contenuParams.set("mots_cles", projet.getMotsCles());
133
 
134
		contenuParams.set("i18n_citation", i18nC.projetCitation());
135
		contenuParams.set("citation", projet.getCitation());
136
 
137
		contenuParams.set("i18n_licence", i18nC.projetLicence());
138
		contenuParams.set("licence", projet.getLicence());
139
 
140
		contenuParams.set("i18n_langue", i18nC.projetLangue());
141
		contenuParams.set("langue", projet.getLangue());
142
 
143
		contenuParams.set("i18n_indexation_heure", i18nC.projetIndexationHeure());
144
		contenuParams.set("indexation_heure", projet.getIndexationHeure());
145
 
146
		contenuParams.set("i18n_indexation_duree", i18nC.projetIndexationDuree());
147
		contenuParams.set("indexation_duree", projet.getIndexationDuree());
148
 
149
		contenuParams.set("i18n_indexation_frequence", i18nC.projetIndexationFrequence());
150
		contenuParams.set("indexation_frequence", projet.getIndexationFreq());
151
 
152
		contenuParams.set("i18n_mark_public", i18nC.projetMarkPublic());
153
		contenuParams.set("mark_public", projet.getMarkPublic());
154
 
834 aurelien 155
		String gHtml = formaterContenu(contenuTpl, contenuParams);
156
		contenu.getElement().setInnerHTML(gHtml);
157
	}
158
 
159
	public void rafraichir(Object nouvellesDonnees) {
160
		if (nouvellesDonnees instanceof Projet) {
161
			projet = (Projet) nouvellesDonnees;
162
			projetChargementOk = true;
163
		} else if (nouvellesDonnees instanceof ProjetListe) {
164
			projets = (ProjetListe) nouvellesDonnees;
165
			projetsChargementOk = true;
166
			GWT.log("projets recu", null);
167
		} else {
168
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
169
		}
170
 
171
		if (avoirDonneesChargees()) {
172
			afficherDetail();
173
		}
174
	}
175
 
176
	private boolean avoirDonneesChargees() {
177
		boolean ok = false;
178
		if (projetsChargementOk && projetChargementOk) {
179
			ok = true;
180
		}
181
		return ok;
182
	}
183
}