Subversion Repositories eFlore/Applications.coel

Rev

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