Subversion Repositories eFlore/Applications.coel

Rev

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

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