Subversion Repositories eFlore/Applications.coel

Rev

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

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