Subversion Repositories eFlore/Applications.coel

Rev

Details | 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;
390 jp_milcent 28
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout;
60 jpm 29
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
374 jp_milcent 30
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
373 jp_milcent 31
import com.google.gwt.core.client.GWT;
390 jp_milcent 32
import com.google.gwt.i18n.client.DateTimeFormat;
60 jpm 33
 
373 jp_milcent 34
public class StructureDetailPanneauVue extends LayoutContainer implements Rafraichissable {
60 jpm 35
 
373 jp_milcent 36
	private Mediateur mediateur = null;
37
 
374 jp_milcent 38
	private String enteteTpl = null;
379 jp_milcent 39
	private String identificationTpl = null;
40
	private String personnelTpl = null;
390 jp_milcent 41
	private String tableauPersonnelTpl = null;
379 jp_milcent 42
	private String lignePersonnelTpl = null;
390 jp_milcent 43
	private String conservationTpl = null;
44
	private String valorisationTpl = null;
373 jp_milcent 45
 
46
	private Structure structure = null;
379 jp_milcent 47
	private StructureAPersonneListe personnel = null;
48
	private StructureValorisation valorisation = null;
49
	private StructureConservation conservation = null;
373 jp_milcent 50
 
51
	private ContentPanel panneauPrincipal = null;
374 jp_milcent 52
	private Html entete = null;
373 jp_milcent 53
	private TabPanel onglets = null;
54
	private TabItem identificationOnglet = null;
379 jp_milcent 55
	private TabItem personnelOnglet = null;
390 jp_milcent 56
	private TabItem conservationOnglet = null;
57
	private TabItem valorisationOnglet = null;
60 jpm 58
 
373 jp_milcent 59
	public StructureDetailPanneauVue(Mediateur mediateurCourant) {
60
		mediateur = mediateurCourant;
379 jp_milcent 61
		initialiserTousLesTpl();
60 jpm 62
 
63
		setLayout(new FitLayout());
373 jp_milcent 64
		setBorders(false);
65
		setScrollMode(Scroll.AUTO);
66
 
67
		panneauPrincipal = new ContentPanel();
374 jp_milcent 68
		panneauPrincipal.setLayout(new FlowLayout());
69
		panneauPrincipal.setHeaderVisible(false);
70
		panneauPrincipal.setBodyBorder(false);
390 jp_milcent 71
 
374 jp_milcent 72
	    entete = new Html();
379 jp_milcent 73
	    entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
374 jp_milcent 74
	    panneauPrincipal.setTopComponent(entete);
75
 
373 jp_milcent 76
		onglets = new TabPanel();
379 jp_milcent 77
		onglets.setId(ComposantId.ZONE_DETAIL_CORPS);
374 jp_milcent 78
		onglets.setHeight("100%");
79
		onglets.setBodyBorder(false);
80
 
373 jp_milcent 81
		identificationOnglet = new TabItem("Général");
390 jp_milcent 82
		identificationOnglet.setLayout(new AnchorLayout());
379 jp_milcent 83
		identificationOnglet.setScrollMode(Scroll.AUTO);
373 jp_milcent 84
		onglets.add(identificationOnglet);
85
 
379 jp_milcent 86
		personnelOnglet = new TabItem("Personnel");
390 jp_milcent 87
		personnelOnglet.setLayout(new AnchorLayout());
379 jp_milcent 88
		personnelOnglet.setScrollMode(Scroll.AUTO);
89
		onglets.add(personnelOnglet);
90
 
390 jp_milcent 91
		conservationOnglet = new TabItem("Conservation");
92
		conservationOnglet.setLayout(new AnchorLayout());
93
		conservationOnglet.setScrollMode(Scroll.AUTO);
94
		onglets.add(conservationOnglet);
95
 
96
		valorisationOnglet = new TabItem("Valorisation");
97
		valorisationOnglet.setLayout(new AnchorLayout());
98
		valorisationOnglet.setScrollMode(Scroll.AUTO);
99
		onglets.add(valorisationOnglet);
100
 
373 jp_milcent 101
		panneauPrincipal.add(onglets);
102
		add(panneauPrincipal);
60 jpm 103
	}
104
 
390 jp_milcent 105
	private void afficherDetailInstitution() {
106
		if (structure != null) {
379 jp_milcent 107
			personnel = structure.getPersonnel();
108
			valorisation = structure.getValorisation();
109
			conservation = structure.getConservation();
110
 
373 jp_milcent 111
			afficherEntete();
112
			afficherIdentification();
390 jp_milcent 113
			if (personnel != null) {
114
				afficherPersonnel();
115
			}
116
			if (conservation != null) {
117
				//afficherConservation();
118
			}
119
			if (valorisation != null) {
120
				//afficherValorisation();
121
			}
60 jpm 122
		}
374 jp_milcent 123
		layout();
60 jpm 124
	}
373 jp_milcent 125
 
126
	private void afficherEntete() {
127
		Params enteteParams = new Params();
390 jp_milcent 128
		enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
129
		enteteParams.set("css_meta", ComposantClass.META);
130
 
379 jp_milcent 131
		enteteParams.set("nom", structure.getNom());
132
		enteteParams.set("ville", structure.getVille());
390 jp_milcent 133
		enteteParams.set("id", structure.getId());
134
		enteteParams.set("guid", structure.getGuid());
135
		enteteParams.set("projet", structure.getIdProjet());
373 jp_milcent 136
 
374 jp_milcent 137
		String eHtml = Format.substitute(enteteTpl, enteteParams);
373 jp_milcent 138
		entete.getElement().setInnerHTML(eHtml);
139
	}
140
 
141
	private void afficherIdentification() {
142
		Params contenuParams = new Params();
390 jp_milcent 143
		contenuParams.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU);
144
		contenuParams.set("css_label", ComposantClass.LABEL);
145
		contenuParams.set("css_fieldset", ComposantClass.FIELDSET);
146
		contenuParams.set("css_clear", ComposantClass.CLEAR);
147
 
148
		contenuParams.set("i18n_titre_administratif", mediateur.i18nC.titreAdministratif());
149
		contenuParams.set("i18n_acronyme", mediateur.i18nC.acronyme());
150
		contenuParams.set("i18n_statut", mediateur.i18nC.statut());
151
		contenuParams.set("i18n_date_fondation", mediateur.i18nC.dateFondation());
152
		contenuParams.set("i18n_nbre_personnel", mediateur.i18nC.nbrePersonnel());
153
 
154
		contenuParams.set("i18n_titre_description", mediateur.i18nC.description());
155
		contenuParams.set("i18n_description", mediateur.i18nC.description());
156
 
157
		contenuParams.set("i18n_titre_adresse", mediateur.i18nC.adresse());
158
		contenuParams.set("i18n_adresse", mediateur.i18nC.adresse());
159
		contenuParams.set("i18n_cp", mediateur.i18nC.codePostal());
160
		contenuParams.set("i18n_ville", mediateur.i18nC.ville());
161
		contenuParams.set("i18n_region", mediateur.i18nC.region());
162
		contenuParams.set("i18n_pays", mediateur.i18nC.pays());
163
 
164
		contenuParams.set("i18n_titre_communication", mediateur.i18nC.titreCommunication());
165
		contenuParams.set("i18n_tel", mediateur.i18nC.telephone());
166
		contenuParams.set("i18n_fax", mediateur.i18nC.fax());
167
		contenuParams.set("i18n_courriel", mediateur.i18nC.courriel());
168
		contenuParams.set("i18n_acces", mediateur.i18nC.acces());
169
		contenuParams.set("i18n_web", mediateur.i18nC.siteWeb());
170
 
171
		contenuParams.set("acronyme", structure.getIdAlternatif());
172
		contenuParams.set("statut", structure.getTypePrive()+structure.getTypePublic());
392 jp_milcent 173
		contenuParams.set("date_fondation", structure.getDateFondationFormatLong());
390 jp_milcent 174
		contenuParams.set("nbre_personnel", structure.getNbrePersonne());
175
 
379 jp_milcent 176
		contenuParams.set("description", structure.getDescription());
390 jp_milcent 177
 
379 jp_milcent 178
		contenuParams.set("adresse", structure.getAdresse());
390 jp_milcent 179
		contenuParams.set("cp", structure.getCodePostal());
379 jp_milcent 180
		contenuParams.set("ville", structure.getVille());
181
		contenuParams.set("region", structure.getRegion());
182
		contenuParams.set("pays", structure.getPays());
390 jp_milcent 183
 
379 jp_milcent 184
		contenuParams.set("tel", structure.getTelephone());
185
		contenuParams.set("fax", structure.getFax());
186
		contenuParams.set("courriel", structure.getCourriel());
187
		contenuParams.set("acces", structure.getConditionAcces());
390 jp_milcent 188
		contenuParams.set("web", structure.getUrl());
379 jp_milcent 189
 
190
		String cHtml = Format.substitute(identificationTpl, contenuParams);
373 jp_milcent 191
		HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
374 jp_milcent 192
		identificationOnglet.removeAll();
373 jp_milcent 193
		identificationOnglet.add(corpsConteneurDuHtml);
194
	}
195
 
379 jp_milcent 196
	private void afficherPersonnel() {
390 jp_milcent 197
		String tableauPersonnelHtml = "";
198
		if (personnel.size() > 0) {
199
			tableauPersonnelHtml = construireTableauDuPersonnel();
200
		}
201
 
379 jp_milcent 202
		Params contenuParams = new Params();
390 jp_milcent 203
		contenuParams.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU);
204
		contenuParams.set("i18n_titre_personnel", mediateur.i18nC.titrePersonnel());
205
		contenuParams.set("i18n_nbre_personnel_collection", mediateur.i18nC.nbrePersonnelCollection());
206
		contenuParams.set("nbre_personnel_collection", personnel.size());
207
		contenuParams.set("tableau_personnel", tableauPersonnelHtml);
208
		String cHtml = Format.substitute(personnelTpl, contenuParams);
379 jp_milcent 209
 
390 jp_milcent 210
		HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
211
		personnelOnglet.removeAll();
212
		personnelOnglet.add(corpsConteneurDuHtml);
213
	}
214
 
215
	private String construireTableauDuPersonnel() {
216
		Params contenuParams = new Params();
217
		contenuParams.set("i18n_titre_membre", mediateur.i18nC.titreMembre());
218
		contenuParams.set("i18n_fonction", mediateur.i18nC.fonction());
219
		contenuParams.set("i18n_prenom", mediateur.i18nC.prenom());
220
		contenuParams.set("i18n_nom", mediateur.i18nC.nom());
221
		contenuParams.set("i18n_tel", mediateur.i18nC.telephoneFixe());
222
		contenuParams.set("i18n_fax", mediateur.i18nC.fax());
223
		contenuParams.set("i18n_courriel", mediateur.i18nC.courrielPrincipal());
224
		contenuParams.set("i18n_statut", mediateur.i18nC.statut());
225
		contenuParams.set("i18n_tps_w", mediateur.i18nC.tpsTravail());
226
		contenuParams.set("i18n_specialite", mediateur.i18nC.specialite());
227
		contenuParams.set("i18n_contact", mediateur.i18nC.boolContact());
228
 
379 jp_milcent 229
		String lignesPersonnel = "";
230
		Iterator<String> it = personnel.keySet().iterator();
231
		while (it.hasNext()) {
232
			StructureAPersonne personne = personnel.get(it.next());
233
			Params ligneParams = new Params();
234
			ligneParams.set("fonction", personne.getFonction());
235
			ligneParams.set("prenom", personne.getPrenom());
236
			ligneParams.set("nom", personne.getNom());
237
			ligneParams.set("tel", personne.getTelephone());
238
			ligneParams.set("fax", personne.getFax());
239
			ligneParams.set("courriel", personne.getCourriel());
240
			ligneParams.set("statut", personne.getStatut());
241
			ligneParams.set("tps_w", personne.getBotaTravailHebdoTps());
242
			ligneParams.set("specialite", personne.afficherSpecialite());
243
			ligneParams.set("contact", personne.getContact());
244
			lignesPersonnel += Format.substitute(lignePersonnelTpl, ligneParams);
245
		}
246
		contenuParams.set("lignes", lignesPersonnel);
247
 
390 jp_milcent 248
		String cHtml = Format.substitute(tableauPersonnelTpl, contenuParams);
249
		return cHtml;
379 jp_milcent 250
	}
390 jp_milcent 251
 
379 jp_milcent 252
	private void initialiserTousLesTpl() {
253
		initialiserEnteteHtmlTpl();
254
		initialiserIdentificationTpl();
255
		initialiserPersonnelTpl();
390 jp_milcent 256
		initialiserTableauPersonnelTpl();
379 jp_milcent 257
		initialiserLignePersonnelTpl();
390 jp_milcent 258
		initialiserConservationTpl();
259
		initialiserValorisationTpl();
379 jp_milcent 260
	}
261
 
373 jp_milcent 262
	private void initialiserEnteteHtmlTpl() {
390 jp_milcent 263
		enteteTpl = 	"<div id='{css_id}'>"+
379 jp_milcent 264
						"	<h1>{nom}</h1>"+
390 jp_milcent 265
						"	<h2>{ville}<span class='{css_meta}'>{projet} - {id} - {guid}</span></h2>" +
266
						"	" +
373 jp_milcent 267
						"</div>";
268
	}
269
 
379 jp_milcent 270
	private void initialiserIdentificationTpl() {
271
		identificationTpl =
390 jp_milcent 272
						"<div class='{css_corps}'>"+
273
						"	<div class='{css_fieldset}'>"+
274
						"		<h2>{i18n_titre_administratif}</h2>"+
275
						"		<span class='{css_label}'>{i18n_acronyme} :</span> {acronyme}<br />"+
276
						"		<span class='{css_label}'>{i18n_acces} :</span> {acces}<br />"+
277
						"		<span class='{css_label}'>{i18n_statut} :</span> {statut}<br />"+
278
						"		<span class='{css_label}'>{i18n_date_fondation} :</span> {date_fondation}<br />"+
279
						"		<span class='{css_label}'>{i18n_nbre_personnel} :</span> {nbre_personnel}<br />"+
280
						"	</div>"+
281
						"	<div class='{css_fieldset}'>"+
282
						"		<h2>{i18n_titre_description}</h2>"+
283
						"		{description}"+
284
						"	</div>"+
285
						"	<hr class='{css_clear}'/>"+
286
						"	<div class='{css_fieldset}'>"+
287
						"		<h2>{i18n_titre_adresse}</h2>"+
288
						"		<span class='{css_label}'>{i18n_adresse} :</span> {adresse}<br />" +
289
						"		<span class='{css_label}'>{i18n_cp} :</span> {cp}<br />" +
290
						"		<span class='{css_label}'>{i18n_ville} :</span> {ville}<br />" +
291
						"		<span class='{css_label}'>{i18n_region} :</span> {region}<br />" +
292
						"		<span class='{css_label}'>{i18n_pays} :</span> {pays}<br />" +
293
						"	</div>"+
294
						"	<div class='{css_fieldset}'>"+
295
						"		<h2>{i18n_titre_communication}</h2>"+
296
						"		<span class='{css_label}'>{i18n_tel} :</span> {tel}<br />"+
297
						"		<span class='{css_label}'>{i18n_fax} :</span> {fax}<br />"+
298
						"		<span class='{css_label}'>{i18n_courriel} :</span> {courriel}<br />"+
299
						"		<span class='{css_label}'>{i18n_web} :</span> {web}<br />"+
300
						"	</div>"+
373 jp_milcent 301
						"</div>";
302
	}
303
 
379 jp_milcent 304
	private void initialiserPersonnelTpl() {
305
		personnelTpl =
390 jp_milcent 306
						"<div class='{css_corps}'>"+
307
						"	<h2>{i18n_titre_personnel}</h2>"+
308
						"	<p><span class='{css_label}'>{i18n_nbre_personnel_collection} :</span> {nbre_personnel_collection}</p>"+
309
						"	{tableau_personnel}"+
379 jp_milcent 310
						"</div>";
311
	}
312
 
390 jp_milcent 313
	private void initialiserTableauPersonnelTpl() {
314
		tableauPersonnelTpl =
315
						"<h3>{i18n_titre_membre}</h3>"+
316
						"<table>"+
317
						"	<thead>"+
318
						"		<tr>" +
319
						"			<th>{i18n_fonction}</th>" +
320
						"			<th>{i18n_prenom}</th>" +
321
						"			<th>{i18n_nom}</th>" +
322
						"			<th>{i18n_tel}</th>" +
323
						"			<th>{i18n_fax}</th>" +
324
						"			<th>{i18n_courriel}</th>" +
325
						"			<th>{i18n_statut}</th>" +
326
						"			<th>{i18n_tps_w}</th>" +
327
						"			<th>{i18n_specialite}</th>" +
328
						"			<th>{i18n_contact}</th>" +
329
						"		</tr>"+
330
						"	</thead>"+
331
						"	<tbody>"+
332
						"		{lignes}"+
333
						"	</tbody>"+
334
						"</table>";
335
	}
336
 
379 jp_milcent 337
	private void initialiserLignePersonnelTpl() {
338
		lignePersonnelTpl =
339
						"<tr>"+
340
						"	<td>{fonction}</td>"+
341
						"	<td>{prenom}</td>"+
342
						"	<td>{nom}</td>"+
343
						"	<td>{tel}</td>" +
344
						"	<td>{fax}</td>" +
345
						"	<td>{courriel}</td>" +
346
						"	<td>{statut}</td>" +
347
						"	<td>{tps_w}</td>" +
348
						"	<td>{specialite}</td>" +
349
						"	<td>{contact}</td>" +
350
						"</tr>";
351
	}
352
 
390 jp_milcent 353
	private void initialiserConservationTpl() {
354
		conservationTpl =
355
						"<div class='{css_corps}'>"+
356
						"	<div class='{css_fieldset}'>"+
357
						"		<h2>{i18n_titre_conservation_personnel}</h2>"+
358
						"		<span class='{css_label}'>{i18n_formation} :</span> {formation_interet}<br />"+
359
						"		<span class='{css_label}'>{i18n_formation_interet} :</span> {formation_interet}<br />"+
360
						"	</div>"+
361
						"	<div class='{css_fieldset}'>"+
362
						"		<h2>{i18n_titre_local}</h2>"+
363
						"		<span class='{css_label}'>{i18n_local_specifique} :</span> {local_specifique}<br />"+
364
						"		<span class='{css_label}'>{i18n_meuble_specifique} :</span> {meuble_specifique}<br />"+
365
						"		<span class='{css_label}'>{i18n_local_parametre} :</span> {local_parametre}<br />"+
366
						"		<span class='{css_label}'>{i18n_conservation_en_commun} :</span> {conservation_en_commun}<br />"+
367
						"		<span class='{css_label}'>{i18n_acces_control} :</span> {acces_control}<br />"+
368
						"	</div>"+
369
						"	<hr class='{css_clear}'/>"+
370
						"</div>";
371
	}
372
 
373
	private void initialiserValorisationTpl() {
374
		valorisationTpl =
375
						"<div class='{css_corps}'>"+
376
						"	<div class='{css_fieldset}'>"+
377
						"		<h2>{i18n_titre_action_valorisation}</h2>"+
378
						"	</div>"+
379
						"	<div class='{css_fieldset}'>"+
380
						"		<h2>{i18n_titre_recherche_scientifique}</h2>"+
381
						"	</div>"+
382
						"	<hr class='{css_clear}'/>"+
383
						"	<div class='{css_fieldset}'>"+
384
						"		<h2>{i18n_titre_acces_usage}</h2>"+
385
						"	</div>"+
386
						"</div>";
387
	}
388
 
60 jpm 389
	public void rafraichir(Object nouvelleDonnees) {
390
		if (nouvelleDonnees instanceof Structure) {
390 jp_milcent 391
			structure = (Structure) nouvelleDonnees;
392
			afficherDetailInstitution();
379 jp_milcent 393
		} if (nouvelleDonnees instanceof Information) {
394
			Information info = (Information) nouvelleDonnees;
395
			if (info.getType().equals("liste_structure_a_personne")) {
396
				allouerPersonnelAStructure((StructureAPersonneListe) info.getDonnee(0));
390 jp_milcent 397
				afficherDetailInstitution();
379 jp_milcent 398
			}
373 jp_milcent 399
		} else {
400
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
60 jpm 401
		}
402
	}
403
 
379 jp_milcent 404
	private void allouerPersonnelAStructure(StructureAPersonneListe personnel) {
405
		structure.setPersonnel(personnel);
406
	}
407
 
60 jpm 408
}