Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
453 jp_milcent 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.Collection;
630 jp_milcent 8
import org.tela_botanica.client.modeles.CollectionBotanique;
453 jp_milcent 9
import org.tela_botanica.client.modeles.ProjetListe;
10
import org.tela_botanica.client.modeles.Structure;
11
import org.tela_botanica.client.modeles.ValeurListe;
12
 
13
import com.extjs.gxt.ui.client.Style.Scroll;
14
import com.extjs.gxt.ui.client.util.Format;
15
import com.extjs.gxt.ui.client.util.Params;
16
import com.extjs.gxt.ui.client.widget.ContentPanel;
17
import com.extjs.gxt.ui.client.widget.Html;
18
import com.extjs.gxt.ui.client.widget.TabItem;
19
import com.extjs.gxt.ui.client.widget.TabPanel;
20
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout;
21
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
22
import com.google.gwt.core.client.GWT;
23
 
24
public class CollectionDetailVue extends DetailVue implements Rafraichissable {
25
 
468 jp_milcent 26
	private Structure structure = null;
453 jp_milcent 27
 
28
	private String enteteTpl = null;
29
	private String generalTpl = null;
630 jp_milcent 30
	private String auteurTpl = null;
687 jp_milcent 31
	private String publicationTpl = null;
630 jp_milcent 32
	private String descriptionTpl = null;
33
	private String contenuTpl = null;
34
	private String documentTpl = null;
35
	private String inventaireTpl = null;
453 jp_milcent 36
 
37
	private Collection collection = null;
813 jpm 38
	private boolean collectionChargementOk = false;
453 jp_milcent 39
 
40
	private ContentPanel panneauPrincipal = null;
41
	private Html entete = null;
42
	private TabPanel onglets = null;
43
	private TabItem generalOnglet = null;
630 jp_milcent 44
	private TabItem auteurOnglet = null;
687 jp_milcent 45
	private TabItem publicationOnglet = null;
630 jp_milcent 46
	private TabItem descriptionOnglet = null;
47
	private TabItem contenuOnglet = null;
48
	private TabItem documentOnglet = null;
49
	private TabItem inventaireOnglet = null;
453 jp_milcent 50
 
51
	public CollectionDetailVue(Mediateur mediateurCourant) {
52
		super(mediateurCourant);
53
		initialiserTousLesTpl();
54
		chargerOntologie();
55
 
56
		panneauPrincipal = new ContentPanel();
57
		panneauPrincipal.setLayout(new FlowLayout());
58
		panneauPrincipal.setHeaderVisible(false);
59
		panneauPrincipal.setBodyBorder(false);
60
 
61
	    entete = new Html();
62
	    entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
63
	    panneauPrincipal.setTopComponent(entete);
64
 
65
		onglets = new TabPanel();
66
		onglets.setId(ComposantId.ZONE_DETAIL_CORPS);
67
		onglets.setHeight("100%");
68
		onglets.setBodyBorder(false);
69
 
70
		generalOnglet = new TabItem(i18nC.structureInfoGeneral());
71
		generalOnglet.setLayout(new AnchorLayout());
72
		generalOnglet.setScrollMode(Scroll.AUTO);
73
		onglets.add(generalOnglet);
74
 
630 jp_milcent 75
		auteurOnglet = new TabItem(i18nC.collectionAuteur());
76
		auteurOnglet.setLayout(new AnchorLayout());
77
		auteurOnglet.setScrollMode(Scroll.AUTO);
78
		onglets.add(auteurOnglet);
79
 
687 jp_milcent 80
		publicationOnglet = new TabItem(i18nC.collectionPublication());
81
		publicationOnglet.setLayout(new AnchorLayout());
82
		publicationOnglet.setScrollMode(Scroll.AUTO);
83
		onglets.add(publicationOnglet);
84
 
630 jp_milcent 85
		descriptionOnglet = new TabItem(i18nC.collectionDescription());
86
		descriptionOnglet.setLayout(new AnchorLayout());
87
		descriptionOnglet.setScrollMode(Scroll.AUTO);
88
		onglets.add(descriptionOnglet);
89
 
90
		contenuOnglet = new TabItem(i18nC.collectionContenu());
91
		contenuOnglet.setLayout(new AnchorLayout());
92
		contenuOnglet.setScrollMode(Scroll.AUTO);
93
		onglets.add(contenuOnglet);
94
 
95
		documentOnglet = new TabItem(i18nC.collectionDocument());
96
		documentOnglet.setLayout(new AnchorLayout());
97
		documentOnglet.setScrollMode(Scroll.AUTO);
98
		onglets.add(documentOnglet);
99
 
100
		inventaireOnglet = new TabItem(i18nC.collectionInventaire());
101
		inventaireOnglet.setLayout(new AnchorLayout());
102
		inventaireOnglet.setScrollMode(Scroll.AUTO);
103
		onglets.add(inventaireOnglet);
104
 
453 jp_milcent 105
		panneauPrincipal.add(onglets);
106
		add(panneauPrincipal);
107
	}
108
 
109
	private void initialiserTousLesTpl() {
110
		initialiserEnteteHtmlTpl();
111
		initialiserGeneralTpl();
630 jp_milcent 112
		initialiserAuteurTpl();
687 jp_milcent 113
		initialiserPublicationTpl();
630 jp_milcent 114
		initialiserContenuTpl();
115
		initialiserDescriptionTpl();
116
		initialiserDocumentTpl();
117
		initialiserInventaireTpl();
453 jp_milcent 118
	}
119
 
120
	private void initialiserEnteteHtmlTpl() {
121
		enteteTpl =
122
			"<div id='{css_id}'>"+
123
			"	<h1>{nom}</h1>"+
813 jpm 124
			"	<h2>{structure}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" +
453 jp_milcent 125
			"</div>";
126
	}
127
 
128
	private void initialiserGeneralTpl() {
129
		generalTpl =
130
			"<div class='{css_corps}'>"+
131
			"	<div class='{css_fieldset}'>"+
132
			"		<h2>{i18n_titre_identification}</h2>"+
630 jp_milcent 133
			"		<span class='{css_label}'>{i18n_nom_alternatif} :</span> {nom_alternatif}<br />"+
477 jp_milcent 134
			"		<span class='{css_label}'>{i18n_acronyme} :</span> {acronyme}<br />"+
135
			"		<span class='{css_label}'>{i18n_code} :</span> {code}<br />"+
630 jp_milcent 136
			"		<span class='{css_label}'>{i18n_cote} :</span> {cote}<br />"+
137
			"		<span class='{css_label}'>{i18n_mere} :</span> {mere}<br />"+
687 jp_milcent 138
			"		<span class='{css_label}'>{i18n_type_ncd} :</span> {type_ncd}<br />"+
139
			"		<span class='{css_label}'>{i18n_type_botanique} :</span> {type_botanique}<br />"+
140
			"		<span class='{css_label}'>{i18n_type_depot} :</span> {type_depot}<br />"+
141
			"		<span class='{css_label}'>{i18n_nbre_echantillon} :</span> {nbre_echantillon}<br />"+
453 jp_milcent 142
			"	</div>"+
477 jp_milcent 143
			"	<div class='{css_fieldset}'>"+
630 jp_milcent 144
			"		<h2>{i18n_general_collection_titre}</h2>"+
477 jp_milcent 145
			"		<span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
146
			"		<span class='{css_label}'>{i18n_description_specialiste} :</span> {description_specialiste}<br />"+
630 jp_milcent 147
			"		<span class='{css_label}'>{i18n_historique} :</span> {historique}<br />"+
148
			"		<span class='{css_label}'>{i18n_web} :</span> {web}<br />"+
149
			"		<span class='{css_label}'>{i18n_groupement_principe} :</span> {groupement_principe}<br />"+
150
			"		<span class='{css_label}'>{i18n_groupement_but} :</span> {groupement_but}<br />"+
477 jp_milcent 151
			"	</div>"+
152
			"	<hr class='{css_clear}'/>"+
453 jp_milcent 153
			"</div>";
154
	}
155
 
630 jp_milcent 156
	private void initialiserAuteurTpl() {
157
		auteurTpl =
158
			"<div class='{css_corps}'>"+
159
			"	<div class='{css_fieldset}'>"+
160
			"		<h2>{i18n_titre_auteur}</h2>"+
161
			"	</div>"+
162
			"	<hr class='{css_clear}'/>"+
163
			"</div>";
164
	}
165
 
687 jp_milcent 166
	private void initialiserPublicationTpl() {
167
		publicationTpl =
168
			"<div class='{css_corps}'>"+
169
			"	<div class='{css_fieldset}'>"+
170
			"		<h2>{i18n_titre_publication}</h2>"+
171
			"	</div>"+
172
			"	<hr class='{css_clear}'/>"+
173
			"</div>";
174
	}
175
 
630 jp_milcent 176
	private void initialiserDescriptionTpl() {
177
		descriptionTpl =
178
			"<div class='{css_corps}'>"+
179
			"	<div class='{css_fieldset}'>"+
180
			"		<h2>{i18n_titre_description}</h2>"+
181
			"	</div>"+
182
			"	<hr class='{css_clear}'/>"+
183
			"</div>";
184
	}
185
 
186
	private void initialiserContenuTpl() {
187
		contenuTpl =
188
			"<div class='{css_corps}'>"+
189
			"	<div class='{css_fieldset}'>"+
190
			"		<h2>{i18n_titre_contenu}</h2>"+
191
			"	</div>"+
192
			"	<hr class='{css_clear}'/>"+
193
			"</div>";
194
	}
195
 
196
	private void initialiserDocumentTpl() {
197
		documentTpl =
198
			"<div class='{css_corps}'>"+
199
			"	<div class='{css_fieldset}'>"+
200
			"		<h2>{i18n_titre_document}</h2>"+
201
			"	</div>"+
202
			"	<hr class='{css_clear}'/>"+
203
			"</div>";
204
	}
205
 
206
	private void initialiserInventaireTpl() {
207
		inventaireTpl =
208
			"<div class='{css_corps}'>"+
209
			"	<div class='{css_fieldset}'>"+
210
			"		<h2>{i18n_titre_inventaire}</h2>"+
211
			"	</div>"+
212
			"	<hr class='{css_clear}'/>"+
213
			"</div>";
214
	}
215
 
453 jp_milcent 216
	private void chargerOntologie() {
813 jpm 217
		String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot"};
218
		lancerChargementListesValeurs(listesCodes);
453 jp_milcent 219
	}
220
 
811 jpm 221
	public void rafraichir(Object nouvellesDonnees) {
222
		if (nouvellesDonnees instanceof Collection) {
223
			collection = (Collection) nouvellesDonnees;
813 jpm 224
			collectionChargementOk = true;
811 jpm 225
		} else if (nouvellesDonnees instanceof ProjetListe) {
226
			projets = (ProjetListe) nouvellesDonnees;
813 jpm 227
			projetsChargementOk = true;
811 jpm 228
		} else if (nouvellesDonnees instanceof ValeurListe) {
813 jpm 229
			ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
230
			receptionerOntologie(listeValeursReceptionnee);
453 jp_milcent 231
		} else {
232
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
233
		}
813 jpm 234
 
235
		if (avoirDonneesChargees()) {
236
			afficherDetail();
237
		}
453 jp_milcent 238
	}
239
 
813 jpm 240
	private boolean avoirDonneesChargees() {
241
		boolean ok = false;
242
		if (projetsChargementOk && collectionChargementOk && ontologieChargementOk) {
243
			ok = true;
244
		}
245
		return ok;
246
	}
247
 
453 jp_milcent 248
	private void afficherDetail() {
249
		if (collection != null) {
250
			afficherEntete();
251
			afficherIdentification();
630 jp_milcent 252
			afficherAuteur();
687 jp_milcent 253
			afficherPublication();
630 jp_milcent 254
			afficherDescription();
255
			afficherContenu();
256
			afficherDocument();
257
			afficherInventaire();
453 jp_milcent 258
		}
259
		layout();
260
	}
261
 
262
	private void afficherEntete() {
263
		Params enteteParams = new Params();
264
		enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
265
		enteteParams.set("css_meta", ComposantClass.META);
266
 
813 jpm 267
		enteteParams.set("i18n_id", i18nC.id());
268
 
453 jp_milcent 269
		enteteParams.set("nom", collection.getNom());
468 jp_milcent 270
		enteteParams.set("structure", collection.getStructureNom());
453 jp_milcent 271
		enteteParams.set("id", collection.getId());
272
		enteteParams.set("guid", collection.getGuid());
273
		enteteParams.set("projet", construireTxtProjet(collection.getIdProjet()));
274
 
275
		String eHtml = Format.substitute(enteteTpl, enteteParams);
276
		entete.getElement().setInnerHTML(eHtml);
277
	}
278
 
279
	private void afficherIdentification() {
280
		Params generalParams = new Params();
281
		generalParams.set("i18n_titre_identification", i18nC.titreAdministratif());
687 jp_milcent 282
		generalParams.set("i18n_nom_alternatif", i18nC.nomAlternatif());
453 jp_milcent 283
		generalParams.set("i18n_acronyme", i18nC.acronyme());
477 jp_milcent 284
		generalParams.set("i18n_code", i18nC.code());
285
		generalParams.set("i18n_cote", i18nC.cote());
286
		generalParams.set("i18n_mere", i18nC.collectionMere());
687 jp_milcent 287
		generalParams.set("i18n_type_ncd", i18nC.typeCollectionNcd());
288
		generalParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique());
289
		generalParams.set("i18n_type_depot", i18nC.typeDepot());
290
		generalParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon());
291
 
630 jp_milcent 292
		generalParams.set("i18n_general_collection_titre", i18nC.collectionGeneralTitre());
477 jp_milcent 293
		generalParams.set("i18n_description", i18nC.description());
294
		generalParams.set("i18n_description_specialiste", i18nC.descriptionSpecialiste());
295
		generalParams.set("i18n_historique", i18nC.historique());
296
		generalParams.set("i18n_web", i18nC.siteWeb());
297
		generalParams.set("i18n_groupement_principe", i18nC.groupementPrincipe());
298
		generalParams.set("i18n_groupement_but", i18nC.groupementBut());
299
 
300
		String acronyme = construireTxtTruck(collection.getIdAlternatif());
630 jp_milcent 301
		String code = construireTxtTruck(collection.getCode());
302
		String nomAlternatif = construireTxtTruck(collection.getNomAlternatif());
303
		String urls = construireTxtTruck(collection.getUrls());
304
		String typeNcd = construireTxtListeOntologie(collection.getTypeNcd());
305
		String typeBota = construireTxtListeOntologie(collection.getBotanique().getType());
306
		String typeDepot = construireTxtListeOntologie(collection.getTypeDepot());
307
 
308
		generalParams.set("nom_alternatif", nomAlternatif);
453 jp_milcent 309
		generalParams.set("acronyme", acronyme);
630 jp_milcent 310
		generalParams.set("code", code);
311
		generalParams.set("cote", collection.getCote());
312
		generalParams.set("mere", collection.getCollectionMereNom());
687 jp_milcent 313
		generalParams.set("type_ncd", typeNcd);
314
		generalParams.set("type_botanique", typeBota);
315
		generalParams.set("type_depot", typeDepot);
316
		generalParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon());
317
 
477 jp_milcent 318
		generalParams.set("description", collection.getDescription());
319
		generalParams.set("description_specialiste", collection.getDescriptionSpecialiste());
630 jp_milcent 320
		generalParams.set("historique", collection.getHistorique());
321
		generalParams.set("web", urls);
322
		generalParams.set("groupement_principe", collection.getGroupementPrincipe());
323
		generalParams.set("groupement_but", collection.getGroupementBut());
453 jp_milcent 324
 
325
		afficherOnglet(generalTpl, generalParams, generalOnglet);
326
	}
327
 
630 jp_milcent 328
	private void afficherAuteur() {
329
		Params auteurParams = new Params();
330
		auteurParams.set("i18n_titre_auteur", i18nC.collectionAuteurTitre());
331
 
332
		afficherOnglet(auteurTpl, auteurParams, auteurOnglet);
333
	}
334
 
687 jp_milcent 335
	private void afficherPublication() {
336
		Params publicationParams = new Params();
337
		publicationParams.set("i18n_titre_publication", i18nC.collectionPublicationTitre());
338
 
339
		afficherOnglet(publicationTpl, publicationParams, publicationOnglet);
340
	}
341
 
630 jp_milcent 342
	private void afficherDescription() {
343
		Params descriptionParams = new Params();
344
		descriptionParams.set("i18n_titre_description", i18nC.collectionDescriptionTitre());
345
 
346
		afficherOnglet(descriptionTpl, descriptionParams, descriptionOnglet);
347
	}
348
 
349
	private void afficherContenu() {
350
		Params contenuParams = new Params();
351
		contenuParams.set("i18n_titre_contenu", i18nC.collectionContenuTitre());
352
 
353
		afficherOnglet(contenuTpl, contenuParams, contenuOnglet);
354
	}
355
 
356
	private void afficherDocument() {
357
		Params documentParams = new Params();
358
		documentParams.set("i18n_titre_document", i18nC.collectionDocumentTitre());
359
 
360
		afficherOnglet(documentTpl, documentParams, documentOnglet);
361
	}
362
 
363
	private void afficherInventaire() {
364
		Params inventaireParams = new Params();
365
		inventaireParams.set("i18n_titre_inventaire", i18nC.collectionInventaireTitre());
366
 
367
		afficherOnglet(inventaireTpl, inventaireParams, inventaireOnglet);
368
	}
369
 
468 jp_milcent 370
	protected String getNomStructure() {
371
		String nomStructure = "";
372
		if (structure != null) {
373
			nomStructure = structure.getNom();
374
		} else {
375
			nomStructure = collection.getIdStructure();
453 jp_milcent 376
		}
468 jp_milcent 377
		return nomStructure;
453 jp_milcent 378
	}
379
}