Subversion Repositories eFlore/Applications.coel

Rev

Rev 373 | Rev 379 | 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
 
373 jp_milcent 3
import org.tela_botanica.client.ComposantId;
4
import org.tela_botanica.client.Mediateur;
60 jpm 5
import org.tela_botanica.client.interfaces.Rafraichissable;
6
import org.tela_botanica.client.modeles.Structure;
7
 
374 jp_milcent 8
import com.extjs.gxt.ui.client.Events;
60 jpm 9
import com.extjs.gxt.ui.client.Style.Scroll;
10
import com.extjs.gxt.ui.client.util.Format;
11
import com.extjs.gxt.ui.client.util.Params;
12
import com.extjs.gxt.ui.client.widget.ContentPanel;
374 jp_milcent 13
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
14
import com.extjs.gxt.ui.client.widget.Html;
373 jp_milcent 15
import com.extjs.gxt.ui.client.widget.HtmlContainer;
16
import com.extjs.gxt.ui.client.widget.LayoutContainer;
17
import com.extjs.gxt.ui.client.widget.TabItem;
18
import com.extjs.gxt.ui.client.widget.TabPanel;
60 jpm 19
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
374 jp_milcent 20
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
373 jp_milcent 21
import com.google.gwt.core.client.GWT;
60 jpm 22
 
373 jp_milcent 23
public class StructureDetailPanneauVue extends LayoutContainer implements Rafraichissable {
60 jpm 24
 
373 jp_milcent 25
	private Mediateur mediateur = null;
26
 
374 jp_milcent 27
	private String enteteTpl = null;
28
	private String contenuTpl = null;
373 jp_milcent 29
 
30
	private Structure structure = null;
31
 
32
	private ContentPanel panneauPrincipal = null;
374 jp_milcent 33
	private Html entete = null;
373 jp_milcent 34
	private TabPanel onglets = null;
35
	private TabItem identificationOnglet = null;
60 jpm 36
 
373 jp_milcent 37
	public StructureDetailPanneauVue(Mediateur mediateurCourant) {
38
		mediateur = mediateurCourant;
39
		initialiserEnteteHtmlTpl();
40
		initialiserContenuHtmlTpl();
60 jpm 41
 
42
		setLayout(new FitLayout());
373 jp_milcent 43
		setBorders(false);
44
		setScrollMode(Scroll.AUTO);
45
 
46
		panneauPrincipal = new ContentPanel();
374 jp_milcent 47
		panneauPrincipal.setLayout(new FlowLayout());
48
		panneauPrincipal.setHeaderVisible(false);
49
		panneauPrincipal.setBodyBorder(false);
373 jp_milcent 50
 
51
 
374 jp_milcent 52
	    entete = new Html();
53
	    entete.setId(ComposantId.ZONE_DETAIL);
54
	    panneauPrincipal.setTopComponent(entete);
55
 
373 jp_milcent 56
		onglets = new TabPanel();
374 jp_milcent 57
		onglets.setHeight("100%");
58
		onglets.setBorders(false);
59
		onglets.setBodyBorder(false);
60
 
373 jp_milcent 61
		identificationOnglet = new TabItem("Général");
62
		onglets.add(identificationOnglet);
63
 
64
		panneauPrincipal.add(onglets);
65
		add(panneauPrincipal);
60 jpm 66
	}
67
 
373 jp_milcent 68
	private void afficherDetailInstitution(Structure structureCourante) {
69
		if (structureCourante != null) {
70
			structure = structureCourante;
60 jpm 71
 
373 jp_milcent 72
			afficherEntete();
73
			afficherIdentification();
60 jpm 74
		}
374 jp_milcent 75
		layout();
60 jpm 76
	}
373 jp_milcent 77
 
78
	private void afficherEntete() {
79
		Params enteteParams = new Params();
80
		enteteParams.add(ComposantId.ZONE_DETAIL);
81
		enteteParams.add(structure.getNom());
82
		enteteParams.add(structure.getVille());
83
 
374 jp_milcent 84
		String eHtml = Format.substitute(enteteTpl, enteteParams);
373 jp_milcent 85
		entete.getElement().setInnerHTML(eHtml);
86
	}
87
 
88
	private void afficherIdentification() {
89
		Params contenuParams = new Params();
90
		contenuParams.add(structure.getDescription());
91
		contenuParams.add(structure.getAdresse());
92
		contenuParams.add(structure.getCodePostal());
93
		contenuParams.add(structure.getVille());
94
		contenuParams.add(structure.getRegion());
95
		contenuParams.add(structure.getPays());
96
		contenuParams.add(structure.getTelephone());
97
		contenuParams.add(structure.getFax());
98
		contenuParams.add(structure.getCourriel());
99
		contenuParams.add(structure.getConditionAcces());
100
		contenuParams.add(ComposantId.ZONE_DETAIL_CORPS);
60 jpm 101
 
374 jp_milcent 102
		String cHtml = Format.substitute(contenuTpl, contenuParams);
373 jp_milcent 103
		HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
374 jp_milcent 104
		identificationOnglet.removeAll();
373 jp_milcent 105
		identificationOnglet.add(corpsConteneurDuHtml);
106
	}
107
 
108
	private void initialiserEnteteHtmlTpl() {
374 jp_milcent 109
		enteteTpl = 	"<div id='{0}'>"+
373 jp_milcent 110
						"	<h1>{1}</h1>"+
111
						"	<h2>{2}</h2>" +
112
						"</div>";
113
	}
114
 
115
	private void initialiserContenuHtmlTpl() {
374 jp_milcent 116
		contenuTpl = 	"<div id='{10}'>"+
373 jp_milcent 117
						"	<h2>Renseignements administratifs</h2>"+
118
						"	<span style='font-weight:bold;'>Condition d'accès :</span> {9}<br />"+
119
						"	<span style='font-weight:bold;'>Adresse :</span> {1}, {2} {3}, {4}, {5}<br />"+
120
						"	<span style='font-weight:bold;'>Téléphone :</span> {6}<br />"+
121
						"	<span style='font-weight:bold;'>Fax :</span> {7}<br />"+
122
						"	<span style='font-weight:bold;'>Courriel :</span> {8}<br />"+
123
						"	{0}"+
124
						"</div>";
125
	}
126
 
60 jpm 127
	public void rafraichir(Object nouvelleDonnees) {
128
		if (nouvelleDonnees instanceof Structure) {
129
			afficherDetailInstitution((Structure) nouvelleDonnees);
373 jp_milcent 130
		} else {
131
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
60 jpm 132
		}
133
	}
134
 
135
}