127 |
gduche |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.Iterator;
|
|
|
5 |
import java.util.List;
|
|
|
6 |
|
|
|
7 |
import org.tela_botanica.client.ComposantClass;
|
|
|
8 |
import org.tela_botanica.client.Mediateur;
|
|
|
9 |
import org.tela_botanica.client.RegistreId;
|
|
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
353 |
gduche |
11 |
import org.tela_botanica.client.modeles.Information;
|
127 |
gduche |
12 |
import org.tela_botanica.client.modeles.Personne;
|
|
|
13 |
import org.tela_botanica.client.modeles.PersonneListe;
|
|
|
14 |
|
|
|
15 |
import com.extjs.gxt.ui.client.Registry;
|
287 |
gduche |
16 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
127 |
gduche |
17 |
import com.extjs.gxt.ui.client.Style.SelectionMode;
|
377 |
gduche |
18 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
127 |
gduche |
19 |
import com.extjs.gxt.ui.client.binder.TableBinder;
|
|
|
20 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
|
|
21 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
|
|
22 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
|
|
23 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
24 |
import com.extjs.gxt.ui.client.store.ListStore;
|
|
|
25 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
353 |
gduche |
26 |
import com.extjs.gxt.ui.client.widget.Info;
|
278 |
jp_milcent |
27 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
417 |
gduche |
28 |
import com.extjs.gxt.ui.client.widget.form.LabelField;
|
127 |
gduche |
29 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
287 |
gduche |
30 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
127 |
gduche |
31 |
import com.extjs.gxt.ui.client.widget.table.Table;
|
|
|
32 |
import com.extjs.gxt.ui.client.widget.table.TableColumn;
|
|
|
33 |
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
|
417 |
gduche |
34 |
import com.extjs.gxt.ui.client.widget.table.TableItem;
|
127 |
gduche |
35 |
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
|
|
|
36 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
278 |
jp_milcent |
37 |
import com.google.gwt.core.client.GWT;
|
353 |
gduche |
38 |
import com.google.gwt.user.client.Window;
|
127 |
gduche |
39 |
|
|
|
40 |
public class PanneauPersonneListe extends ContentPanel implements Rafraichissable {
|
|
|
41 |
|
278 |
jp_milcent |
42 |
private Mediateur mediateur = null ;
|
127 |
gduche |
43 |
private Table table = null;
|
|
|
44 |
private ListStore<Personne> store = null;
|
|
|
45 |
private TableBinder<Personne> binder = null;
|
287 |
gduche |
46 |
private Personne personneSelectionnee = null;
|
258 |
gduche |
47 |
|
127 |
gduche |
48 |
public PanneauPersonneListe() {
|
278 |
jp_milcent |
49 |
mediateur = Registry.get(RegistreId.MEDIATEUR);
|
127 |
gduche |
50 |
|
|
|
51 |
//Définition de la barre d'outil
|
|
|
52 |
ToolBar toolBar = new ToolBar();
|
|
|
53 |
TextToolItem ajouter = new TextToolItem("Ajouter");
|
|
|
54 |
ajouter.setIconStyle(ComposantClass.ICONE_AJOUTER);
|
|
|
55 |
ajouter.addSelectionListener(new SelectionListener<ComponentEvent>() {
|
|
|
56 |
public void componentSelected(ComponentEvent ce) {
|
278 |
jp_milcent |
57 |
mediateur.clicAjouterPersonne();
|
127 |
gduche |
58 |
}
|
|
|
59 |
});
|
|
|
60 |
toolBar.add(ajouter);
|
217 |
aurelien |
61 |
|
|
|
62 |
|
|
|
63 |
final Rafraichissable r = this ;
|
127 |
gduche |
64 |
|
217 |
aurelien |
65 |
// TODO : ajouter btn mod & supp
|
|
|
66 |
final TextToolItem modifier = new TextToolItem("Modifier");
|
127 |
gduche |
67 |
modifier.setIconStyle(ComposantClass.ICONE_MODIFIER);
|
217 |
aurelien |
68 |
modifier.addSelectionListener(new SelectionListener<ComponentEvent>() {
|
|
|
69 |
public void componentSelected(ComponentEvent ce) {
|
287 |
gduche |
70 |
mediateur.clicModifierPersonne(personneSelectionnee);
|
217 |
aurelien |
71 |
}
|
|
|
72 |
});
|
127 |
gduche |
73 |
toolBar.add(modifier);
|
|
|
74 |
|
217 |
aurelien |
75 |
final TextToolItem supprimer = new TextToolItem("Supprimer");
|
|
|
76 |
supprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {
|
|
|
77 |
public void componentSelected(ComponentEvent ce) {
|
|
|
78 |
|
417 |
gduche |
79 |
mediateur.clicSupprimerPersonne(r, binder.getSelection());
|
217 |
aurelien |
80 |
}
|
|
|
81 |
});
|
417 |
gduche |
82 |
|
127 |
gduche |
83 |
supprimer.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
|
|
|
84 |
toolBar.add(supprimer);
|
258 |
gduche |
85 |
|
127 |
gduche |
86 |
setTopComponent(toolBar);
|
258 |
gduche |
87 |
|
127 |
gduche |
88 |
List<TableColumn> columns = new ArrayList<TableColumn>();
|
|
|
89 |
|
|
|
90 |
// ATTENTION : les noms des colonnes doivent correspondrent aux noms variables de la classe utilisée dans la liste
|
|
|
91 |
columns.add(new TableColumn("fmt_nom_complet", "Nom Complet", .20f));
|
|
|
92 |
columns.add(new TableColumn("nom", "Nom", .20f));
|
|
|
93 |
columns.add(new TableColumn("code_postal", "Code Postal", .10f));
|
|
|
94 |
columns.add(new TableColumn("ville", "Ville", .20f));
|
262 |
gduche |
95 |
columns.add(new TableColumn("courriel_princ", "Courriel", .25f));
|
127 |
gduche |
96 |
|
|
|
97 |
TableColumnModel cm = new TableColumnModel(columns);
|
|
|
98 |
|
|
|
99 |
table = new Table(cm);
|
|
|
100 |
table.setSelectionMode(SelectionMode.MULTI);
|
|
|
101 |
table.setBorders(false);
|
287 |
gduche |
102 |
|
|
|
103 |
table.setHorizontalScroll(true);
|
|
|
104 |
|
127 |
gduche |
105 |
add(table);
|
|
|
106 |
|
|
|
107 |
store = new ListStore<Personne>();
|
|
|
108 |
|
|
|
109 |
binder = new TableBinder<Personne>(table, store);
|
|
|
110 |
binder.setAutoSelect(true);
|
150 |
gduche |
111 |
|
|
|
112 |
binder.addSelectionChangedListener(new SelectionChangedListener<Personne>() {
|
|
|
113 |
public void selectionChanged(SelectionChangedEvent<Personne> event) {
|
|
|
114 |
Personne p = (Personne) event.getSelectedItem();
|
287 |
gduche |
115 |
personneSelectionnee = p;
|
150 |
gduche |
116 |
clicListe(p);
|
127 |
gduche |
117 |
}
|
150 |
gduche |
118 |
});
|
287 |
gduche |
119 |
|
127 |
gduche |
120 |
setLayout(new FitLayout());
|
|
|
121 |
}
|
|
|
122 |
|
150 |
gduche |
123 |
private void clicListe(Personne personne) {
|
278 |
jp_milcent |
124 |
mediateur.clicListePersonne(personne);
|
127 |
gduche |
125 |
}
|
|
|
126 |
|
353 |
gduche |
127 |
public void rafraichir(Object nouvellesDonnees) {
|
417 |
gduche |
128 |
|
353 |
gduche |
129 |
if (nouvellesDonnees instanceof PersonneListe) {
|
417 |
gduche |
130 |
|
127 |
gduche |
131 |
setHeading("Personnes");
|
353 |
gduche |
132 |
PersonneListe listePersonnes = (PersonneListe) nouvellesDonnees;
|
127 |
gduche |
133 |
|
|
|
134 |
List<Personne> liste = new ArrayList<Personne>();
|
|
|
135 |
for (Iterator<String> it = listePersonnes.keySet().iterator(); it.hasNext();) {
|
|
|
136 |
liste.add(listePersonnes.get(it.next()));
|
|
|
137 |
}
|
|
|
138 |
|
278 |
jp_milcent |
139 |
store.removeAll();
|
|
|
140 |
store.add(liste);
|
377 |
gduche |
141 |
|
417 |
gduche |
142 |
mediateur.actualiserPanneauCentral();
|
377 |
gduche |
143 |
|
417 |
gduche |
144 |
if (store.getCount() > 0) {
|
|
|
145 |
table.getSelectionModel().select(0);
|
|
|
146 |
}
|
377 |
gduche |
147 |
|
|
|
148 |
|
|
|
149 |
|
417 |
gduche |
150 |
} else if (nouvellesDonnees instanceof Information) {
|
377 |
gduche |
151 |
|
417 |
gduche |
152 |
Information info = (Information) nouvellesDonnees;
|
|
|
153 |
Info.display("Erreur", info.getMessages().toString());
|
|
|
154 |
|
|
|
155 |
if (info.getType().equals("suppression_personne")) {
|
|
|
156 |
|
|
|
157 |
List<TableItem> selectionPersonnes = table.getSelectedItems();
|
|
|
158 |
final int taille = selectionPersonnes.size();
|
|
|
159 |
for (int i = 0; i < taille; i++) {
|
|
|
160 |
//GWT.log("INDEX :"+table.indexOf(selectionStructure.get(i)), null);
|
|
|
161 |
table.remove(selectionPersonnes.get(i));
|
|
|
162 |
}
|
361 |
jp_milcent |
163 |
}
|
|
|
164 |
|
417 |
gduche |
165 |
|
|
|
166 |
|
361 |
jp_milcent |
167 |
} else {
|
353 |
gduche |
168 |
GWT.log("Pas de correspondance" + nouvellesDonnees.getClass() + " dans la méthode rafraichir() de la classe "+this.getClass(), null);
|
127 |
gduche |
169 |
}
|
278 |
jp_milcent |
170 |
layout();
|
127 |
gduche |
171 |
}
|
|
|
172 |
}
|
189 |
gduche |
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|