Subversion Repositories eFlore/Applications.coel

Rev

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