Subversion Repositories eFlore/Applications.coel

Rev

Rev 189 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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