Line 5... |
Line 5... |
5 |
|
5 |
|
6 |
import org.tela_botanica.client.ComposantClass;
|
6 |
import org.tela_botanica.client.ComposantClass;
|
7 |
import org.tela_botanica.client.Mediateur;
|
7 |
import org.tela_botanica.client.Mediateur;
|
8 |
import org.tela_botanica.client.RegistreId;
|
8 |
import org.tela_botanica.client.RegistreId;
|
- |
|
9 |
import org.tela_botanica.client.i18n.Constantes;
|
9 |
import org.tela_botanica.client.i18n.Constantes;
|
10 |
import org.tela_botanica.client.images.Images;
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
11 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
11 |
import org.tela_botanica.client.modeles.Information;
|
12 |
import org.tela_botanica.client.modeles.Information;
|
12 |
import org.tela_botanica.client.modeles.Structure;
|
13 |
import org.tela_botanica.client.modeles.Structure;
|
13 |
import org.tela_botanica.client.modeles.StructureListe;
|
14 |
import org.tela_botanica.client.modeles.StructureListe;
|
Line 14... |
Line 15... |
14 |
import org.tela_botanica.client.modeles.Utilisateur;
|
15 |
import org.tela_botanica.client.modeles.Utilisateur;
|
15 |
|
16 |
|
16 |
import com.extjs.gxt.ui.client.Registry;
|
17 |
import com.extjs.gxt.ui.client.Registry;
|
17 |
import com.extjs.gxt.ui.client.Style.SelectionMode;
|
- |
|
18 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
18 |
import com.extjs.gxt.ui.client.Style.SelectionMode;
|
19 |
import com.extjs.gxt.ui.client.binder.TableBinder;
|
19 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
20 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
20 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
21 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
21 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
22 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
22 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
23 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
23 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
24 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
24 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
25 |
import com.extjs.gxt.ui.client.store.ListStore;
|
25 |
import com.extjs.gxt.ui.client.store.ListStore;
|
26 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
26 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
- |
|
27 |
import com.extjs.gxt.ui.client.widget.Info;
|
- |
|
28 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
- |
|
29 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
- |
|
30 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
27 |
import com.extjs.gxt.ui.client.widget.Info;
|
31 |
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
28 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
- |
|
29 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
- |
|
30 |
import com.extjs.gxt.ui.client.widget.table.Table;
|
- |
|
31 |
import com.extjs.gxt.ui.client.widget.table.TableColumn;
|
- |
|
32 |
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
|
32 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
33 |
import com.extjs.gxt.ui.client.widget.table.TableItem;
|
33 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
Line 34... |
Line 34... |
34 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
34 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
Line 35... |
Line 35... |
35 |
import com.google.gwt.core.client.GWT;
|
35 |
import com.google.gwt.core.client.GWT;
|
36 |
|
36 |
|
Line 37... |
Line 37... |
37 |
public class StructureListeVue extends ContentPanel implements Rafraichissable {
|
37 |
public class StructureListeVue extends ContentPanel implements Rafraichissable {
|
- |
|
38 |
|
38 |
|
39 |
private Mediateur mediateur = null ;
|
39 |
private Mediateur mediateur = null ;
|
- |
|
40 |
private Constantes i18nC = null ;
|
40 |
private Constantes i18nC = null ;
|
41 |
|
41 |
|
42 |
private Table table = null;
|
42 |
//private Table table = null;
|
43 |
private ListStore<Structure> store = null;
|
43 |
private Grid<Structure> grille = null;
|
Line 44... |
Line 44... |
44 |
private TableBinder<Structure> binder = null;
|
44 |
private ListStore<Structure> store = null;
|
Line 53... |
Line 53... |
53 |
|
53 |
|
Line 54... |
Line 54... |
54 |
Utilisateur utilisateur = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
|
54 |
Utilisateur utilisateur = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
|
55 |
|
55 |
|
56 |
ToolBar toolBar = new ToolBar();
|
56 |
ToolBar toolBar = new ToolBar();
|
57 |
ajouter = new Button(i18nC.ajouter());
|
57 |
ajouter = new Button(i18nC.ajouter());
|
58 |
ajouter.setIconStyle(ComposantClass.ICONE_AJOUTER);
|
58 |
ajouter.setIcon(Images.ICONES.ajouter());
|
59 |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
59 |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
60 |
public void componentSelected(ButtonEvent ce) {
|
60 |
public void componentSelected(ButtonEvent ce) {
|
61 |
mediateur.clicAjouterStructure();
|
61 |
mediateur.clicAjouterStructure();
|
62 |
}
|
62 |
}
|
Line 63... |
Line 63... |
63 |
});
|
63 |
});
|
64 |
toolBar.add(ajouter);
|
64 |
toolBar.add(ajouter);
|
65 |
|
65 |
|
66 |
modifier = new Button(i18nC.modifier());
|
66 |
modifier = new Button(i18nC.modifier());
|
67 |
modifier.setIconStyle(ComposantClass.ICONE_MODIFIER);
|
67 |
modifier.setIcon(Images.ICONES.formModifier());
|
68 |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
68 |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
69 |
public void componentSelected(ButtonEvent ce) {
|
69 |
public void componentSelected(ButtonEvent ce) {
|
- |
|
70 |
mediateur.clicModifierStructure(grille.getSelectionModel().getSelectedItems());
|
70 |
mediateur.clicModifierStructure(binder.getSelection());
|
71 |
}
|
Line 71... |
Line 72... |
71 |
}
|
72 |
});
|
72 |
});
|
73 |
|
73 |
toolBar.add(modifier);
|
74 |
toolBar.add(modifier);
|
74 |
|
75 |
|
75 |
supprimer = new Button(i18nC.supprimer());
|
76 |
supprimer = new Button(i18nC.supprimer());
|
76 |
supprimer.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
|
77 |
supprimer.setIcon(Images.ICONES.supprimer());
|
77 |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
78 |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
78 |
public void componentSelected(ButtonEvent ce) {
|
79 |
public void componentSelected(ButtonEvent ce) {
|
79 |
clicSupprimerStructure(binder.getSelection());
|
80 |
clicSupprimerStructure(grille.getSelectionModel().getSelectedItems());
|
80 |
}
|
81 |
}
|
81 |
});
|
82 |
});
|
Line 82... |
Line 83... |
82 |
if (!utilisateur.isIdentifie()) {
|
83 |
if (!utilisateur.isIdentifie()) {
|
Line 83... |
Line 84... |
83 |
supprimer.disable();
|
84 |
supprimer.disable();
|
- |
|
85 |
}
|
84 |
}
|
86 |
toolBar.add(supprimer);
|
- |
|
87 |
|
- |
|
88 |
setTopComponent(toolBar);
|
- |
|
89 |
|
85 |
toolBar.add(supprimer);
|
90 |
List<ColumnConfig> lstColumns = new ArrayList<ColumnConfig>();
|
86 |
|
91 |
|
87 |
setTopComponent(toolBar);
|
92 |
ColumnConfig ccVille = new ColumnConfig();
|
88 |
|
93 |
ccVille.setId("ville");
|
89 |
List<TableColumn> columns = new ArrayList<TableColumn>();
|
- |
|
90 |
columns.add(new TableColumn("ville", i18nC.ville(), .3f));
|
94 |
ccVille.setHeader("Ville");
|
91 |
columns.add(new TableColumn("nom", i18nC.nom(), .7f));
|
95 |
ccVille.setWidth(300);
|
92 |
|
96 |
lstColumns.add(ccVille);
|
- |
|
97 |
|
- |
|
98 |
ColumnConfig ccNom = new ColumnConfig();
|
Line 93... |
Line 99... |
93 |
TableColumnModel cm = new TableColumnModel(columns);
|
99 |
ccNom.setId("nom");
|
94 |
table = new Table(cm);
|
100 |
ccNom.setHeader("Nom");
|
- |
|
101 |
ccNom.setWidth(300);
|
95 |
table.setSelectionMode(SelectionMode.MULTI);
|
102 |
lstColumns.add(ccNom);
|
96 |
table.setBorders(false);
|
103 |
|
97 |
table.setStripeRows(true);
|
104 |
ColumnModel cmStructure = new ColumnModel(lstColumns);
|
98 |
add(table);
|
105 |
|
99 |
|
106 |
store = new ListStore<Structure>();
|
100 |
store = new ListStore<Structure>();
|
107 |
store.sort("ville", SortDir.ASC);
|
101 |
store.sort("ville", SortDir.ASC);
|
108 |
grille = new Grid<Structure>(store, cmStructure);
|
102 |
|
109 |
|
103 |
binder = new TableBinder<Structure>(table, store);
|
110 |
GridSelectionModel<Structure> gsmSelectionStructure = new GridSelectionModel<Structure>();
|
- |
|
111 |
gsmSelectionStructure.addSelectionChangedListener(new SelectionChangedListener<Structure>() {
|
- |
|
112 |
public void selectionChanged(SelectionChangedEvent<Structure> event) {
|
- |
|
113 |
Structure m = (Structure) event.getSelectedItem();
|
104 |
binder.addSelectionChangedListener(new SelectionChangedListener<Structure>() {
|
114 |
clicListe(m);
|
105 |
public void selectionChanged(SelectionChangedEvent<Structure> event) {
|
115 |
}
|
Line 106... |
Line 116... |
106 |
Structure m = (Structure) event.getSelectedItem();
|
116 |
});
|
107 |
clicListe(m);
|
117 |
|
Line 134... |
Line 144... |
134 |
|
144 |
|
Line 135... |
Line 145... |
135 |
mediateur.actualiserPanneauCentral();
|
145 |
mediateur.actualiserPanneauCentral();
|
136 |
|
146 |
|
137 |
if (store.getCount() > 0) {
|
147 |
if (store.getCount() > 0) {
|
- |
|
148 |
//TODO : check below:
|
138 |
//TODO : check below:
|
149 |
//table.getSelectionModel().select(0, 1, true);
|
139 |
table.getSelectionModel().select(0, 1, true);
|
150 |
grille.getSelectionModel().select(0, true);
|
140 |
}
|
151 |
}
|
141 |
} else if (nouvelleDonnees instanceof Information) {
|
152 |
} else if (nouvelleDonnees instanceof Information) {
|
142 |
Information info = (Information) nouvelleDonnees;
|
153 |
Information info = (Information) nouvelleDonnees;
|
143 |
if (info.getType().equals("suppression_structure")) {
|
154 |
if (info.getType().equals("suppression_structure")) {
|
144 |
// Affichage d'un message d'information
|
155 |
// Affichage d'un message d'information
|
Line 145... |
Line 156... |
145 |
//GWT.log(info.toString(), null);
|
156 |
//GWT.log(info.toString(), null);
|
146 |
Info.display(i18nC.suppressionStructure(), info.toString().replaceAll("\n", "<br />"));
|
157 |
Info.display(i18nC.suppressionStructure(), info.toString().replaceAll("\n", "<br />"));
|
147 |
|
158 |
|
148 |
// Suppression des structures sélectionnées
|
159 |
// Suppression des structures sélectionnées
|
149 |
List<TableItem> selectionStructure = table.getSelectedItems();
|
160 |
List<Structure> selectionStructure = grille.getSelectionModel().getSelectedItems();//table.getSelectedItems();
|
150 |
final int taille = selectionStructure.size();
|
161 |
final int taille = selectionStructure.size();
|
- |
|
162 |
for (int i = 0; i < taille; i++) {
|
151 |
for (int i = 0; i < taille; i++) {
|
163 |
//GWT.log("INDEX :"+table.indexOf(selectionStructure.get(i)), null);
|
Line 152... |
Line 164... |
152 |
//GWT.log("INDEX :"+table.indexOf(selectionStructure.get(i)), null);
|
164 |
//table.remove(selectionStructure.get(i));
|
- |
|
165 |
store.remove(selectionStructure.get(i));
|
- |
|
166 |
}
|
153 |
table.remove(selectionStructure.get(i));
|
167 |
|
154 |
}
|
168 |
// Désactivation des boutons si la liste est vide
|
155 |
|
169 |
|
156 |
// Désactivation des boutons si la liste est vide
|
170 |
//TODO : taille de la grille??
|
157 |
if (table.getItemCount() == 0) {
|
171 |
/*if ( == 0) {
|
158 |
supprimer.disable();
|
172 |
supprimer.disable();
|
- |
|
173 |
modifier.disable();
|
159 |
modifier.disable();
|
174 |
}*/
|
160 |
}
|
175 |
} else if (info.getType().equals("maj_utilisateur")) {
|
161 |
} else if (info.getType().equals("maj_utilisateur")) {
|
176 |
/*if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
|
162 |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
|
177 |
//TODO : taille de la grille??
|
163 |
if (table.getItemCount() != 0) {
|
178 |
if (table.getItemCount() != 0) {
|
164 |
supprimer.enable();
|
179 |
supprimer.enable();
|
165 |
}
|
180 |
}
|
166 |
} else {
|
181 |
} else {
|
167 |
supprimer.disable();
|
182 |
supprimer.disable();
|
168 |
}
|
183 |
}*/
|
169 |
}
|
184 |
}
|