Subversion Repositories eFlore/Applications.coel

Rev

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

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