Subversion Repositories eFlore/Applications.coel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
69 jpm 57
		Menu accueilMenu = new Menu("Accueil");
58
		Menu projetMenu = new Menu("Projets");
60 jpm 59
	    Menu menuInstitution = new Menu("Institutions");
60
	    Menu menuCollections = new Menu("Collections");
61
	    Menu menuPersonnes = new Menu("Personnes");
62
	    Menu menuPublications = new Menu("Publications");
63
 
69 jpm 64
	    menus.add(accueilMenu);
65
	    menus.add(projetMenu);
60 jpm 66
	    menus.add(menuInstitution);
67
	    menus.add(menuCollections);
68
	    menus.add(menuPersonnes);
69
	    menus.add(menuPublications);
70
 
71
	    return menus;
72
	}
73
}