Subversion Repositories eFlore/Applications.coel

Rev

Rev 150 | Rev 217 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
127 gduche 1
package org.tela_botanica.client.vues;
2
 
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6
 
7
import org.tela_botanica.client.ComposantClass;
8
import org.tela_botanica.client.Mediateur;
9
import org.tela_botanica.client.RegistreId;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.modeles.Personne;
12
import org.tela_botanica.client.modeles.PersonneListe;
13
import org.tela_botanica.client.modeles.Structure;
14
import org.tela_botanica.client.modeles.StructureListe;
15
 
16
import com.extjs.gxt.ui.client.Registry;
17
import com.extjs.gxt.ui.client.Style.SelectionMode;
18
import com.extjs.gxt.ui.client.binder.TableBinder;
19
import com.extjs.gxt.ui.client.event.ComponentEvent;
20
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
21
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
22
import com.extjs.gxt.ui.client.event.SelectionListener;
23
import com.extjs.gxt.ui.client.store.ListStore;
24
import com.extjs.gxt.ui.client.widget.ContentPanel;
25
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
26
import com.extjs.gxt.ui.client.widget.table.Table;
27
import com.extjs.gxt.ui.client.widget.table.TableColumn;
28
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
29
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
30
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
189 gduche 31
import com.google.gwt.core.client.GWT;
127 gduche 32
import com.google.gwt.user.client.Window;
33
 
34
public class PanneauPersonneListe extends ContentPanel implements Rafraichissable {
35
 
36
	private Mediateur coelMediateur = null ;
37
	private Table table = null;
38
	private ListStore<Personne> store = null;
39
	private TableBinder<Personne> binder = null;
40
 
41
	public PanneauPersonneListe() {
42
		coelMediateur = Registry.get(RegistreId.MEDIATEUR);
43
 
44
		//Définition de la barre d'outil
45
		ToolBar toolBar = new ToolBar();
46
		TextToolItem ajouter = new TextToolItem("Ajouter");
47
		ajouter.setIconStyle(ComposantClass.ICONE_AJOUTER);
48
		ajouter.addSelectionListener(new SelectionListener<ComponentEvent>() {
49
			public void componentSelected(ComponentEvent ce) {
50
				coelMediateur.clicAjouterPersonne();
51
			}
52
		});
53
		toolBar.add(ajouter);
54
 
55
		/*
56
		 TODO : ajouter btn mod & supp
57
		TextToolItem modifier = new TextToolItem("Modifier");
58
		modifier.setIconStyle(ComposantClass.ICONE_MODIFIER);
59
		toolBar.add(modifier);
60
 
61
		TextToolItem supprimer = new TextToolItem("Supprimer");
62
		supprimer.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
63
		toolBar.add(supprimer);
64
		 */
65
		setTopComponent(toolBar);
66
 
67
		List<TableColumn> columns = new ArrayList<TableColumn>();
68
 
69
		//TODO : La liste déborde sur la droite, ce qui ajoute une scroll bar
70
 
71
		// ATTENTION : les noms des colonnes doivent correspondrent aux noms variables de la classe utilisée dans la liste
72
		columns.add(new TableColumn("fmt_nom_complet", "Nom Complet", .20f));
73
		columns.add(new TableColumn("nom", "Nom", .20f));
74
		columns.add(new TableColumn("code_postal", "Code Postal", .10f));
75
		columns.add(new TableColumn("ville", "Ville", .20f));
76
		columns.add(new TableColumn("truk_courriel", "Courriel", .25f));
77
 
78
		TableColumnModel cm = new TableColumnModel(columns);
79
 
80
		table = new Table(cm);
81
		table.setSelectionMode(SelectionMode.MULTI);
82
		table.setBorders(false);
83
 
84
		add(table);
85
 
86
		store = new ListStore<Personne>();
87
 
88
		binder = new TableBinder<Personne>(table, store);
89
		binder.setAutoSelect(true);
150 gduche 90
 
91
 
92
		binder.addSelectionChangedListener(new SelectionChangedListener<Personne>() {
93
		public void selectionChanged(SelectionChangedEvent<Personne> event) {
94
				Personne p = (Personne) event.getSelectedItem();
95
				clicListe(p);
127 gduche 96
			}
150 gduche 97
		});
127 gduche 98
 
99
		setLayout(new FitLayout());
100
	}
101
 
102
	public ListStore<Personne> getStore() {
103
		return store;
104
	}
105
 
106
	public TableBinder<Personne> getBinder() {
107
		return binder;
108
	}
109
 
150 gduche 110
	private void clicListe(Personne personne) {
111
		coelMediateur.clicListePersonne(personne);
127 gduche 112
	}
113
 
114
	public void rafraichir(Object nouvelleDonnees) {
115
		if (nouvelleDonnees instanceof PersonneListe) {
189 gduche 116
			store.removeAll();
127 gduche 117
			setHeading("Personnes");
118
			PersonneListe listePersonnes = (PersonneListe) nouvelleDonnees;
119
 
120
			List<Personne> liste = new ArrayList<Personne>();
121
 
122
			for (Iterator<String> it = listePersonnes.keySet().iterator(); it.hasNext();) {
123
 
124
				liste.add(listePersonnes.get(it.next()));
125
			}
126
 
189 gduche 127
 
127 gduche 128
			store.add((List<Personne>) liste);
189 gduche 129
 
127 gduche 130
		}
131
 
132
	}
133
}
189 gduche 134
 
135
 
136
 
137
 
138
 
139