Subversion Repositories eFlore/Applications.coel

Rev

Rev 468 | Go to most recent revision | Details | 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;
8
import org.tela_botanica.client.modeles.ProjetListe;
9
import org.tela_botanica.client.modeles.Structure;
10
import org.tela_botanica.client.modeles.StructureListe;
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
 
26
	private StructureListe structures = null;
27
 
28
	private String enteteTpl = null;
29
	private String generalTpl = null;
30
 
31
	private Collection collection = null;
32
 
33
	private ContentPanel panneauPrincipal = null;
34
	private Html entete = null;
35
	private TabPanel onglets = null;
36
	private TabItem generalOnglet = null;
37
 
38
	public CollectionDetailVue(Mediateur mediateurCourant) {
39
		super(mediateurCourant);
40
		initialiserTousLesTpl();
41
		chargerOntologie();
42
 
43
		panneauPrincipal = new ContentPanel();
44
		panneauPrincipal.setLayout(new FlowLayout());
45
		panneauPrincipal.setHeaderVisible(false);
46
		panneauPrincipal.setBodyBorder(false);
47
 
48
	    entete = new Html();
49
	    entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
50
	    panneauPrincipal.setTopComponent(entete);
51
 
52
		onglets = new TabPanel();
53
		onglets.setId(ComposantId.ZONE_DETAIL_CORPS);
54
		onglets.setHeight("100%");
55
		onglets.setBodyBorder(false);
56
 
57
		generalOnglet = new TabItem(i18nC.structureInfoGeneral());
58
		generalOnglet.setLayout(new AnchorLayout());
59
		generalOnglet.setScrollMode(Scroll.AUTO);
60
		onglets.add(generalOnglet);
61
 
62
		panneauPrincipal.add(onglets);
63
		add(panneauPrincipal);
64
	}
65
 
66
	private void initialiserTousLesTpl() {
67
		initialiserEnteteHtmlTpl();
68
		initialiserGeneralTpl();
69
	}
70
 
71
	private void initialiserEnteteHtmlTpl() {
72
		enteteTpl =
73
			"<div id='{css_id}'>"+
74
			"	<h1>{nom}</h1>"+
75
			"	<h2>{structure}<span class='{css_meta}'>{projet} - {id} - {guid}</span></h2>" +
76
			"	" +
77
			"</div>";
78
	}
79
 
80
	private void initialiserGeneralTpl() {
81
		generalTpl =
82
			"<div class='{css_corps}'>"+
83
			"	<div class='{css_fieldset}'>"+
84
			"		<h2>{i18n_titre_identification}</h2>"+
85
			"		<span class='{css_label}'>{i18n_sigle} :</span> {sigle}<br />"+
86
			"	</div>"+
87
			"</div>";
88
	}
89
 
90
	private void chargerOntologie() {
91
 
92
	}
93
 
94
	public void rafraichir(Object nouvelleDonnees) {
95
		if (nouvelleDonnees instanceof Collection) {
96
			collection = (Collection) nouvelleDonnees;
97
			afficherDetail();
98
		} else if (nouvelleDonnees instanceof ProjetListe) {
99
			projets = (ProjetListe) nouvelleDonnees;
100
		} else if (nouvelleDonnees instanceof ValeurListe) {
101
			ValeurListe ontologieReceptionnee = (ValeurListe) nouvelleDonnees;
102
			ajouterListeValeursAOntologie(ontologieReceptionnee);
103
		} else {
104
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
105
		}
106
	}
107
 
108
	private void afficherDetail() {
109
		if (collection != null) {
110
			afficherEntete();
111
			afficherIdentification();
112
		}
113
		layout();
114
	}
115
 
116
	private void afficherEntete() {
117
		Params enteteParams = new Params();
118
		enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
119
		enteteParams.set("css_meta", ComposantClass.META);
120
 
121
		enteteParams.set("nom", collection.getNom());
122
		enteteParams.set("structure", construireTxtStructure(collection.getIdStructure()));
123
		enteteParams.set("id", collection.getId());
124
		enteteParams.set("guid", collection.getGuid());
125
		enteteParams.set("projet", construireTxtProjet(collection.getIdProjet()));
126
 
127
		String eHtml = Format.substitute(enteteTpl, enteteParams);
128
		entete.getElement().setInnerHTML(eHtml);
129
	}
130
 
131
	private void afficherIdentification() {
132
		Params generalParams = new Params();
133
		generalParams.set("i18n_titre_identification", i18nC.titreAdministratif());
134
		generalParams.set("i18n_acronyme", i18nC.acronyme());
135
 
136
		String acronyme = construireTxtTruck(collection.getIdAlternatif());
137
 
138
		generalParams.set("acronyme", acronyme);
139
 
140
		afficherOnglet(generalTpl, generalParams, generalOnglet);
141
	}
142
 
143
	protected String construireTxtStructure(String idStructure) {
144
		String chaineARetourner = idStructure;
145
 
146
		if (structures != null) {
147
			Structure structure = structures.get(idStructure);
148
			String nomStructure = structure.getNom();
149
			if  (!nomStructure.equals("")) {
150
				chaineARetourner = nomStructure;
151
			}
152
		}
153
 
154
		return chaineARetourner;
155
	}
156
}