Subversion Repositories eFlore/Applications.coel

Rev

Rev 69 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.vues;

import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.modeles.Menu;

import com.extjs.gxt.ui.client.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TreeEvent;
import com.extjs.gxt.ui.client.util.TreeBuilder;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.tree.Tree;
import com.extjs.gxt.ui.client.widget.tree.TreeItem;

public class MenuPanneauVue extends ContentPanel {

        private Tree tree;
                
        public MenuPanneauVue() {
                setBodyBorder(false);
                setLayoutOnChange(true);
                setHeading("Menu");
                setLayout(new FitLayout());
        }

        public void rafraichir(Object nouvelleDonnees) {
                if (nouvelleDonnees instanceof Menu) {
                        afficherMenu((Menu) nouvelleDonnees);
                }
        }

        private void afficherMenu(Menu menu) {
                tree = new Tree();
                tree.getStyle().setLeafIconStyle("tree-folder");
                tree.addListener(Events.OnClick, new Listener<TreeEvent>(){

                        public void handleEvent(TreeEvent be) {
                                TreeItem f = tree.getSelectedItem();
                                selectionMenu(f.getText());
                        }
                        
                });
                TreeBuilder.buildTree(tree, menu);
                                
                add(tree);
        }
        
        private void selectionMenu(String s) {
                ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu(s);
        }
        
        public Menu listerMenu() {
                Menu menus = new Menu();
                
            Menu menuInstitution = new Menu("Institutions");
            Menu menuCollections = new Menu("Collections");
            Menu menuPersonnes = new Menu("Personnes");
            Menu menuPublications = new Menu("Publications");
            
            menus.add(menuInstitution);
            menus.add(menuCollections);
            menus.add(menuPersonnes);
            menus.add(menuPublications);
            
            return menus;
        }
}