Subversion Repositories eFlore/Applications.coel

Rev

Rev 321 | Rev 436 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 321 Rev 435
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
import java.util.Collection;
3
import java.util.Collection;
4
import java.util.HashMap;
4
import java.util.HashMap;
5
import java.util.Iterator;
5
import java.util.Iterator;
6
import java.util.LinkedList;
6
import java.util.LinkedList;
7
import java.util.MissingResourceException;
7
import java.util.MissingResourceException;
8
 
8
 
-
 
9
 
9
 
10
import org.tela_botanica.client.ComposantId;
10
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.RegistreId;
12
import org.tela_botanica.client.RegistreId;
12
import org.tela_botanica.client.i18n.Constantes;
13
import org.tela_botanica.client.i18n.Constantes;
13
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import org.tela_botanica.client.modeles.Configuration;
15
import org.tela_botanica.client.modeles.Configuration;
15
import org.tela_botanica.client.modeles.Personne;
16
import org.tela_botanica.client.modeles.Personne;
16
import org.tela_botanica.client.modeles.Valeur;
17
import org.tela_botanica.client.modeles.Valeur;
17
import org.tela_botanica.client.modeles.ValeurListe;
18
import org.tela_botanica.client.modeles.ValeurListe;
18
import org.tela_botanica.client.util.UtilTruk;
19
import org.tela_botanica.client.util.UtilTruk;
19
 
20
 
20
import com.extjs.gxt.ui.client.Registry;
21
import com.extjs.gxt.ui.client.Registry;
21
import com.extjs.gxt.ui.client.Style.Scroll;
22
import com.extjs.gxt.ui.client.Style.Scroll;
22
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
23
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
-
 
24
import com.extjs.gxt.ui.client.util.Format;
-
 
25
import com.extjs.gxt.ui.client.util.Params;
23
import com.extjs.gxt.ui.client.widget.ContentPanel;
26
import com.extjs.gxt.ui.client.widget.ContentPanel;
-
 
27
import com.extjs.gxt.ui.client.widget.Html;
24
import com.extjs.gxt.ui.client.widget.LayoutContainer;
28
import com.extjs.gxt.ui.client.widget.LayoutContainer;
25
import com.extjs.gxt.ui.client.widget.TabItem;
29
import com.extjs.gxt.ui.client.widget.TabItem;
26
import com.extjs.gxt.ui.client.widget.TabPanel;
30
import com.extjs.gxt.ui.client.widget.TabPanel;
-
 
31
import com.extjs.gxt.ui.client.widget.Text;
27
import com.extjs.gxt.ui.client.widget.form.FieldSet;
32
import com.extjs.gxt.ui.client.widget.form.FieldSet;
28
import com.extjs.gxt.ui.client.widget.form.LabelField;
33
import com.extjs.gxt.ui.client.widget.form.LabelField;
-
 
34
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
-
 
35
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
29
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
36
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
30
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
37
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
31
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
38
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
-
 
39
import com.extjs.gxt.ui.client.widget.layout.RowData;
-
 
40
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
32
import com.extjs.gxt.ui.client.widget.layout.TableData;
41
import com.extjs.gxt.ui.client.widget.layout.TableData;
33
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
42
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
34
 
43
 
35
import com.google.gwt.core.client.GWT;
44
import com.google.gwt.core.client.GWT;
-
 
45
import com.google.gwt.i18n.client.DateTimeFormat;
36
import com.google.gwt.user.client.ui.Image;
46
import com.google.gwt.user.client.ui.Image;
37
 
47
 
38
public class PersonneDetailPanneauVue extends LayoutContainer implements Rafraichissable {
48
public class PersonneDetailPanneauVue extends LayoutContainer implements Rafraichissable {
-
 
49
 
-
 
50
	
-
 
51
	private LayoutContainer lcDetailHaut;
39
 
52
	
40
	// Le panneau détail se compose de formulaires tabulés
53
	// Le panneau détail se compose de formulaires tabulés
41
	private TabPanel tabPanel;
54
	private TabPanel tabPanel;
42
	
55
	
43
	// Onglet 1 : identite & contact
56
	// Onglet 1 : identite & contact
44
	private TabItem tabIdentite;
57
	private TabItem tabIdentite;
45
	
-
 
46
	private ContentPanel panneauIdentite;
-
 
47
	private ContentPanel panneauImage;
-
 
48
	
58
	
49
	private FieldSet fsIdentite;
59
	private FieldSet fsIdentite;
50
	private FieldSet fsContact;
60
	private FieldSet fsContact;
51
	
61
	
52
	// Onglet 2 : Adresses
62
	// Onglet 2 : Adresses
53
	private TabItem tabAdresse;
63
	private TabItem tabAdresse;
54
	private FieldSet fsAdressePerso;
64
	private FieldSet fsAdressePerso;
55
		// contient : adresse perso / adresse pro
65
		// contient : adresse perso / adresse pro
56
	
66
	
57
	// Onglet 3 : Informations naturalistes
67
	// Onglet 3 : Informations naturalistes
58
	private TabItem tabInfosNat;
68
	private TabItem tabInfosNat;
59
	private FieldSet fsSpec;
69
	private FieldSet fsSpec;
-
 
70
	
-
 
71
	//Onglet 4 : logos
-
 
72
	private TabItem tabLogos;
-
 
73
	
60
	
74
	
-
 
75
	private Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
-
 
76
	
-
 
77
	
-
 
78
	//Templates
-
 
79
	private String enteteTpl = "<div style='display:inline-block; padding-left:15px; width:70%; font-size:11px'>"+
-
 
80
							   "<h1>{nom}</h1>"+
-
 
81
							   "<a href='{mail}'>{mail}</a>" +
-
 
82
							   "</div><br/>";
-
 
83
	
-
 
84
	
-
 
85
	private String tabIdentiteTpl = "<div class='coel-fieldset'>" +
-
 
86
									"		<span><b>Nom Complet:</b></span> {nom_complet}<br />" +
-
 
87
									"		<span><b>Autres noms:</b></span> {nom_autre}<br />" +
-
 
88
									"		<span><b>Abréviation:</b></span> {abreviation}<br />" +
-
 
89
									"		<span><b>Autres Abréviations:</b></b></span> {abreviation_autre}<br /><br />" +
-
 
90
									"		<span><b>Date de naissance</b></span> {naissance_date}<br />" +
-
 
91
									"		<span><b>Lieu de naissance:</b></span> {naissance_lieu}<br /><br />" +
-
 
92
									"		<span><b>Date de décès:</b></span> {deces_date}<br />" +
-
 
93
									"		<span><b>Lieu de décès:</b></span> {deces_lieu}<br /><br />" +
-
 
94
									"</div>" +
-
 
95
									"<div class='coel-fieldset'>" +
-
 
96
									"		<span style='vertical-align:top'><b>Description:</b></span> {description}<br />" +
-
 
97
									"</div>";
61
	private Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
98
	
-
 
99
	
-
 
100
	public PersonneDetailPanneauVue() {
-
 
101
		
-
 
102
		setLayout(new RowLayout());
-
 
103
		
-
 
104
		ContentPanel cp = new ContentPanel();
-
 
105
		cp.setLayout(new FlowLayout());
-
 
106
		
-
 
107
		lcDetailHaut = new LayoutContainer();
-
 
108
		lcDetailHaut.setLayout(new RowLayout());
-
 
109
		//this.add(lcDetailHaut, new RowData(1, 0.2));
-
 
110
		cp.setTopComponent(lcDetailHaut);
-
 
111
		
62
	
112
		add(lcDetailHaut);
63
	public PersonneDetailPanneauVue() {
113
	    
64
		
114
	    
65
		tabPanel = new TabPanel();
115
		tabPanel = new TabPanel();
66
		this.add(tabPanel);
116
		this.add(tabPanel, new RowData(1, 1));
67
		
117
		
68
		//Constructeur de la classe
118
		//Constructeur de la classe
69
		Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
119
		Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
70
		setLayout(new FitLayout());
120
		//setLayout(new FitLayout());
71
		
121
		
72
		tabIdentite = new TabItem("Identité");
-
 
73
		TableLayout tLayout = new TableLayout(2);
122
		tabIdentite = new TabItem("Identité");
74
		tabIdentite.setLayout(tLayout);
123
		tabIdentite.setLayout(new FitLayout());
75
		tabIdentite.setScrollMode(Scroll.AUTO);
-
 
76
		
-
 
77
		panneauIdentite = new ContentPanel();
-
 
78
		panneauIdentite.setWidth("400px");
-
 
79
		panneauIdentite.setHeaderVisible(false);
-
 
80
		panneauIdentite.setBorders(false);
-
 
81
		panneauIdentite.setBodyBorder(false);
-
 
82
		panneauImage = new ContentPanel();
-
 
83
		panneauImage.setLayout(new FlowLayout());
-
 
84
		panneauImage.setBorders(false);
-
 
85
		panneauImage.setWidth(350);
-
 
86
		panneauImage.setBodyBorder(false);
-
 
87
		panneauImage.setHeaderVisible(false);
-
 
88
		
-
 
89
		//Gérer l'alignement vertical en haut
-
 
90
		TableData td = new TableData();
-
 
91
		td.setVerticalAlign(VerticalAlignment.TOP);
-
 
92
		
-
 
93
		tabIdentite.add(panneauIdentite, td);
-
 
94
		tabIdentite.add(panneauImage, td);
-
 
95
		
124
		tabIdentite.setScrollMode(Scroll.AUTO);
96
				
125
				
97
		fsIdentite = new FieldSet();
126
		fsIdentite = new FieldSet();
98
		fsIdentite.setLayout(new FormLayout());
127
		fsIdentite.setLayout(new FormLayout());
99
		
128
		
100
		
129
		
101
		fsContact = new FieldSet();
130
		fsContact = new FieldSet();
102
		fsContact.setLayout(new FormLayout());
131
		fsContact.setLayout(new FormLayout());
103
		
132
		
104
		tabPanel.add(tabIdentite);
133
		tabPanel.add(tabIdentite);
105
		
134
		
106
		//Onglet Adresse:
135
		//Onglet Adresse:
107
		tabAdresse = new TabItem("Adresses");
136
		tabAdresse = new TabItem("Adresses");
108
		fsAdressePerso = new FieldSet();
137
		fsAdressePerso = new FieldSet();
109
		fsAdressePerso.setLayout(new FormLayout());
138
		fsAdressePerso.setLayout(new FormLayout());
110
		
139
		
111
		tabPanel.add(tabAdresse);
140
		tabPanel.add(tabAdresse);
112
		
141
		
113
		//Onglet info naturalistes
142
		//Onglet info naturalistes
114
		tabInfosNat = new TabItem("Informations naturalistes");
143
		tabInfosNat = new TabItem("Informations naturalistes");
115
		fsSpec = new FieldSet();
144
		fsSpec = new FieldSet();
116
		fsSpec.setLayout(new FormLayout());
145
		fsSpec.setLayout(new FormLayout());
117
		tabInfosNat.setScrollMode(Scroll.AUTO);
146
		tabInfosNat.setScrollMode(Scroll.AUTO);
118
		
147
		
119
		tabPanel.add(tabInfosNat);
148
		tabPanel.add(tabInfosNat);
-
 
149
		
-
 
150
		tabLogos = new TabItem("Logos");
-
 
151
		tabLogos.setLayout(new FlowLayout());
-
 
152
		
120
		
153
		tabPanel.add(tabLogos);
121
	}
154
	}
122
 
155
 
123
	
156
	
124
	private HashMap hmLabelFieldRegion = new HashMap();
157
	private HashMap hmLabelFieldRegion = new HashMap();
125
	
158
	
126
	public void afficherDetailPersonne(Personne personne) {
159
	public void afficherDetailPersonne(Personne personne) {
127
		if (personne != null) {
160
		if (personne != null) {
128
			
-
 
129
			
161
			
130
			//MAJ Identité : Configurer les fieldSet
-
 
131
			panneauIdentite.removeAll();
-
 
132
			panneauImage.removeAll();
-
 
133
			
-
 
134
			fsIdentite.setHeading("Identité");
-
 
135
			//fsIdentite.setWidth("350px");
-
 
136
			
-
 
137
			fsContact.setHeading("Contact");
-
 
138
			//fsContact.setWidth("350px");
162
			//MAJ Identité : Configurer les fieldSet
139
			
-
 
140
			panneauIdentite.add(fsIdentite);
-
 
141
			
163
			
142
			
164
			Params enteteParams = new Params();
143
			//La personne peut avoir un ou plusieurs logo
-
 
144
			panneauImage.setHeight("100%");
-
 
145
			panneauImage.setPosition(0, 6);
165
			enteteParams.set("nom", (String) personne.get("fmt_nom_complet"));
146
			panneauImage.setBorders(false);
166
			enteteParams.set("mail", (String) personne.get("courriel_princ"));
147
			
167
			
-
 
168
			LinkedList lstLogos = (LinkedList) personne.getChaineDenormaliseAsMapOrList("truk_logo");			
148
			LinkedList<String> listeLogos = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_logo");
169
			if (lstLogos!=null && lstLogos.size() > 0)	{
149
			if ((listeLogos != null)&&(listeLogos.size() > 0))	{
-
 
150
				panneauImage.setBorders(true);
170
				
151
				for (int i = 0; i < listeLogos.size(); i++)	{
171
				tabLogos.removeAll();
152
					String logoUrl = listeLogos.get(i);
172
				String urlLogoPrinc = (String) lstLogos.get(0);
153
					if ((logoUrl!=null)&&(!logoUrl.trim().equals("")))	{
-
 
154
						//Si c'est le cas, on l'affiche sur la même ligne que fsIdentité
-
 
155
						Image img = new Image();
-
 
156
						img.setUrl(logoUrl);
-
 
157
									
-
 
158
						panneauImage.add(img);			
173
				if (!urlLogoPrinc.trim().equals(""))	{
159
						if (panneauImage.getWidth() < (img.getWidth() + 15))	{
-
 
160
							panneauImage.setWidth(img.getWidth() + 15);
-
 
161
						}
-
 
162
						
174
					enteteTpl = "<div style='position:absolute; right:0; width:30%; text-align:right'><img src='{image}' alt='logo' height='45px'/></div>" + enteteTpl;
-
 
175
					enteteParams.set("image", urlLogoPrinc);
-
 
176
				}
-
 
177
				
-
 
178
				Iterator<String> itLogo = lstLogos.iterator();
-
 
179
				while (itLogo.hasNext()){
-
 
180
					String urlLogoCourant = itLogo.next();
-
 
181
					Image imgCourante = new Image(urlLogoCourant);
-
 
182
					tabLogos.add(imgCourante);		
-
 
183
				}
-
 
184
				
163
					}
185
				tabLogos.enable();			
-
 
186
			} else {
-
 
187
				tabLogos.disable();
164
				}
188
			}	
165
				
189
			
-
 
190
			lcDetailHaut.el().setInnerHtml(Format.substitute(enteteTpl, enteteParams));
-
 
191
			
-
 
192
			Params tabIdentiteParams = new Params();
-
 
193
			tabIdentiteParams.set("nom_complet", personne.getString("fmt_nom_complet"));
-
 
194
			tabIdentiteParams.set("abreviation", personne.getString("abreviation"));
-
 
195
			tabIdentiteParams.set("naissance_date", personne.getString("naissance_date"));
-
 
196
			tabIdentiteParams.set("naissance_lieu", personne.getString("naissance_lieu"));
166
			}
-
 
167
			
-
 
168
			panneauIdentite.add(fsContact);
197
			tabIdentiteParams.set("deces_date", personne.getString("deces_date"));
169
			
198
			tabIdentiteParams.set("deces_lieu", personne.getString("deces_lieu"));
170
			fsIdentite.removeAll();
199
			tabIdentiteParams.set("description", personne.getString("description"));
171
			fsContact.removeAll();
200
			
172
			fsAdressePerso.removeAll();
201
			fsAdressePerso.removeAll();
173
			fsSpec.removeAll();
202
			fsSpec.removeAll();
174
			tabInfosNat.removeAll();
203
			tabInfosNat.removeAll();
175
			//Ajout des champs Identité
-
 
176
			
-
 
177
			
-
 
178
			
-
 
179
			// TODO: projet
-
 
180
			
-
 
181
			// nom complet
-
 
182
			Object nomComplet = personne.obtenirValeurChamp("fmt_nom_complet");
-
 
183
			ajouterLabelField(fsIdentite,"Nom Complet", nomComplet);
-
 
184
			
204
			
185
			// Nom autre : champ truk; non-typé
205
			// Nom autre : champ truk; non-typé
186
			LinkedList<String> nomsAutre = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_nom_autre");
206
			LinkedList<String> nomsAutre = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_nom_autre");
-
 
207
			String listeNoms = "";
187
			if ((nomsAutre != null)&&(nomsAutre.size() > 0))	{
208
			if ((nomsAutre != null)&&(nomsAutre.size() > 0))	{
188
				
-
 
189
				LabelField noms = new LabelField();
-
 
190
				noms.setFieldLabel("Autres noms:");
-
 
191
				String listeNoms = UtilTruk.traiterTrukListe(nomsAutre, ", ");				
209
				listeNoms = UtilTruk.traiterTrukListe(nomsAutre, ", ");				
192
				noms.setValue(listeNoms);
-
 
193
				fsIdentite.add(noms);				
-
 
194
			}
210
			}
195
			
-
 
196
			// abreviation
-
 
197
			Object abreviation = personne.obtenirValeurChamp("abreviation");
-
 
198
			ajouterLabelField(fsIdentite, "Abreviation", abreviation);
211
			tabIdentiteParams.set("nom_autre", listeNoms);
199
			
212
			
200
			// Abréviations, autre : non-typé
213
			// Abréviations, autre : non-typé
201
			LinkedList<String> abrevAutres = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_abreviation_autre");
214
			LinkedList<String> abrevAutres = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_abreviation_autre");
-
 
215
			String listeAbrev = "";
202
			if ((abrevAutres != null)&&(abrevAutres.size() > 0))	{
216
			if ((abrevAutres != null)&&(abrevAutres.size() > 0))	{
203
				
-
 
204
				LabelField abreviations = new LabelField();
-
 
205
				abreviations.setFieldLabel("Autres abreviations:");
-
 
206
				String listeAbrev = UtilTruk.traiterTrukListe(abrevAutres, ", ");
217
				listeAbrev = UtilTruk.traiterTrukListe(abrevAutres, ", ");
207
				abreviations.setValue(listeAbrev);
-
 
208
				fsIdentite.add(abreviations);				
-
 
209
			}
-
 
210
			fsIdentite.addText("<hr>");
-
 
211
			
-
 
212
			// date naissance 
-
 
213
			// TODO : Mettre la date en format FR 10/12/09
-
 
214
			Object dateNaissance = personne.obtenirValeurChamp("naissance_date");
-
 
215
			ajouterLabelField(fsIdentite, "Né le", dateNaissance);
-
 
216
						
-
 
217
			// lieu naissance
-
 
218
			Object lieuNaissance = personne.obtenirValeurChamp("naissance_lieu");
-
 
219
			ajouterLabelField(fsIdentite, "A", lieuNaissance);
-
 
220
			
-
 
221
			// date deces
-
 
222
			Object dateDeces = personne.obtenirValeurChamp("deces_date");
-
 
223
			ajouterLabelField(fsIdentite, "Date décès", dateDeces);
-
 
224
			
-
 
225
			// lieu deces
-
 
226
			Object lieuDeces = personne.obtenirValeurChamp("deces_lieu");
-
 
227
			ajouterLabelField(fsIdentite, "Lieu de décès", lieuDeces);
-
 
228
			
-
 
229
			fsIdentite.addText("<hr>");
-
 
230
			
-
 
231
			//Description
-
 
232
			String description = (String) personne.obtenirValeurChamp("description");
-
 
233
			if ((description!=null)&&(!description.trim().equals("")))	{
-
 
234
				LabelField txtDescription = new LabelField();
-
 
235
				txtDescription.setFieldLabel("Description:");
-
 
236
				txtDescription.setValue(description);
-
 
237
				
-
 
238
				//rendreNonEditable(txtDescription);
-
 
239
				
-
 
240
				fsIdentite.add(txtDescription);
-
 
241
			}
218
			}
-
 
219
			tabIdentiteParams.set("abreviation_autre", listeAbrev);
-
 
220
			
242
			
-
 
243
			
-
 
244
			// CONTACT
221
			tabIdentite.el().setInnerHtml(Format.substitute(tabIdentiteTpl, tabIdentiteParams));
245
			// Téléphones
222
			
-
 
223
			// CONTACT > Plusieurs téléphones possible, typés
246
			// > Plusieurs téléphones possible, typés
224
			Constantes constantesI18n = (Constantes) GWT.create(Constantes.class);
247
			Constantes constantesI18n = (Constantes) GWT.create(Constantes.class);
225
			
248
			
226
			
249
			HashMap<String, String> mapTelephones = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_telephone");
227
			HashMap<String, String> mapTelephones = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_telephone");
250
			if ((mapTelephones != null)&&(mapTelephones.size() > 0))	{
228
			if ((mapTelephones != null)&&(mapTelephones.size() > 0))	{
251
				
229
				
252
				Collection<String> telephoneKeys = mapTelephones.keySet();
230
				Collection<String> telephoneKeys = mapTelephones.keySet();
253
				Iterator<String> itTelephones = telephoneKeys.iterator();
231
				Iterator<String> itTelephones = telephoneKeys.iterator();
254
				
232
				
255
				while (itTelephones.hasNext())	{
233
				while (itTelephones.hasNext())	{
256
					String key = itTelephones.next();
234
					String key = itTelephones.next();
257
					LabelField telephoneLabel = new LabelField();
235
					LabelField telephoneLabel = new LabelField();
258
					String label = "";
236
					String label = "";
259
					try {
237
					try {
260
						label = constantesI18n.getString(key);
238
						label = constantesI18n.getString(key);
261
					}
239
					}
262
					catch (MissingResourceException e)	{
240
					catch (MissingResourceException e)	{
263
						label = key;
241
						label = key;
264
					}
242
					}
265
					
243
					
266
					telephoneLabel.setFieldLabel( label + ":");
244
					telephoneLabel.setFieldLabel( label + ":");
267
					
245
					
268
					telephoneLabel.setValue(mapTelephones.get(key));
246
					telephoneLabel.setValue(mapTelephones.get(key));
269
					
247
					
270
					fsContact.add(telephoneLabel);
248
					fsContact.add(telephoneLabel);
271
				}
249
				}
272
			}
250
			}
273
			
251
			
274
			// Fax
252
			// Fax
275
			// > Plusieurs fax possible, typés
253
			// > Plusieurs fax possible, typés
276
			
254
			
277
			HashMap<String, String> mapFax = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_fax");
255
			HashMap<String, String> mapFax = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_fax");
278
			if ((mapFax != null)&&(mapFax.size() > 0))	{
256
			if ((mapFax != null)&&(mapFax.size() > 0))	{
279
				
257
				
280
				Collection<String> faxKeys = mapFax.keySet();
258
				Collection<String> faxKeys = mapFax.keySet();
281
				Iterator<String> itFax = faxKeys.iterator();
259
				Iterator<String> itFax = faxKeys.iterator();
282
				
260
				
283
				while (itFax.hasNext())	{
261
				while (itFax.hasNext())	{
284
					String key = itFax.next();
262
					String key = itFax.next();
285
					LabelField faxLabel = new LabelField();
263
					LabelField faxLabel = new LabelField();
286
					String label = "";
264
					String label = "";
287
					try {
265
					try {
288
						label = constantesI18n.getString(key);
266
						label = constantesI18n.getString(key);
289
					}
267
					}
290
					catch (MissingResourceException e)	{
268
					catch (MissingResourceException e)	{
291
						label = key;
269
						label = key;
292
					}
270
					}
293
					
271
					
294
					faxLabel.setFieldLabel( label + ":");
272
					faxLabel.setFieldLabel( label + ":");
295
					
273
					
296
					faxLabel.setValue(mapTelephones.get(key));
274
					faxLabel.setValue(mapTelephones.get(key));
297
					
275
					
298
					fsContact.add(faxLabel);
276
					fsContact.add(faxLabel);
299
				}
277
				}
300
			}
278
			}
301
			
279
			
302
			// Courriel
280
			// Courriel
303
			// Courriel est un champ truk de la forme "Adresse@adr.com;; adr2@adr.fr ..."
281
			// Courriel est un champ truk de la forme "Adresse@adr.com;; adr2@adr.fr ..."
304
			
282
			
305
			LinkedList<String> listeCourriel = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_courriel");
283
			LinkedList<String> listeCourriel = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_courriel");
306
			if ((listeCourriel!=null)&&(listeCourriel.size() > 0))	{
284
			if ((listeCourriel!=null)&&(listeCourriel.size() > 0))	{
307
				String strLabelCourriel = "Courriel";
285
				String strLabelCourriel = "Courriel";
308
				if (listeCourriel.size() > 1)	{
286
				if (listeCourriel.size() > 1)	{
309
					strLabelCourriel += "s";	
287
					strLabelCourriel += "s";	
310
				}
288
				}
311
				
289
				
312
				LabelField labelCourriel = new LabelField();
290
				LabelField labelCourriel = new LabelField();
313
				labelCourriel.setFieldLabel(strLabelCourriel);
291
				labelCourriel.setFieldLabel(strLabelCourriel);
314
				
292
				
315
				String valeurCourriel = "";
293
				String valeurCourriel = "";
316
				Iterator<String> itCourriel = listeCourriel.iterator();
294
				Iterator<String> itCourriel = listeCourriel.iterator();
317
				while (itCourriel.hasNext())	{
295
				while (itCourriel.hasNext())	{
318
					String valeurCourante = itCourriel.next();
296
					String valeurCourante = itCourriel.next();
319
					valeurCourriel += "<a href=\"mailto:" + valeurCourante + "\">" + valeurCourante + "</a><br />";
297
					valeurCourriel += "<a href=\"mailto:" + valeurCourante + "\">" + valeurCourante + "</a><br />";
320
										
298
										
321
				}
299
				}
322
				
300
				
323
				labelCourriel.setValue(valeurCourriel);
301
				labelCourriel.setValue(valeurCourriel);
324
				fsContact.add(labelCourriel);
302
				fsContact.add(labelCourriel);
325
			}
303
			}
326
			
304
			
327
			
305
			
328
			// Url Site Webs
306
			// Url Site Webs
329
			LinkedList listeUrl = (LinkedList) personne.getChaineDenormaliseAsMapOrList("truk_url");
307
			LinkedList listeUrl = (LinkedList) personne.getChaineDenormaliseAsMapOrList("truk_url");
330
			if (listeUrl!=null && listeUrl.size() > 0)	{
308
			if (listeUrl!=null && listeUrl.size() > 0)	{
331
				String strUrl = "";
309
				String strUrl = "";
332
				Iterator<String> urlIt = listeUrl.iterator();
310
				Iterator<String> urlIt = listeUrl.iterator();
333
				while (urlIt.hasNext())	{
311
				while (urlIt.hasNext())	{
334
					String urlCourante = urlIt.next();
312
					String urlCourante = urlIt.next();
335
					strUrl += "<a href=\""+urlCourante+"\">" + urlCourante + "</a> <br/>";
313
					strUrl += "<a href=\""+urlCourante+"\">" + urlCourante + "</a> <br/>";
336
					
314
					
337
					
315
					
338
				}
316
				}
339
				
317
				
340
				LabelField urlLabelField = new LabelField();
318
				LabelField urlLabelField = new LabelField();
341
				urlLabelField.setFieldLabel("Url:");
319
				urlLabelField.setFieldLabel("Url:");
342
				urlLabelField.setValue(strUrl);
320
				urlLabelField.setValue(strUrl);
343
				fsContact.add(urlLabelField);
321
				fsContact.add(urlLabelField);
344
			}
322
			}
345
			
-
 
-
 
323
			
346
			
324
			tabIdentite.setStyleAttribute("padding", "15px");
347
			panneauIdentite.add(fsContact);
325
			//tabIdentite.add(fsContact);
348
			
326
			
349
			
327
			
350
			fsAdressePerso.setHeading("Adresse personnelle");
328
			fsAdressePerso.setHeading("Adresse personnelle");
351
			
329
			
352
			/*
330
			/*
353
			 * Adresses :
331
			 * Adresses :
354
			 * */
332
			 * */
355
			String adresse01 = (String) personne.obtenirValeurChamp("adresse_01");
333
			String adresse01 = (String) personne.obtenirValeurChamp("adresse_01");
356
			ajouterLabelField(fsAdressePerso, "Adresse", adresse01);
334
			ajouterLabelField(fsAdressePerso, "Adresse", adresse01);
357
			
335
			
358
			String adresse02 = (String) personne.obtenirValeurChamp("adresse_02");
336
			String adresse02 = (String) personne.obtenirValeurChamp("adresse_02");
359
			ajouterLabelField(fsAdressePerso, "", adresse02);
337
			ajouterLabelField(fsAdressePerso, "", adresse02);
360
			
338
			
361
			String boitePostale = (String) personne.obtenirValeurChamp("bp");
339
			String boitePostale = (String) personne.obtenirValeurChamp("bp");
362
			ajouterLabelField(fsAdressePerso, "Boite Postale", boitePostale);
340
			ajouterLabelField(fsAdressePerso, "Boite Postale", boitePostale);
363
			
341
			
364
			String codePostal = (String) personne.obtenirValeurChamp("code_postal");
342
			String codePostal = (String) personne.obtenirValeurChamp("code_postal");
365
			ajouterLabelField(fsAdressePerso, "Code postal", codePostal);
343
			ajouterLabelField(fsAdressePerso, "Code postal", codePostal);
366
			
344
			
367
			String ville = (String) personne.obtenirValeurChamp("ville");
345
			String ville = (String) personne.obtenirValeurChamp("ville");
368
			ajouterLabelField(fsAdressePerso, "Ville", ville);
346
			ajouterLabelField(fsAdressePerso, "Ville", ville);
369
			
347
			
370
			String region = (String) personne.obtenirValeurChamp("region");
348
			String region = (String) personne.obtenirValeurChamp("region");
371
			ajouterLabelField(fsAdressePerso, "Région", region);
349
			ajouterLabelField(fsAdressePerso, "Région", region);
372
			
350
			
373
			String pays = (String) personne.obtenirValeurChamp("pays");
351
			String pays = (String) personne.obtenirValeurChamp("pays");
374
			ajouterLabelField(fsAdressePerso, "Pays", pays);
352
			ajouterLabelField(fsAdressePerso, "Pays", pays);
375
			
353
			
376
			fsAdressePerso.addText("<br >");	
354
			fsAdressePerso.addText("<br >");	
377
			fsAdressePerso.setWidth("350px");
355
			fsAdressePerso.setWidth("350px");
378
			
356
			
379
			tabAdresse.add(fsAdressePerso);
357
			tabAdresse.add(fsAdressePerso);
380
			
358
			
381
 
359
 
382
			// Infos naturalistes 
360
			// Infos naturalistes 
383
			
361
			
384
			// Biographie
362
			// Biographie
385
			// Spécialité (typé)
363
			// Spécialité (typé)
386
			
364
			
387
			fsSpec.setHeading("Spécialités");
365
			fsSpec.setHeading("Spécialités");
388
			tabInfosNat.add(fsSpec);
366
			tabInfosNat.add(fsSpec);
389
			
367
			
390
			HashMap hmSpecialite = (HashMap) personne.getChaineDenormaliseAsMapOrList("ce_truk_specialite");
368
			HashMap hmSpecialite = (HashMap) personne.getChaineDenormaliseAsMapOrList("ce_truk_specialite");
391
			if ((hmSpecialite != null)&&(hmSpecialite.size() > 0))	{
369
			if ((hmSpecialite != null)&&(hmSpecialite.size() > 0))	{
392
				
370
				
393
				Collection<String> specialiteKeys = hmSpecialite.keySet();
371
				Collection<String> specialiteKeys = hmSpecialite.keySet();
394
				Iterator<String> itSpec = specialiteKeys.iterator();
372
				Iterator<String> itSpec = specialiteKeys.iterator();
395
				
373
				
396
				while (itSpec.hasNext())	{
374
				while (itSpec.hasNext())	{
397
					String key = itSpec.next();
375
					String key = itSpec.next();
398
					LabelField specLabel = new LabelField();
376
					LabelField specLabel = new LabelField();
399
					String label = "";
377
					String label = "";
400
					try {
378
					try {
401
						label = constantesI18n.getString(key);
379
						label = constantesI18n.getString(key);
402
					}
380
					}
403
					catch (MissingResourceException e)	{
381
					catch (MissingResourceException e)	{
404
						label = key;
382
						label = key;
405
					}
383
					}
406
					
384
					
407
					specLabel.setFieldLabel( label + ":");
385
					specLabel.setFieldLabel( label + ":");
408
					
386
					
409
					specLabel.setValue(hmSpecialite.get(key));
387
					specLabel.setValue(hmSpecialite.get(key));
410
					
388
					
411
					fsSpec.add(specLabel);
389
					fsSpec.add(specLabel);
412
				}
390
				}
413
			}
391
			}
414
			
392
			
415
			// Récolte
393
			// Récolte
416
			LinkedList<String> lstRecolte = (LinkedList) personne.getChaineDenormaliseAsMapOrList("truk_recolte");
394
			LinkedList<String> lstRecolte = (LinkedList) personne.getChaineDenormaliseAsMapOrList("truk_recolte");
417
			if ((lstRecolte!=null)&&(lstRecolte.size()>0))	{
395
			if ((lstRecolte!=null)&&(lstRecolte.size()>0))	{
418
				FieldSet fsRecolte = new FieldSet();
396
				FieldSet fsRecolte = new FieldSet();
419
				fsRecolte.setHeading("Récoltes");
397
				fsRecolte.setHeading("Récoltes");
420
				fsRecolte.setLayout(new FormLayout());
398
				fsRecolte.setLayout(new FormLayout());
421
				
399
				
422
				Iterator<String> itRecolte = lstRecolte.iterator();
400
				Iterator<String> itRecolte = lstRecolte.iterator();
423
				while (itRecolte.hasNext())	{
401
				while (itRecolte.hasNext())	{
424
					
402
					
425
					String recolteCourante = itRecolte.next();
403
					String recolteCourante = itRecolte.next();
426
					LabelField lfRecolte = new LabelField();
404
					LabelField lfRecolte = new LabelField();
427
					String[] splitRecolte = recolteCourante.split("\\|");
405
					String[] splitRecolte = recolteCourante.split("\\|");
428
					
406
					
429
					String labelRecolte = "";
407
					String labelRecolte = "";
430
					if (splitRecolte.length > 1)	{
408
					if (splitRecolte.length > 1)	{
431
						lfRecolte.setValue(splitRecolte[1]);
409
						lfRecolte.setValue(splitRecolte[1]);
432
					}
410
					}
433
					
411
					
434
					lfRecolte.setFieldLabel(splitRecolte[0]);
412
					lfRecolte.setFieldLabel(splitRecolte[0]);
435
					fsRecolte.add(lfRecolte);
413
					fsRecolte.add(lfRecolte);
436
					
414
					
437
					LinkedList<LabelField> lstComposantsRegion = (LinkedList<LabelField>) hmLabelFieldRegion.get(splitRecolte[0]);
415
					LinkedList<LabelField> lstComposantsRegion = (LinkedList<LabelField>) hmLabelFieldRegion.get(splitRecolte[0]);
438
					
416
					
439
					if (lstComposantsRegion == null)	{
417
					if (lstComposantsRegion == null)	{
440
						lstComposantsRegion = new LinkedList<LabelField>();
418
						lstComposantsRegion = new LinkedList<LabelField>();
441
					}
419
					}
442
					
420
					
443
					lstComposantsRegion.add(lfRecolte);
421
					lstComposantsRegion.add(lfRecolte);
444
					hmLabelFieldRegion.remove(splitRecolte[0]);
422
					hmLabelFieldRegion.remove(splitRecolte[0]);
445
					hmLabelFieldRegion.put(splitRecolte[0], lstComposantsRegion);
423
					hmLabelFieldRegion.put(splitRecolte[0], lstComposantsRegion);
446
									
424
									
447
				}
425
				}
448
				
426
				
449
				tabInfosNat.add(fsRecolte);
427
				tabInfosNat.add(fsRecolte);
450
			}
428
			}
451
			
429
			
452
			changerLabelRegions();
430
			changerLabelRegions();
453
			// tabInfosNat
431
			// tabInfosNat
454
			layout();
432
			layout();
455
		} 
433
		} 
456
	}
434
	}
457
	
435
	
458
	
436
	
459
	private void changerLabelRegions()	{
437
	private void changerLabelRegions()	{
460
		
438
		
461
		Collection<String> colClesComposants = hmLabelFieldRegion.keySet();
439
		Collection<String> colClesComposants = hmLabelFieldRegion.keySet();
462
		Iterator<String> itComposants = colClesComposants.iterator();
440
		Iterator<String> itComposants = colClesComposants.iterator();
463
		
441
		
464
		while (itComposants.hasNext())	{
442
		while (itComposants.hasNext())	{
465
			String region = itComposants.next();
443
			String region = itComposants.next();
466
			mediateur.obtenirValeurEtRafraichir(this, "region", region);
444
			mediateur.obtenirValeurEtRafraichir(this, "region", region);
467
		}
445
		}
468
	}
446
	}
469
 
447
 
470
	private void ajouterLabelField(FieldSet fs, String tfLabel, Object tfValue)	{
448
	private void ajouterLabelField(FieldSet fs, String tfLabel, Object tfValue)	{
471
	
449
	
472
		if ((tfValue!=null)&&(!tfValue.toString().trim().equals("")))	{
450
		if ((tfValue!=null)&&(!tfValue.toString().trim().equals("")))	{
473
			
451
			
474
			
452
			
475
			LabelField tf = new LabelField();
453
			LabelField tf = new LabelField();
476
		
454
		
477
			tf.setFieldLabel(tfLabel + ":");
455
			tf.setFieldLabel(tfLabel + ":");
478
			if ((tfLabel==null)||("".equals(tfLabel)))	{
456
			if ((tfLabel==null)||("".equals(tfLabel)))	{
479
				tf.setHideLabel(true);
457
				tf.setHideLabel(true);
480
				tf.setStyleAttribute("margin", "0 0 0 105px");
458
				tf.setStyleAttribute("margin", "0 0 0 105px");
481
			}
459
			}
482
			tf.setValue(tfValue);
460
			tf.setValue(tfValue);
483
		
461
		
484
			//Ajout au fieldSet
462
			//Ajout au fieldSet
485
			fs.add(tf);
463
			fs.add(tf);
486
		}
464
		}
487
	}
465
	}
488
	
466
	
489
	
467
	
490
		
468
		
491
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
469
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
492
	
470
	
493
	public void rafraichir(Object nouvellesDonnees) {
471
	public void rafraichir(Object nouvellesDonnees) {
494
		
472
		
495
		// Si on a reçu une personne on en affiche les détails
473
		// Si on a reçu une personne on en affiche les détails
496
		if (nouvellesDonnees instanceof Personne) {
474
		if (nouvellesDonnees instanceof Personne) {
497
			afficherDetailPersonne((Personne) nouvellesDonnees);
475
			afficherDetailPersonne((Personne) nouvellesDonnees);
498
		} else if (nouvellesDonnees instanceof ValeurListe)	{
476
		} else if (nouvellesDonnees instanceof ValeurListe)	{
499
			
477
			
500
			ValeurListe listeValeur = (ValeurListe) nouvellesDonnees;
478
			ValeurListe listeValeur = (ValeurListe) nouvellesDonnees;
501
			if (listeValeur.getId().equals(config.getListeId("region")))	{
479
			if (listeValeur.getId().equals(config.getListeId("region")))	{
502
				
480
				
503
				Collection colCleListeValeur = listeValeur.keySet();
481
				Collection colCleListeValeur = listeValeur.keySet();
504
				
482
				
505
				Iterator<String> itLv = colCleListeValeur.iterator();
483
				Iterator<String> itLv = colCleListeValeur.iterator();
506
				
484
				
507
				while (itLv.hasNext())	{
485
				while (itLv.hasNext())	{
508
					String idRegion = itLv.next();
486
					String idRegion = itLv.next();
509
					Valeur region = listeValeur.get(idRegion);
487
					Valeur region = listeValeur.get(idRegion);
510
					
488
					
511
					
489
					
512
					
490
					
513
					if (region != null)	{
491
					if (region != null)	{
514
						
492
						
515
						String strRegionId = region.getAbreviation();
493
						String strRegionId = region.getAbreviation();
516
						
494
						
517
						LinkedList<LabelField> listComposantsRegion = (LinkedList) hmLabelFieldRegion.get(strRegionId);
495
						LinkedList<LabelField> listComposantsRegion = (LinkedList) hmLabelFieldRegion.get(strRegionId);
518
						for (int i=0; i < listComposantsRegion.size(); i++)	{
496
						for (int i=0; i < listComposantsRegion.size(); i++)	{
519
							LabelField lfRegion = listComposantsRegion.get(i);
497
							LabelField lfRegion = listComposantsRegion.get(i);
520
							lfRegion.setFieldLabel(region.getNom());	
498
							lfRegion.setFieldLabel(region.getNom());	
521
						}
499
						}
522
					
500
					
523
					}
501
					}
524
				}
502
				}
525
			}
503
			}
526
		}
504
		}
527
	}
505
	}
528
 
506
 
529
}
507
}