60 |
jpm |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.Mediateur;
|
|
|
4 |
import org.tela_botanica.client.RegistreId;
|
|
|
5 |
import org.tela_botanica.client.modeles.Menu;
|
|
|
6 |
|
|
|
7 |
import com.extjs.gxt.ui.client.Events;
|
|
|
8 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
9 |
import com.extjs.gxt.ui.client.event.Listener;
|
|
|
10 |
import com.extjs.gxt.ui.client.event.TreeEvent;
|
|
|
11 |
import com.extjs.gxt.ui.client.util.TreeBuilder;
|
|
|
12 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
13 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
14 |
import com.extjs.gxt.ui.client.widget.tree.Tree;
|
|
|
15 |
import com.extjs.gxt.ui.client.widget.tree.TreeItem;
|
|
|
16 |
|
|
|
17 |
public class MenuPanneauVue extends ContentPanel {
|
|
|
18 |
|
|
|
19 |
private Tree tree;
|
|
|
20 |
|
|
|
21 |
public MenuPanneauVue() {
|
|
|
22 |
setBodyBorder(false);
|
|
|
23 |
setLayoutOnChange(true);
|
|
|
24 |
setHeading("Menu");
|
|
|
25 |
setLayout(new FitLayout());
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public void rafraichir(Object nouvelleDonnees) {
|
|
|
29 |
if (nouvelleDonnees instanceof Menu) {
|
|
|
30 |
afficherMenu((Menu) nouvelleDonnees);
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
private void afficherMenu(Menu menu) {
|
|
|
35 |
tree = new Tree();
|
|
|
36 |
tree.getStyle().setLeafIconStyle("tree-folder");
|
|
|
37 |
tree.addListener(Events.OnClick, new Listener<TreeEvent>(){
|
|
|
38 |
|
|
|
39 |
public void handleEvent(TreeEvent be) {
|
|
|
40 |
TreeItem f = tree.getSelectedItem();
|
|
|
41 |
selectionMenu(f.getText());
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
});
|
|
|
45 |
TreeBuilder.buildTree(tree, menu);
|
|
|
46 |
|
|
|
47 |
add(tree);
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
private void selectionMenu(String s) {
|
|
|
51 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu(s);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public Menu listerMenu() {
|
|
|
55 |
Menu menus = new Menu();
|
|
|
56 |
|
|
|
57 |
Menu menuInstitution = new Menu("Institutions");
|
|
|
58 |
Menu menuCollections = new Menu("Collections");
|
|
|
59 |
Menu menuPersonnes = new Menu("Personnes");
|
|
|
60 |
Menu menuPublications = new Menu("Publications");
|
|
|
61 |
|
|
|
62 |
menus.add(menuInstitution);
|
|
|
63 |
menus.add(menuCollections);
|
|
|
64 |
menus.add(menuPersonnes);
|
|
|
65 |
menus.add(menuPublications);
|
|
|
66 |
|
|
|
67 |
return menus;
|
|
|
68 |
}
|
|
|
69 |
}
|