Subversion Repositories eFlore/Applications.coel

Rev

Rev 189 | Rev 198 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 189 Rev 197
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line 2...
2
 
2
 
-
 
3
 
-
 
4
 
Line 3... Line 5...
3
 
5
import java.util.HashMap;
4
 
6
import java.util.Iterator;
5
import java.util.List;
-
 
6
 
7
 
7
import org.tela_botanica.client.RegistreId;
-
 
8
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
9
import org.tela_botanica.client.modeles.Information;
-
 
10
import org.tela_botanica.client.modeles.Personne;
8
 
Line 11... Line 9...
11
import org.tela_botanica.client.modeles.Projet;
9
import org.tela_botanica.client.RegistreId;
12
import org.tela_botanica.client.modeles.ProjetsListeAsyncDao;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
11
import org.tela_botanica.client.modeles.Personne;
13
import org.tela_botanica.client.modeles.Structure;
12
import org.tela_botanica.client.modeles.StructureListe;
14
import org.tela_botanica.client.modeles.StructureListe;
13
 
15
 
-
 
16
import com.extjs.gxt.ui.client.Registry;
14
import com.extjs.gxt.ui.client.Registry;
-
 
15
import com.extjs.gxt.ui.client.Style.Scroll;
17
import com.extjs.gxt.ui.client.Style.Scroll;
16
import com.extjs.gxt.ui.client.event.ComponentEvent;
18
import com.extjs.gxt.ui.client.util.Format;
17
import com.extjs.gxt.ui.client.event.KeyListener;
-
 
18
import com.extjs.gxt.ui.client.util.Params;
-
 
19
import com.extjs.gxt.ui.client.widget.Html;
19
import com.extjs.gxt.ui.client.util.Params;
20
import com.extjs.gxt.ui.client.widget.LayoutContainer;
-
 
21
import com.extjs.gxt.ui.client.widget.TabItem;
-
 
22
import com.extjs.gxt.ui.client.widget.TabPanel;
-
 
23
import com.extjs.gxt.ui.client.widget.form.FieldSet;
20
import com.extjs.gxt.ui.client.widget.ContentPanel;
24
import com.extjs.gxt.ui.client.widget.form.TextField;
-
 
25
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
21
import com.extjs.gxt.ui.client.widget.Html;
26
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
22
import com.extjs.gxt.ui.client.widget.TabItem;
27
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
-
 
28
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
23
import com.extjs.gxt.ui.client.widget.TabPanel;
29
import com.google.gwt.dom.client.LinkElement;
24
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
30
import com.google.gwt.dom.client.NodeList;
25
import com.google.gwt.user.client.ui.FlexTable;
-
 
26
import com.google.gwt.user.client.ui.Grid;
31
import com.google.gwt.user.client.Window;
Line 27... Line 32...
27
import com.google.gwt.user.client.ui.Hyperlink;
32
import com.google.gwt.user.client.ui.Hyperlink;
Line -... Line 33...
-
 
33
import com.google.gwt.user.client.ui.Image;
Line 28... Line 34...
28
import com.google.gwt.user.client.ui.Label;
34
import com.google.gwt.user.client.ui.Label;
29
import com.google.gwt.user.client.ui.Widget;
-
 
30
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
-
 
31
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
-
 
32
 
35
import com.google.gwt.user.client.ui.Widget;
33
public class PersonneDetailPanneauVue extends TabPanel implements Rafraichissable {
-
 
34
 
-
 
35
	
36
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
36
	private Html header;
37
 
37
	
-
 
38
	//TABS
-
 
Line 39... Line 38...
39
	// Informations générales : nom, prénom, adresse, cp, ville, adresse email, sexe, projet
38
public class PersonneDetailPanneauVue extends TabPanel implements Rafraichissable {
Line 40... Line 39...
40
	private TabItem infoGenerales;
39
 
41
	private String contenuInfo = "<div style='padding: 12px;'><h1>{0}</h1><a href=\"{1}\">{1}</a><br /><br /><p><b>Adresse: </b>{2}<br />{3}<br />{4} {5}<br /> {7}</p><br />{6}</div>";
40
	// Le panneau détail se compose de formulaires tabulés
Line 42... Line 41...
42
	
41
	
-
 
42
	// Onglet 1 : identite & contact
-
 
43
	private TabItem identite;
-
 
44
	private FieldSet fsIdentite;
-
 
45
	private FieldSet fsContact;
-
 
46
	
-
 
47
	public PersonneDetailPanneauVue() {
-
 
48
		
-
 
49
		Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
-
 
50
		setLayout(new FitLayout());
-
 
51
		
-
 
52
		identite = new TabItem("Identité");
-
 
53
		identite.setLayout(new TableLayout(2));		
-
 
54
		identite.setScrollMode(Scroll.AUTO);
43
	private TabItem infoBio;
55
		
Line 44... Line -...
44
	private String contenuBio = "";
-
 
45
			// <div style='padding: 12px;'><h1>{0} {1} {2}</h1><h2>{3}</h2><br><b>Date de naissance: </b>{4}<br /><b>Date de décès:{5}</b><p>{6}</p></div>";
-
 
46
	
-
 
47
	
56
		fsIdentite = new FieldSet();
Line 48... Line -...
48
	public PersonneDetailPanneauVue() {
-
 
49
		
-
 
50
		Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
-
 
51
		setLayout(new FitLayout());
-
 
52
		
-
 
53
		infoGenerales = new TabItem("Informations Générales");
57
		
54
		this.add(infoGenerales);
58
		fsIdentite.setLayout(new FormLayout());
55
		
-
 
56
		infoBio = new TabItem("Biographie");
59
		
57
		infoBio.disable();
-
 
58
		this.add(infoBio);
60
		
59
	}
-
 
60
 
61
		fsContact = new FieldSet();
61
	private void ajouterParam(Params parametres, String nomChamp, Personne personne)	{
-
 
62
		Object valeur = personne.obtenirValeurChamp(nomChamp);
-
 
63
		parametres.add(valeur);
62
		
64
	}	
63
		fsContact.setLayout(new FormLayout());
65
	
-
 
-
 
64
		
66
	public void afficherDetailPersonne(Personne personne) {
65
		
67
		if (personne != null) {
66
		this.add(identite);
68
			infoGenerales.removeAll();
-
 
69
			infoBio.removeAll();
67
		
70
			infoBio.disable();
-
 
71
			
-
 
72
			//Contenu
68
	}
73
			Params infoGenParams = new Params();
69
 
-
 
70
	public void afficherDetailPersonne(Personne personne) {
74
			ajouterParam(infoGenParams, "fmt_nom_complet", personne);
71
		if (personne != null) {
75
			ajouterParam(infoGenParams, "truk_courriel", personne);
-
 
76
			ajouterParam(infoGenParams, "adresse_01", personne);
72
			identite.removeAll();
Line 77... Line -...
77
			ajouterParam(infoGenParams, "adresse_02", personne);
-
 
78
			ajouterParam(infoGenParams, "code_postal", personne);
-
 
79
			ajouterParam(infoGenParams, "ville", personne);
-
 
80
			ajouterParam(infoGenParams, "description", personne);
-
 
81
			ajouterParam(infoGenParams, "cp_truk_fax", personne);
-
 
82
			
73
			
83
			//Info générales
-
 
84
			infoGenerales.addText(Format.substitute(contenuInfo, infoGenParams));
74
			fsIdentite.setHeading("Identité");
85
			
75
			fsIdentite.setWidth("350px");
86
			Params bioParams = new Params();
76
			fsIdentite.setStyleAttribute("padding", "1px");
Line -... Line 77...
-
 
77
			
-
 
78
			fsContact.setHeading("Contact");
87
			// Nécessaire que si une biographie existe...
79
			fsContact.setWidth("350px");
Line -... Line 80...
-
 
80
			
-
 
81
			
-
 
82
			identite.add(fsIdentite);
-
 
83
			
-
 
84
			String logoUrl = (String) personne.obtenirValeurChamp("truk_logo");
-
 
85
			if ((logoUrl!=null)&&(!logoUrl.trim().equals("")))	{
-
 
86
				
-
 
87
				Image img = new Image();
-
 
88
				img.setUrl(logoUrl);
-
 
89
				img.setTitle("logo-personne");
-
 
90
				identite.add(img);
-
 
91
				
-
 
92
			}	else	{
-
 
93
				identite.add(new Label());
-
 
94
			}
-
 
95
			
-
 
96
			identite.add(fsContact);
-
 
97
			
-
 
98
			
-
 
99
			
-
 
100
			
-
 
101
			
-
 
102
			fsIdentite.removeAll();
-
 
103
			fsContact.removeAll();
-
 
104
			//Ajout des champs Identité
-
 
105
			
-
 
106
			
-
 
107
			
-
 
108
			// TODO: projet
-
 
109
			
-
 
110
			// nom complet
-
 
111
			Object nomComplet = personne.obtenirValeurChamp("fmt_nom_complet");
-
 
112
			ajouterTextFieldNonEditable(fsIdentite,"Nom", nomComplet);
-
 
113
			
-
 
114
			
-
 
115
			// TODO : nom autre
-
 
116
			
-
 
117
			// abreviation
-
 
118
			Object abreviation = personne.obtenirValeurChamp("abreviation");
-
 
119
			ajouterTextFieldNonEditable(fsIdentite, "Abreviation", abreviation);
-
 
120
			
-
 
121
			// date naissance
-
 
122
			Object dateNaissance = personne.obtenirValeurChamp("date_naissance");
-
 
123
			ajouterTextFieldNonEditable(fsIdentite, "Date de naissance", dateNaissance);
-
 
124
			
-
 
125
			// lieu naissance
-
 
126
			Object lieuNaissance = personne.obtenirValeurChamp("lieu_naissance");
-
 
127
			ajouterTextFieldNonEditable(fsIdentite, "Lieu de naissance", lieuNaissance);
-
 
128
			
-
 
129
			// date deces
-
 
130
			Object dateDeces = personne.obtenirValeurChamp("date_deces");
-
 
131
			ajouterTextFieldNonEditable(fsIdentite, "Date de décès", dateDeces);
-
 
132
			
-
 
133
			// lieu deces
-
 
134
			Object lieuDeces = personne.obtenirValeurChamp("lieu_deces");
-
 
135
			ajouterTextFieldNonEditable(fsIdentite, "Lieu de décès", lieuDeces);
-
 
136
			
-
 
137
			
-
 
138
			
-
 
139
			//CONTACT
-
 
140
			
-
 
141
			String courriel =  (String) personne.obtenirValeurChamp("truk_courriel");
-
 
142
			Hyperlink lnkCourriel = new Hyperlink();
-
 
143
			lnkCourriel.setHTML("<b style=\"margin:0 50px 0 0 ; color:black;\">Courriel:</b><a href=\"mailto:" + courriel + "\">" + courriel + "</a>");
-
 
144
			fsContact.add(lnkCourriel);
-
 
145
			
-
 
146
			fsContact.addText("<br >");
-
 
147
			
-
 
148
			String adresse01 = (String) personne.obtenirValeurChamp("adresse_01");
-
 
149
			ajouterTextFieldNonEditable(fsContact, "Adresse", adresse01);
-
 
150
			
-
 
151
			
-
 
152
			String adresse02 = (String) personne.obtenirValeurChamp("adresse_02");
-
 
153
			ajouterTextFieldNonEditable(fsContact, "", adresse02);
-
 
154
			
Line 88... Line -...
88
			// FIXME : remplacer par un id role? 
-
 
Line 89... Line 155...
89
			if ((personne.obtenirValeurChamp("biographie")!=null)&&(!((String) personne.obtenirValeurChamp("biographie")).trim().equals("")))	{
155
			String boitePostale = (String) personne.obtenirValeurChamp("bp");
90
				
156
			ajouterTextFieldNonEditable(fsContact, "Boite Postale", boitePostale);
-
 
157
			
-
 
158
			String codePostal = (String) personne.obtenirValeurChamp("code_postal");
-
 
159
			ajouterTextFieldNonEditable(fsContact, "Code postal", codePostal);
-
 
160
			
-
 
161
			String ville = (String) personne.obtenirValeurChamp("ville");
-
 
162
			ajouterTextFieldNonEditable(fsContact, "Ville", ville);
-
 
163
			
-
 
164
			String region = (String) personne.obtenirValeurChamp("region");
-
 
165
			ajouterTextFieldNonEditable(fsContact, "Région", region);
-
 
166
			
-
 
167
			String pays = (String) personne.obtenirValeurChamp("pays");
-
 
168
			ajouterTextFieldNonEditable(fsContact, "Pays", pays);
-
 
169
			
91
				contenuBio = "<div style='padding: 12px;'><h1>{0} {1} {2}</h1><h2>{3}</h2><br><b>Date de naissance: </b>{4}<br /><b>Date de décès:{5}</b><p>a{6}a</p></div>";
170
			fsContact.addText("<br >");	
-
 
171
			
-
 
172
			
-
 
173
			
Line -... Line 174...
-
 
174
			layout();
-
 
175
		} 
-
 
176
	}
-
 
177
 
-
 
178
	public void ajouterTextFieldNonEditable(FieldSet fs, String tfLabel, Object tfValue)	{
-
 
179
	
-
 
180
		if ((tfValue!=null)&&(!tfValue.toString().trim().equals("")))	{
92
								
181
			
93
				ajouterParam(bioParams, "ce_truk_prefix", personne);
182
			TextField tf = new TextField();
-
 
183
		
-
 
184
			tf.setFieldLabel(tfLabel);
-
 
185
			if ((tfLabel==null)||("".equals(tfLabel)))	{
-
 
186
				tf.setHideLabel(true);
-
 
187
				tf.setStyleAttribute("margin", "0 0 0 105px");
-
 
188
			}
-
 
189
			tf.setValue(tfValue);
-
 
190
		
-
 
191
			// Non éditable : on empêche l'évènement par défaut
-
 
192
			tf.addKeyListener(new KeyListener()	{
-
 
193
			
-
 
194
			public void componentKeyPress(ComponentEvent ev)	{
-
 
195
				ev.stopEvent();
-
 
196
			}
-
 
197
			});
-
 
198
		
-
 
199
			//Ajout au fieldSet
-
 
200
			fs.add(tf);
-
 
201
		}
-
 
202
	}
-
 
203
	
-
 
204
	/*public void visualiserPersonneIdentite()	{
-
 
205
		
-
 
206
		//FieldSet identité
-
 
207
		
-
 
208
		FieldSet fsId = new FieldSet();
-
 
209
		fsId.setHeading("Identité");
-
 
210
		fsId.setLayout(new FormLayout());
-
 
211
		
-
 
212
		visualiser(champsIdentite, fsId);
-
 
213
		
-
 
214
		/*NodeList nl = (NodeList) fsId.getElement().getChildNodes();
-
 
215
		Window.alert(String.valueOf(nl.getLength()));*/
-
 
216
		
-
 
217
		/*identite.add(fsId);
-
 
218
		
-
 
219
		//TEST
-
 
220
		Widget w = (TextField) fsId.getWidget(0);
-
 
221
		
-
 
222
		
-
 
223
		//FieldSet contact
-
 
224
		FieldSet fsContact = new FieldSet();
-
 
225
		fsContact.setHeading("Contact");
-
 
226
		
-
 
227
		
-
 
228
		
-
 
229
	}
-
 
230
	
-
 
231
	public void visualiser(HashMap champs, LayoutContainer lContent)	{
-
 
232
		
-
 
233
		Iterator<String> itNomChamps = champs.keySet().iterator();
94
				ajouterParam(bioParams, "fmt_nom_complet", personne);
234
		while (itNomChamps.hasNext())	{
95
				ajouterParam(bioParams, "ce_truk_suffix", personne);
235
			TextField<String> nom = new TextField();
96
				ajouterParam(bioParams, "abreviation", personne);
236
			String cle = itNomChamps.next();
97
				ajouterParam(bioParams, "naissance_date", personne);
237
			nom.setFieldLabel(cle);
98
				ajouterParam(bioParams, "deces_date", personne);
238
			nom.setValue((String) champs.get(cle));
99
				ajouterParam(bioParams, "biographie", personne);
239
			
Line 122... Line 262...
122
				afficherDetailPersonne(null);
262
				afficherDetailPersonne(null);
123
			}
263
			}
124
		}
264
		}
125
	}
265
	}
Line 126... Line 266...
126
 
266
 
127
}
267
}