Subversion Repositories eFlore/Applications.coel

Rev

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

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