Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
60 jpm 1
package org.tela_botanica.client.vues;
2
 
379 jp_milcent 3
import java.util.Iterator;
4
import java.util.Map.Entry;
5
 
6
import org.tela_botanica.client.ComposantClass;
373 jp_milcent 7
import org.tela_botanica.client.ComposantId;
8
import org.tela_botanica.client.Mediateur;
60 jpm 9
import org.tela_botanica.client.interfaces.Rafraichissable;
379 jp_milcent 10
import org.tela_botanica.client.modeles.Information;
60 jpm 11
import org.tela_botanica.client.modeles.Structure;
379 jp_milcent 12
import org.tela_botanica.client.modeles.StructureAPersonne;
13
import org.tela_botanica.client.modeles.StructureAPersonneListe;
14
import org.tela_botanica.client.modeles.StructureConservation;
15
import org.tela_botanica.client.modeles.StructureValorisation;
60 jpm 16
 
374 jp_milcent 17
import com.extjs.gxt.ui.client.Events;
60 jpm 18
import com.extjs.gxt.ui.client.Style.Scroll;
19
import com.extjs.gxt.ui.client.util.Format;
20
import com.extjs.gxt.ui.client.util.Params;
21
import com.extjs.gxt.ui.client.widget.ContentPanel;
374 jp_milcent 22
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
23
import com.extjs.gxt.ui.client.widget.Html;
373 jp_milcent 24
import com.extjs.gxt.ui.client.widget.HtmlContainer;
25
import com.extjs.gxt.ui.client.widget.LayoutContainer;
26
import com.extjs.gxt.ui.client.widget.TabItem;
27
import com.extjs.gxt.ui.client.widget.TabPanel;
60 jpm 28
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
374 jp_milcent 29
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
373 jp_milcent 30
import com.google.gwt.core.client.GWT;
60 jpm 31
 
373 jp_milcent 32
public class StructureDetailPanneauVue extends LayoutContainer implements Rafraichissable {
60 jpm 33
 
373 jp_milcent 34
	private Mediateur mediateur = null;
35
 
374 jp_milcent 36
	private String enteteTpl = null;
379 jp_milcent 37
	private String identificationTpl = null;
38
	private String personnelTpl = null;
39
	private String lignePersonnelTpl = null;
373 jp_milcent 40
 
41
	private Structure structure = null;
379 jp_milcent 42
	private StructureAPersonneListe personnel = null;
43
	private StructureValorisation valorisation = null;
44
	private StructureConservation conservation = null;
373 jp_milcent 45
 
46
	private ContentPanel panneauPrincipal = null;
374 jp_milcent 47
	private Html entete = null;
373 jp_milcent 48
	private TabPanel onglets = null;
49
	private TabItem identificationOnglet = null;
379 jp_milcent 50
	private TabItem personnelOnglet = null;
60 jpm 51
 
373 jp_milcent 52
	public StructureDetailPanneauVue(Mediateur mediateurCourant) {
53
		mediateur = mediateurCourant;
379 jp_milcent 54
		initialiserTousLesTpl();
60 jpm 55
 
56
		setLayout(new FitLayout());
373 jp_milcent 57
		setBorders(false);
58
		setScrollMode(Scroll.AUTO);
59
 
60
		panneauPrincipal = new ContentPanel();
374 jp_milcent 61
		panneauPrincipal.setLayout(new FlowLayout());
62
		panneauPrincipal.setHeaderVisible(false);
63
		panneauPrincipal.setBodyBorder(false);
373 jp_milcent 64
 
65
 
374 jp_milcent 66
	    entete = new Html();
379 jp_milcent 67
	    entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
374 jp_milcent 68
	    panneauPrincipal.setTopComponent(entete);
69
 
373 jp_milcent 70
		onglets = new TabPanel();
379 jp_milcent 71
		onglets.setId(ComposantId.ZONE_DETAIL_CORPS);
374 jp_milcent 72
		onglets.setHeight("100%");
73
		onglets.setBorders(false);
74
		onglets.setBodyBorder(false);
75
 
373 jp_milcent 76
		identificationOnglet = new TabItem("Général");
379 jp_milcent 77
		identificationOnglet.setBorders(false);
78
		identificationOnglet.setScrollMode(Scroll.AUTO);
373 jp_milcent 79
		onglets.add(identificationOnglet);
80
 
379 jp_milcent 81
		personnelOnglet = new TabItem("Personnel");
82
		personnelOnglet.setBorders(false);
83
		personnelOnglet.setScrollMode(Scroll.AUTO);
84
		onglets.add(personnelOnglet);
85
 
373 jp_milcent 86
		panneauPrincipal.add(onglets);
87
		add(panneauPrincipal);
60 jpm 88
	}
89
 
373 jp_milcent 90
	private void afficherDetailInstitution(Structure structureCourante) {
91
		if (structureCourante != null) {
92
			structure = structureCourante;
379 jp_milcent 93
			personnel = structure.getPersonnel();
94
			valorisation = structure.getValorisation();
95
			conservation = structure.getConservation();
96
 
373 jp_milcent 97
			afficherEntete();
98
			afficherIdentification();
60 jpm 99
		}
374 jp_milcent 100
		layout();
60 jpm 101
	}
373 jp_milcent 102
 
103
	private void afficherEntete() {
104
		Params enteteParams = new Params();
379 jp_milcent 105
		enteteParams.set("id", ComposantId.ZONE_DETAIL_ENTETE);
106
		enteteParams.set("nom", structure.getNom());
107
		enteteParams.set("ville", structure.getVille());
373 jp_milcent 108
 
374 jp_milcent 109
		String eHtml = Format.substitute(enteteTpl, enteteParams);
373 jp_milcent 110
		entete.getElement().setInnerHTML(eHtml);
111
	}
112
 
113
	private void afficherIdentification() {
114
		Params contenuParams = new Params();
379 jp_milcent 115
		contenuParams.set("css_class", ComposantClass.DETAIL_CORPS_CONTENU);
116
		contenuParams.set("description", structure.getDescription());
117
		contenuParams.set("adresse", structure.getAdresse());
118
		contenuParams.set("code_postal", structure.getCodePostal());
119
		contenuParams.set("ville", structure.getVille());
120
		contenuParams.set("region", structure.getRegion());
121
		contenuParams.set("pays", structure.getPays());
122
		contenuParams.set("tel", structure.getTelephone());
123
		contenuParams.set("fax", structure.getFax());
124
		contenuParams.set("courriel", structure.getCourriel());
125
		contenuParams.set("acces", structure.getConditionAcces());
126
 
127
		String cHtml = Format.substitute(identificationTpl, contenuParams);
373 jp_milcent 128
		HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
374 jp_milcent 129
		identificationOnglet.removeAll();
373 jp_milcent 130
		identificationOnglet.add(corpsConteneurDuHtml);
131
	}
132
 
379 jp_milcent 133
	private void afficherPersonnel() {
134
		Params contenuParams = new Params();
135
		contenuParams.set("css_class", ComposantClass.DETAIL_CORPS_CONTENU);
136
		contenuParams.set("fonction", mediateur.i18nC.fonction());
137
		contenuParams.set("prenom", mediateur.i18nC.prenom());
138
		contenuParams.set("nom", mediateur.i18nC.nom());
139
		contenuParams.set("tel", mediateur.i18nC.telephoneFixe());
140
		contenuParams.set("fax", mediateur.i18nC.fax());
141
		contenuParams.set("courriel", mediateur.i18nC.courrielPrincipal());
142
		contenuParams.set("statut", mediateur.i18nC.statut());
143
		contenuParams.set("tps_w", mediateur.i18nC.tpsTravail());
144
		contenuParams.set("specialite", mediateur.i18nC.specialite());
145
		contenuParams.set("contact", mediateur.i18nC.boolContact());
146
 
147
		String lignesPersonnel = "";
148
		personnel = structure.getPersonnel();
149
		Iterator<String> it = personnel.keySet().iterator();
150
		while (it.hasNext()) {
151
			StructureAPersonne personne = personnel.get(it.next());
152
			Params ligneParams = new Params();
153
			ligneParams.set("fonction", personne.getFonction());
154
			ligneParams.set("prenom", personne.getPrenom());
155
			ligneParams.set("nom", personne.getNom());
156
			ligneParams.set("tel", personne.getTelephone());
157
			ligneParams.set("fax", personne.getFax());
158
			ligneParams.set("courriel", personne.getCourriel());
159
			ligneParams.set("statut", personne.getStatut());
160
			ligneParams.set("tps_w", personne.getBotaTravailHebdoTps());
161
			ligneParams.set("specialite", personne.afficherSpecialite());
162
			ligneParams.set("contact", personne.getContact());
163
			lignesPersonnel += Format.substitute(lignePersonnelTpl, ligneParams);
164
		}
165
		contenuParams.set("lignes", lignesPersonnel);
166
 
167
		String cHtml = Format.substitute(personnelTpl, contenuParams);
168
		HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
169
		personnelOnglet.removeAll();
170
		personnelOnglet.add(corpsConteneurDuHtml);
171
	}
172
 
173
	private void initialiserTousLesTpl() {
174
		initialiserEnteteHtmlTpl();
175
		initialiserIdentificationTpl();
176
		initialiserPersonnelTpl();
177
		initialiserLignePersonnelTpl();
178
	}
179
 
373 jp_milcent 180
	private void initialiserEnteteHtmlTpl() {
379 jp_milcent 181
		enteteTpl = 	"<div id='{id}'>"+
182
						"	<h1>{nom}</h1>"+
183
						"	<h2>{ville}</h2>" +
373 jp_milcent 184
						"</div>";
185
	}
186
 
379 jp_milcent 187
	private void initialiserIdentificationTpl() {
188
		identificationTpl =
189
						"<div class='{css_class}'>"+
373 jp_milcent 190
						"	<h2>Renseignements administratifs</h2>"+
379 jp_milcent 191
						"	<span style='font-weight:bold;'>Condition d'accès :</span> {acces}<br />"+
192
						"	<span style='font-weight:bold;'>Adresse :</span> {adresse}, {code_postal} {ville}, {region}, {pays}<br />"+
193
						"	<span style='font-weight:bold;'>Téléphone :</span> {tel}<br />"+
194
						"	<span style='font-weight:bold;'>Fax :</span> {fax}<br />"+
195
						"	<span style='font-weight:bold;'>Courriel :</span> {courriel}<br />"+
196
						"	{description}"+
373 jp_milcent 197
						"</div>";
198
	}
199
 
379 jp_milcent 200
	private void initialiserPersonnelTpl() {
201
		personnelTpl =
202
						"<div class='{css_class}'>"+
203
						"	<h2>Personnel</h2>"+
204
						"	<table>"+
205
						"		<thead>"+
206
						"			<tr>" +
207
						"				<th>{fonction}</th>" +
208
						"				<th>{prenom}</th>" +
209
						"				<th>{nom}</th>" +
210
						"				<th>{tel}</th>" +
211
						"				<th>{fax}</th>" +
212
						"				<th>{courriel}</th>" +
213
						"				<th>{statut}</th>" +
214
						"				<th>{tps_w}</th>" +
215
						"				<th>{specialite}</th>" +
216
						"				<th>{contact}</th>" +
217
						"			</tr>"+
218
						"		</thead>"+
219
						"		<tbody>"+
220
						"			{lignes}"+
221
						"		</tbody>"+
222
						"	</table>"+
223
						"</div>";
224
	}
225
 
226
	private void initialiserLignePersonnelTpl() {
227
		lignePersonnelTpl =
228
						"<tr>"+
229
						"	<td>{fonction}</td>"+
230
						"	<td>{prenom}</td>"+
231
						"	<td>{nom}</td>"+
232
						"	<td>{tel}</td>" +
233
						"	<td>{fax}</td>" +
234
						"	<td>{courriel}</td>" +
235
						"	<td>{statut}</td>" +
236
						"	<td>{tps_w}</td>" +
237
						"	<td>{specialite}</td>" +
238
						"	<td>{contact}</td>" +
239
						"</tr>";
240
	}
241
 
60 jpm 242
	public void rafraichir(Object nouvelleDonnees) {
243
		if (nouvelleDonnees instanceof Structure) {
244
			afficherDetailInstitution((Structure) nouvelleDonnees);
379 jp_milcent 245
		} if (nouvelleDonnees instanceof Information) {
246
			Information info = (Information) nouvelleDonnees;
247
			if (info.getType().equals("liste_structure_a_personne")) {
248
				allouerPersonnelAStructure((StructureAPersonneListe) info.getDonnee(0));
249
				afficherPersonnel();
250
				layout();
251
			}
373 jp_milcent 252
		} else {
253
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
60 jpm 254
		}
255
	}
256
 
379 jp_milcent 257
	private void allouerPersonnelAStructure(StructureAPersonneListe personnel) {
258
		structure.setPersonnel(personnel);
259
	}
260
 
60 jpm 261
}