106 |
aurelien |
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;
|
|
|
11 |
import org.tela_botanica.client.modeles.Publication;
|
|
|
12 |
import org.tela_botanica.client.modeles.PublicationListe;
|
|
|
13 |
|
|
|
14 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
15 |
import com.extjs.gxt.ui.client.Style.SelectionMode;
|
|
|
16 |
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.SelectionChangedEvent;
|
|
|
19 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
|
|
20 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
21 |
import com.extjs.gxt.ui.client.store.ListStore;
|
227 |
aurelien |
22 |
import com.extjs.gxt.ui.client.widget.Component;
|
106 |
aurelien |
23 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
24 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
227 |
aurelien |
25 |
import com.extjs.gxt.ui.client.widget.table.CellRenderer;
|
106 |
aurelien |
26 |
import com.extjs.gxt.ui.client.widget.table.Table;
|
|
|
27 |
import com.extjs.gxt.ui.client.widget.table.TableColumn;
|
|
|
28 |
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
|
|
|
29 |
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
|
|
|
30 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
|
|
31 |
|
444 |
jp_milcent |
32 |
public class PublicationListeVue extends ContentPanel implements Rafraichissable {
|
106 |
aurelien |
33 |
|
|
|
34 |
private Mediateur coelMediateur = null ;
|
|
|
35 |
private Table table = null;
|
|
|
36 |
private ListStore<Publication> store = null;
|
|
|
37 |
private TableBinder<Publication> binder = null;
|
|
|
38 |
|
444 |
jp_milcent |
39 |
public PublicationListeVue() {
|
106 |
aurelien |
40 |
coelMediateur = Registry.get(RegistreId.MEDIATEUR);
|
|
|
41 |
|
|
|
42 |
ToolBar toolBar = new ToolBar();
|
|
|
43 |
TextToolItem ajouter = new TextToolItem("Ajouter");
|
|
|
44 |
ajouter.setIconStyle(ComposantClass.ICONE_AJOUTER);
|
|
|
45 |
ajouter.addSelectionListener(new SelectionListener<ComponentEvent>() {
|
|
|
46 |
public void componentSelected(ComponentEvent ce) {
|
|
|
47 |
coelMediateur.clicAjouterPublication();
|
|
|
48 |
}
|
|
|
49 |
});
|
|
|
50 |
toolBar.add(ajouter);
|
|
|
51 |
|
|
|
52 |
TextToolItem modifier = new TextToolItem("Modifier");
|
|
|
53 |
modifier.setIconStyle(ComposantClass.ICONE_MODIFIER);
|
|
|
54 |
toolBar.add(modifier);
|
219 |
aurelien |
55 |
modifier.addSelectionListener(new SelectionListener<ComponentEvent>() {
|
|
|
56 |
public void componentSelected(ComponentEvent ce) {
|
|
|
57 |
coelMediateur.clicModifierPublication(binder.getSelection());
|
|
|
58 |
}
|
|
|
59 |
});
|
106 |
aurelien |
60 |
|
|
|
61 |
TextToolItem supprimer = new TextToolItem("Supprimer");
|
|
|
62 |
supprimer.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
|
|
|
63 |
toolBar.add(supprimer);
|
239 |
aurelien |
64 |
supprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {
|
|
|
65 |
public void componentSelected(ComponentEvent ce) {
|
|
|
66 |
coelMediateur.clicSupprimerPublication(binder.getSelection());
|
|
|
67 |
}
|
|
|
68 |
});
|
106 |
aurelien |
69 |
|
|
|
70 |
setTopComponent(toolBar);
|
|
|
71 |
|
|
|
72 |
List<TableColumn> columns = new ArrayList<TableColumn>();
|
239 |
aurelien |
73 |
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
|
227 |
aurelien |
74 |
TableColumn auteurColonne = new TableColumn("fmt_auteur", "Auteur(s)", .2f);
|
|
|
75 |
auteurColonne.setRenderer(new CellRenderer() {
|
|
|
76 |
|
|
|
77 |
public String render(Component item, String property, Object value) {
|
|
|
78 |
// TODO Auto-generated method stub
|
|
|
79 |
return ((String)value).replaceAll("\\|", ", ");
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
});
|
|
|
83 |
columns.add(auteurColonne);
|
219 |
aurelien |
84 |
columns.add(new TableColumn("titre", "Titre", .15f));
|
|
|
85 |
columns.add(new TableColumn("fmt_nom_complet", "Nom de la revue", .15f));
|
|
|
86 |
columns.add(new TableColumn("ce_truk_editeur", "Editeur", .1f));
|
|
|
87 |
columns.add(new TableColumn("date_parution", "Date de parution", .1f));
|
|
|
88 |
columns.add(new TableColumn("indication_nvt", "Tome", .1f));
|
|
|
89 |
columns.add(new TableColumn("fascicule", "Fascicule", .1f));
|
|
|
90 |
columns.add(new TableColumn("truk_pages", "Pages", .1f));
|
106 |
aurelien |
91 |
|
|
|
92 |
TableColumnModel cm = new TableColumnModel(columns);
|
|
|
93 |
|
|
|
94 |
table = new Table(cm);
|
|
|
95 |
table.setSelectionMode(SelectionMode.MULTI);
|
|
|
96 |
table.setBorders(false);
|
|
|
97 |
|
|
|
98 |
add(table);
|
|
|
99 |
|
|
|
100 |
store = new ListStore<Publication>();
|
|
|
101 |
|
|
|
102 |
binder = new TableBinder<Publication>(table, store);
|
|
|
103 |
binder.setAutoSelect(true);
|
|
|
104 |
binder.addSelectionChangedListener(new SelectionChangedListener<Publication>() {
|
|
|
105 |
public void selectionChanged(SelectionChangedEvent<Publication> event) {
|
|
|
106 |
Publication m = (Publication) event.getSelectedItem();
|
|
|
107 |
clicListe(m);
|
|
|
108 |
}
|
|
|
109 |
});
|
|
|
110 |
|
|
|
111 |
setLayout(new FitLayout());
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
public ListStore<Publication> getStore() {
|
|
|
115 |
return store;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
public TableBinder<Publication> getBinder() {
|
|
|
119 |
return binder;
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
private void clicListe(Publication publication) {
|
|
|
123 |
coelMediateur.clicListePublication(publication);
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
public void rafraichir(Object nouvelleDonnees) {
|
|
|
127 |
if (nouvelleDonnees instanceof PublicationListe) {
|
|
|
128 |
PublicationListe listePublications = (PublicationListe) nouvelleDonnees;
|
|
|
129 |
setHeading("Publications");
|
|
|
130 |
|
|
|
131 |
List<Publication> liste = new ArrayList<Publication>();
|
|
|
132 |
for (Iterator<String> it = listePublications.keySet().iterator(); it.hasNext();) {
|
|
|
133 |
liste.add(listePublications.get(it.next()));
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
store.removeAll();
|
|
|
137 |
store.add((List<Publication>) liste);
|
|
|
138 |
|
|
|
139 |
// Test pour savoir si la liste contient des éléments
|
|
|
140 |
if (listePublications.size() > 0) {
|
|
|
141 |
binder.setSelection((Publication) listePublications.get(0));
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
}
|