Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 280 Rev 283
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line -... Line 2...
-
 
2
 
2
 
3
import java.util.ArrayList;
-
 
4
import java.util.HashMap;
-
 
5
import java.util.Iterator;
Line 3... Line 6...
3
import java.util.HashMap;
6
import java.util.List;
4
 
7
 
5
import org.tela_botanica.client.ComposantClass;
8
import org.tela_botanica.client.ComposantClass;
6
import org.tela_botanica.client.Mediateur;
9
import org.tela_botanica.client.Mediateur;
-
 
10
import org.tela_botanica.client.RegistreId;
7
import org.tela_botanica.client.RegistreId;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
9
import org.tela_botanica.client.modeles.InterneValeur;
12
import org.tela_botanica.client.modeles.Configuration;
-
 
13
import org.tela_botanica.client.modeles.InterneValeur;
Line 10... Line 14...
10
import org.tela_botanica.client.modeles.Personne;
14
import org.tela_botanica.client.modeles.Valeur;
11
import org.tela_botanica.client.modeles.Valeur;
15
import org.tela_botanica.client.modeles.ValeurListe;
-
 
16
 
-
 
17
 
12
 
18
import com.extjs.gxt.ui.client.Registry;
13
 
19
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
14
import com.extjs.gxt.ui.client.Registry;
20
import com.extjs.gxt.ui.client.Style.Scroll;
15
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
21
import com.extjs.gxt.ui.client.event.BaseEvent;
16
import com.extjs.gxt.ui.client.event.ComponentEvent;
22
import com.extjs.gxt.ui.client.event.ComponentEvent;
17
import com.extjs.gxt.ui.client.event.KeyListener;
23
import com.extjs.gxt.ui.client.event.KeyListener;
18
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
24
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
19
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
-
 
-
 
25
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
20
import com.extjs.gxt.ui.client.event.SelectionListener;
26
import com.extjs.gxt.ui.client.event.SelectionListener;
21
import com.extjs.gxt.ui.client.store.ListStore;
-
 
-
 
27
import com.extjs.gxt.ui.client.store.ListStore;
22
import com.extjs.gxt.ui.client.store.Store;
28
import com.extjs.gxt.ui.client.store.StoreListener;
23
import com.extjs.gxt.ui.client.widget.Container;
29
 
24
import com.extjs.gxt.ui.client.widget.ContentPanel;
30
import com.extjs.gxt.ui.client.widget.ContentPanel;
-
 
31
 
25
import com.extjs.gxt.ui.client.widget.DatePicker;
32
import com.extjs.gxt.ui.client.widget.LayoutContainer;
26
import com.extjs.gxt.ui.client.widget.LayoutContainer;
33
import com.extjs.gxt.ui.client.widget.TabItem;
27
import com.extjs.gxt.ui.client.widget.TabItem;
34
import com.extjs.gxt.ui.client.widget.TabPanel;
28
import com.extjs.gxt.ui.client.widget.TabPanel;
35
 
29
import com.extjs.gxt.ui.client.widget.form.ComboBox;
36
import com.extjs.gxt.ui.client.widget.form.ComboBox;
30
import com.extjs.gxt.ui.client.widget.form.DateField;
-
 
31
import com.extjs.gxt.ui.client.widget.form.FieldSet;
37
import com.extjs.gxt.ui.client.widget.form.DateField;
32
import com.extjs.gxt.ui.client.widget.form.LabelField;
38
import com.extjs.gxt.ui.client.widget.form.FieldSet;
33
import com.extjs.gxt.ui.client.widget.form.TextField;
39
import com.extjs.gxt.ui.client.widget.form.LabelField;
34
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
40
import com.extjs.gxt.ui.client.widget.form.TextField;
35
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
41
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
36
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
42
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
37
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
43
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
38
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
44
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
39
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
-
 
40
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
45
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
41
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
46
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
Line 42... Line 47...
42
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
47
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
Line 53... Line 58...
53
	 * 		VARIABLES
58
	 * 		VARIABLES
54
	 * -------------------------------------------------------------------------------------
59
	 * -------------------------------------------------------------------------------------
55
	 */
60
	 */
Line 56... Line 61...
56
	
61
	
57
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
-
 
-
 
62
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
-
 
63
	private Mediateur mediateur = Registry.get(RegistreId.MEDIATEUR);
Line 58... Line 64...
58
	
64
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
59
	
65
	
60
	/*--------------------------------------------------------------------------------------
66
	/*--------------------------------------------------------------------------------------
61
	 * 		CONSTRUCTEUR 
67
	 * 		CONSTRUCTEUR 
Line 68... Line 74...
68
	 * formulaire et annuler la saisie). 
74
	 * formulaire et annuler la saisie). 
69
	 * 
75
	 * 
70
	 * */
76
	 * */
71
	public FormPersonneVue() {
77
	public FormPersonneVue() {
Line 72... Line 78...
72
		
78
		
Line 73... Line 79...
73
		initialiserPanneau(this);
79
		initialiserPanneau();
Line 74... Line 80...
74
		
80
		
75
		ToolBar barreOutils = new ToolBar();
81
		ToolBar barreOutils = new ToolBar();
Line 94... Line 100...
94
	/**
100
	/**
95
	 * Inialise le panneau donné
101
	 * Inialise le panneau donné
96
	 * 
102
	 * 
97
	 * @param contentPanel le panneau à initialiser
103
	 * @param contentPanel le panneau à initialiser
98
	 * */
104
	 * */
99
	public void initialiserPanneau(ContentPanel contentPanel)	{
105
	public void initialiserPanneau()	{
Line 100... Line 106...
100
		
106
		
101
		contentPanel.setLayout(new FitLayout());
107
		setLayout(new FitLayout());
102
		contentPanel.setIconStyle("icone-form-ajouter");  
108
		setIconStyle("icone-form-ajouter");  
103
		contentPanel.setCollapsible(false);  
109
		setCollapsible(false);  
104
		contentPanel.setHeading("Ajouter une personne");
110
		setHeading("Ajouter une personne");
105
		contentPanel.setButtonAlign(HorizontalAlignment.CENTER);  
111
		setButtonAlign(HorizontalAlignment.CENTER);  
106
		contentPanel.setLayout(new FormLayout());
112
		setLayout(new FormLayout());
Line 107... Line 113...
107
	}
113
	}
108
	
114
	
109
	/**
115
	/**
Line 115... Line 121...
115
		TabPanel formulaireOnglets = new TabPanel();
121
		TabPanel formulaireOnglets = new TabPanel();
Line 116... Line 122...
116
		
122
		
117
		//Tab 1 : identite
123
		//Tab 1 : identite
118
		tiIdentite = new TabItem("Identité");
124
		tiIdentite = new TabItem("Identité");
-
 
125
		tiIdentite.setLayout(new FormLayout());
119
		tiIdentite.setLayout(new FormLayout());
126
		tiIdentite.setScrollMode(Scroll.AUTO);
Line -... Line 127...
-
 
127
		formulaireOnglets.add(tiIdentite);
120
		formulaireOnglets.add(tiIdentite);
128
		
121
		
129
		
122
		
130
		
-
 
131
		//Tab 2 : Adresse
123
		//Tab 2 : Adresse
132
		tiAdresses = new TabItem("Adresse");
Line 124... Line 133...
124
		tiAdresses = new TabItem("Adresse");
133
		tiAdresses.setLayout(new FlowLayout());
125
		tiAdresses.setLayout(new FlowLayout());
134
		tiAdresses.setScrollMode(Scroll.AUTO);
126
		formulaireOnglets.add(tiAdresses);
135
		formulaireOnglets.add(tiAdresses);
-
 
136
		
127
		
137
		//Tab 3 : Infos Naturalistes
Line 128... Line 138...
128
		//Tab 3 : Infos Naturalistes
138
		tiInfosNat = new TabItem("Informations Naturalistes");
129
		tiInfosNat = new TabItem("Informations Naturalistes");
139
		tiInfosNat.setLayout(new FormLayout());
Line 141... Line 151...
141
	//hmIdentite référence par une chaine de caractère tous les composants de l'onglet Identite
151
	//hmIdentite référence par une chaine de caractère tous les composants de l'onglet Identite
142
	private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
152
	private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
Line 143... Line 153...
143
	
153
	
Line 144... Line 154...
144
	public void creerComposantsIdentite()	{
154
	public void creerComposantsIdentite()	{
145
		
155
		
Line 146... Line 156...
146
			// Gestion de l'affichage en colonnes
156
		// Gestion de l'affichage en colonnes
147
			// On crée 3 Layout container : un principal, un pour la colonne de gauche, un pour la colonne de droite
157
			// On crée 3 Layout container : un principal, un pour la colonne de gauche, un pour la colonne de droite
148
		
158
		
Line 185... Line 195...
185
			
195
			
186
			//Préfixe
196
			//Préfixe
187
			ComboBox<Valeur> cbPrefix = new ComboBox<Valeur>();
197
			ComboBox<Valeur> cbPrefix = new ComboBox<Valeur>();
188
			ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
198
			ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
-
 
199
			cbPrefix.setStore(storePrefixe);
-
 
200
			cbPrefix.setDisplayField("nom");
189
			cbPrefix.setStore(storePrefixe);
201
			cbPrefix.setEmptyText("Choisissez le préfixe:");
190
			cbPrefix.setFieldLabel("Prefix");
202
			cbPrefix.setFieldLabel("Prefix");
Line 191... Line 203...
191
			fsNoms.add(cbPrefix);			
203
			fsNoms.add(cbPrefix);			
Line -... Line 204...
-
 
204
			
-
 
205
			hmIdentite.put("cbPrefix", cbPrefix);
-
 
206
			
192
			
207
			// Remplir la liste des préfixe
193
			hmIdentite.put("cbPrefix", cbPrefix);
208
			mediateur.obtenirListeValeurEtRafraichir(this, "prefixe");
194
			
209
			
195
			//Prénom
210
			//Prénom
Line 204... Line 219...
204
			tfNom.setFieldLabel("Nom");
219
			tfNom.setFieldLabel("Nom");
205
			fsNoms.add(tfNom);
220
			fsNoms.add(tfNom);
Line 206... Line 221...
206
			
221
			
Line 207... Line 222...
207
			hmIdentite.put("tfNom", tfNom);
222
			hmIdentite.put("tfNom", tfNom);
208
			
223
			
209
			//Préfixe
224
			//Suffixe
210
			ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
225
			ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
211
			ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
226
			ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
-
 
227
			cbSuffixe.setStore(storeSuffixe);
-
 
228
			cbSuffixe.setFieldLabel("Suffixe");
212
			cbSuffixe.setStore(storeSuffixe);
229
			cbSuffixe.setDisplayField("nom");
Line 213... Line 230...
213
			cbSuffixe.setFieldLabel("Suffixe");
230
			cbSuffixe.setEmptyText("Choisissez un suffixe:");
214
			fsNoms.add(cbSuffixe);			
231
			fsNoms.add(cbSuffixe);			
-
 
232
			
-
 
233
			hmIdentite.put("cbSuffixe", cbSuffixe);
-
 
234
			
215
			
235
			// Remplir la liste des suffixes:
216
			hmIdentite.put("cbSuffixe", cbSuffixe);
236
			mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");
217
						
237
			
218
			// Nom : autre
238
			// Nom : autre
Line 274... Line 294...
274
			tfLieuDeces.setFieldLabel("Lieu de décès");
294
			tfLieuDeces.setFieldLabel("Lieu de décès");
275
			fsVie.add(tfLieuDeces);
295
			fsVie.add(tfLieuDeces);
Line 276... Line 296...
276
			
296
			
Line 277... Line -...
277
			hmIdentite.put("tfLieuDeces", tfLieuDeces);
-
 
278
			
-
 
279
			//Date picker
-
 
280
			DatePicker datePick = new DatePicker();
-
 
281
			
297
			hmIdentite.put("tfLieuDeces", tfLieuDeces);
Line 282... Line 298...
282
			
298
			
Line 283... Line 299...
283
			left.add(fsVie);
299
			left.add(fsVie);
284
			
300
			
285
			tiIdentite.add(main);
301
			tiIdentite.add(main);
286
			
-
 
287
			
-
 
288
			// Ajout des évènements saisi
-
 
289
			KeyListener klNoms = new KeyListener()	{
-
 
290
				public void componentKeyUp(ComponentEvent ev)	{
-
 
291
						/*
-
 
292
						 * Met à jour le nom Complet du formulaire
-
 
293
						 * */
302
			
294
						String valeurRetour = "";
-
 
295
						// Prefixe
-
 
296
						String prefixe = (String) ((ComboBox) hmIdentite.get("cbPrefix")).getSelectedText();
-
 
297
						
-
 
298
						// Prénom
-
 
299
						String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
-
 
300
						
-
 
301
						// Nom
-
 
302
						String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
-
 
303
						
-
 
304
						// Suffixe
-
 
305
						String suffixe = (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getSelectedText();
-
 
306
						
-
 
307
						// Mettre à jour la valeur
-
 
308
						valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
-
 
309
						valeurRetour = valeurRetour.replaceAll("null", "");
-
 
310
						
-
 
311
						((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
-
 
312
						
-
 
313
						if (!valeurRetour.trim().equals(""))	{
-
 
314
							((LabelField) hmIdentite.get("nomComplet")).show();
303
			
315
						} else {
304
			// Ajout des évènements saisi
Line -... Line 305...
-
 
305
			KeyListener klNoms = new KeyListener()	{
-
 
306
				public void componentKeyUp(ComponentEvent ev)	{
-
 
307
					rafraichir(null);	
-
 
308
				}				
-
 
309
			};
-
 
310
			
-
 
311
			SelectionChangedListener<InterneValeur> selectionChange = new SelectionChangedListener<InterneValeur>() {
316
							((LabelField) hmIdentite.get("nomComplet")).hide();
312
				public void selectionChanged(SelectionChangedEvent se) {
317
						}
313
						rafraichir(null);
318
						
314
					}
319
				}				
315
			};
320
			};
-
 
321
			
-
 
322
			cbPrefix.addKeyListener(klNoms);
-
 
323
			tfPrenom.addKeyListener(klNoms);
-
 
324
			tfNom.addKeyListener(klNoms);
-
 
325
			cbSuffixe.addKeyListener(klNoms);
-
 
326
			
-
 
327
			
-
 
328
			//Prénom
-
 
329
		
-
 
330
			
-
 
331
			this.recalculate();
-
 
332
			fsNoms.recalculate();
-
 
Line 333... Line 316...
333
			fsNoms.layout();
316
						
Line 334... Line 317...
334
			this.layout();
317
			cbPrefix.addSelectionChangedListener(selectionChange);
335
			this.hide();
318
			cbPrefix.addKeyListener(klNoms);
Line 397... Line 380...
397
	
380
	
398
	/*---------------------------------------------------------------------------------------
381
	/*---------------------------------------------------------------------------------------
399
	 * 		RAFRAICHISSEMENT DU PANNEAU
382
	 * 		RAFRAICHISSEMENT DU PANNEAU
400
	 * --------------------------------------------------------------------------------------
383
	 * --------------------------------------------------------------------------------------
401
	 */	
384
	 */	
-
 
385
	public void rafraichir(Object nouvellesDonnees) {
-
 
386
		if (nouvellesDonnees instanceof ValeurListe){
-
 
387
			
-
 
388
			
-
 
389
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
-
 
390
			
-
 
391
			
402
	public void rafraichir(Object nouvelleDonnees) {
392
			
-
 
393
			// Créer une liste de valeurs
-
 
394
			List<Valeur> liste = new ArrayList<Valeur>();
-
 
395
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
-
 
396
				liste.add(listeValeurs.get(it.next()));
-
 
397
			}
-
 
398
			
-
 
399
			if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
-
 
400
 
-
 
401
				//Remplir la liste Prefixe
-
 
402
				
-
 
403
				
403
		// TODO Auto-generated method stub
404
				ListStore<Valeur> stPrefixe = ((ComboBox) hmIdentite.get("cbPrefix")).getStore();
-
 
405
				stPrefixe.removeAll();
-
 
406
				stPrefixe.add(liste);
-
 
407
				((ComboBox) hmIdentite.get("cbPrefix")).setStore(stPrefixe);
-
 
408
				
-
 
409
				
-
 
410
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
-
 
411
			
-
 
412
				//Remplir la liste Suffixe
404
		this.show();
413
				ListStore<Valeur> stSuffix = ((ComboBox) hmIdentite.get("cbSuffixe")).getStore();
405
		this.layout();
414
				stSuffix.removeAll();
-
 
415
				stSuffix.add(liste);
-
 
416
				((ComboBox) hmIdentite.get("cbSuffixe")).setStore(stSuffix);
-
 
417
				
-
 
418
				
-
 
419
			}
-
 
420
		}
-
 
421
		
-
 
422
		if (nouvellesDonnees == null)
-
 
423
		{
-
 
424
			ComboBox cb= (ComboBox) hmIdentite.get("cbPrefix");
-
 
425
			/*
-
 
426
			 * Met à jour le nom Complet du formulaire
-
 
427
			 * */
-
 
428
			String valeurRetour = "";
-
 
429
			
-
 
430
			// Prefixe
-
 
431
			String prefixe = "";
-
 
432
			Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefix")).getValue();
-
 
433
			
-
 
434
			if (valPrefixe != null)	{
-
 
435
				prefixe = valPrefixe.getNom();
-
 
436
			}
-
 
437
			
-
 
438
			// Prénom
-
 
439
			String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
-
 
440
			
-
 
441
			// Nom
-
 
442
			String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
-
 
443
			
-
 
444
			// Suffixe
-
 
445
			String suffixe = "";
-
 
446
			Valeur valSuffixe = (Valeur) ((ComboBox) hmIdentite.get("cbSuffixe")).getValue();
-
 
447
			
-
 
448
			if (valSuffixe != null)	{
-
 
449
				suffixe = valSuffixe.getNom();
-
 
450
			}
-
 
451
			
-
 
452
			// Mettre à jour la valeur
-
 
453
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
-
 
454
			valeurRetour = valeurRetour.replaceAll("null", "");
-
 
455
			
-
 
456
			((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
-
 
457
			
-
 
458
			if (!valeurRetour.trim().equals(""))	{
-
 
459
				((LabelField) hmIdentite.get("nomComplet")).show();
-
 
460
			} else {
-
 
461
				((LabelField) hmIdentite.get("nomComplet")).hide();
-
 
462
			}
406
		this.recalculate();		
463
		}