Subversion Repositories eFlore/Applications.coel

Rev

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