Package org.apache.jetspeed.om.folder

Examples of org.apache.jetspeed.om.folder.MenuDefinition


    }

    protected void menuActions(String action, String name, SeparatorDefinitionBean element)
    {
        SiteTreeNode node = getUserSelectedNode();
        MenuDefinition definition = getMenuDefinition();
        MenuSeparatorDefinition oldElement = getSeparatorDefinition(element.getText());
        MenuSeparatorDefinition newElement = getSeparatorDefinition(element);
        if (node.getDocType() == FileType.Folder)
        {
            Folder folder = getJetspeedFolder(node.getNodePath());
            List menuList = folder.getMenuDefinitions();
            if (action.equals(SAVE_ACTION))
            {
                menuList.remove(definition);
                if(definition.getMenuElements()!=null)
                {
                    definition.getMenuElements().remove(oldElement);
                    definition.getMenuElements().add(newElement);
                }else{
                    List elements =  new ArrayList();
                    elements.add(newElement);
                    definition.setMenuElements(elements);
                }
                menuList.add(definition);
            }
            else if (action.equals(REMOVE_ACTION))
            {
                menuList.remove(definition);
                definition.getMenuElements().remove(oldElement);
                menuList.add(definition);
            }
            folder.setMenuDefinitions(menuList);
            folderAction(folder, SAVE_ACTION);
        }
        else if (node.getDocType() == FileType.Page)
        {
            Page page = getJetspeedPage(node.getNodePath());
            List menuList = page.getMenuDefinitions();
            if (action.equals(SAVE_ACTION))
            {
                menuList.remove(definition);
                if(definition.getMenuElements()!=null)
                {
                    definition.getMenuElements().remove(oldElement);
                    definition.getMenuElements().add(newElement);
                }else{
                    List elements =  new ArrayList();
                    elements.add(newElement);
                    definition.setMenuElements(elements);
                }
                menuList.add(definition);
            }
            else if (action.equals(REMOVE_ACTION))
            {
                menuList.remove(definition);
                definition.getMenuElements().remove(oldElement);
                menuList.add(definition);
            }
            page.setMenuDefinitions(menuList);
            PageAction(page, SAVE_ACTION);
        }
View Full Code Here


    }

    protected void menuActions(String action, String name, IncludesDefinitionBean element)
    {
        SiteTreeNode node = getUserSelectedNode();
        MenuDefinition definition = getMenuDefinition();
        MenuIncludeDefinition oldElement = getIncludesDefinition(name);
        MenuIncludeDefinition newElement = getIncludesDefinition(element);
        if (node.getDocType() == FileType.Folder)
        {
            Folder folder = getJetspeedFolder(node.getNodePath());
            List menuList = folder.getMenuDefinitions();
            if (action.equals(SAVE_ACTION))
            {
                menuList.remove(definition);
                if(definition.getMenuElements()!=null)
                {
                    definition.getMenuElements().remove(oldElement);
                    definition.getMenuElements().add(newElement);
                }else{
                    List elements =  new ArrayList();
                    elements.add(newElement);
                    definition.setMenuElements(elements);
                }
                menuList.add(definition);
            }
            else if (action.equals(REMOVE_ACTION))
            {
                menuList.remove(definition);
                definition.getMenuElements().remove(oldElement);
                menuList.add(definition);
            }
            folder.setMenuDefinitions(menuList);
            folderAction(folder, SAVE_ACTION);
        }
        else if (node.getDocType() == FileType.Page)
        {
            Page page = getJetspeedPage(node.getNodePath());
            List menuList = page.getMenuDefinitions();
            if (action.equals(SAVE_ACTION))
            {
                menuList.remove(definition);
                if(definition.getMenuElements()!=null)
                {
                    definition.getMenuElements().remove(oldElement);
                    definition.getMenuElements().add(newElement);
                }else{
                    List elements =  new ArrayList();
                    elements.add(newElement);
                    definition.setMenuElements(elements);
                }
                menuList.add(definition);
            }
            else if (action.equals(REMOVE_ACTION))
            {
                menuList.remove(definition);
                definition.getMenuElements().remove(oldElement);
                menuList.add(definition);
            }
            page.setMenuDefinitions(menuList);
            PageAction(page, SAVE_ACTION);
        }
View Full Code Here

    }

    protected void menuActions(String action, String name, ExcludesDefinitionBean element)
    {
        SiteTreeNode node = getUserSelectedNode();
        MenuDefinition definition = getMenuDefinition();
        MenuExcludeDefinition oldElement = getExcludeDefinition(name);
        MenuExcludeDefinition newElement = getExcludesDefinition(element);
        if (node.getDocType() == FileType.Folder)
        {
            Folder folder = getJetspeedFolder(node.getNodePath());
            List menuList = folder.getMenuDefinitions();
            if (action.equals(SAVE_ACTION))
            {
                menuList.remove(definition);
                if(definition.getMenuElements()!=null)
                {
                    definition.getMenuElements().remove(oldElement);
                    definition.getMenuElements().add(newElement);
                }else{
                    List elements =  new ArrayList();
                    elements.add(newElement);
                    definition.setMenuElements(elements);
                }
                menuList.add(definition);
            }
            else if (action.equals(REMOVE_ACTION))
            {
                menuList.remove(definition);
                definition.getMenuElements().remove(oldElement);
                menuList.add(definition);
            }
            folder.setMenuDefinitions(menuList);
            folderAction(folder, SAVE_ACTION);
        }
        else if (node.getDocType() == FileType.Page)
        {
            Page page = getJetspeedPage(node.getNodePath());
            List menuList = page.getMenuDefinitions();
            if (action.equals(SAVE_ACTION))
            {
                menuList.remove(definition);
                if(definition.getMenuElements()!=null)
                {
                    definition.getMenuElements().remove(oldElement);
                    definition.getMenuElements().add(newElement);
                }else{
                    List elements =  new ArrayList();
                    elements.add(newElement);
                    definition.setMenuElements(elements);
                }
                menuList.add(definition);
            }
            else if (action.equals(REMOVE_ACTION))
            {
                menuList.remove(definition);
                definition.getMenuElements().remove(oldElement);
                menuList.add(definition);
            }
            page.setMenuDefinitions(menuList);
            PageAction(page, SAVE_ACTION);
        }
View Full Code Here

        return null;
    }
   
    public MenuDefinition getDefinition(String name)
    {
        MenuDefinition definition = null;
        boolean found = true;
        try
        {
            if (document.getType().equals(PortalSiteManager.FOLDER_NODE_TYPE))
            {
View Full Code Here

    private MenuDefinition getMenu(List menuDefinitions,String name)
    {
        for (int index = 0; index < menuDefinitions.size(); index++)
        {
            MenuDefinition definition = (MenuDefinition) menuDefinitions.get(index);
            if (definition.getName().equals(name))
            {
                return definition;
            }
        }
        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
View Full Code Here

        return getServiceLocator().getPageManager().newFolderMenuDefinition();
    }
   
    private MenuDefinition getMenuDefinition(String type,JetspeedMenuDefinition menuDefinition)
    {       
        MenuDefinition definition = null;
        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
        {
            definition =  getServiceLocator().getPageManager().newPageMenuDefinition();
        }else{
            definition = getServiceLocator().getPageManager().newFolderMenuDefinition();   
        }
        definition.setDepth(menuDefinition.getDepth());
        definition.setName(menuDefinition.getName());
        definition.setOptions(menuDefinition.getOptions());
        definition.setOrder(menuDefinition.getOrder());
        definition.setPaths(menuDefinition.isPaths());
        definition.setRegexp(menuDefinition.isRegexp());
        definition.setTitle(menuDefinition.getTitle());
        definition.setShortTitle(menuDefinition.getShortTitle());
        definition.setSkin(menuDefinition.getSkin());
        definition.setProfile(menuDefinition.getProfile());       
        return definition;
    }
View Full Code Here

            add(new AjaxButton("newsave",new ResourceModel("add.menu"),menuForm)
            {
                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                {
                    MenuDefinition def = null;
                    if (getNodeType().equals(FOLDER_NODE_TYPE))
                    {
                        def = getServiceLocator().getPageManager().newFolderMenuDefinition();
                    }
                    else
View Full Code Here

        assertNotNull(folder);
        List menus = folder.getMenuDefinitions();
        assertNotNull(menus);
        assertEquals(5, menus.size());

        MenuDefinition simpleMenu = (MenuDefinition)menus.get(0);
        assertNotNull(simpleMenu);
        assertEquals("simple", simpleMenu.getName());
        assertNotNull(simpleMenu.getMenuElements());
        assertEquals(1, simpleMenu.getMenuElements().size());
        assertTrue(simpleMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
        assertEquals("/test001.psml,/folder1/folder2", ((MenuOptionsDefinition)simpleMenu.getMenuElements().get(0)).getOptions());

        MenuDefinition top2LevelsMenu = (MenuDefinition)menus.get(1);
        assertNotNull(top2LevelsMenu);
        assertEquals("top-2-levels", top2LevelsMenu.getName());
        assertNull(top2LevelsMenu.getMenuElements());
        assertEquals("/", top2LevelsMenu.getOptions());
        assertEquals(2, top2LevelsMenu.getDepth());
        assertEquals("dhtml-pull-down", top2LevelsMenu.getSkin());

        MenuDefinition topRolePagesMenu = (MenuDefinition)menus.get(2);
        assertNotNull(topRolePagesMenu);
        assertEquals("top-role-pages", topRolePagesMenu.getName());
        assertTrue(topRolePagesMenu.isRegexp());
        assertEquals("roles", topRolePagesMenu.getProfile());
        assertEquals("*.psml,*.link", topRolePagesMenu.getOrder());

        MenuDefinition breadCrumbsMenu = (MenuDefinition)menus.get(3);
        assertNotNull(breadCrumbsMenu);
        assertEquals("bread-crumbs", breadCrumbsMenu.getName());
        assertTrue(breadCrumbsMenu.isPaths());

        MenuDefinition topCustomMenu = (MenuDefinition)menus.get(4);
        assertNotNull(topCustomMenu);
        assertEquals("top-custom", topCustomMenu.getName());
        assertEquals("Top Menu", topCustomMenu.getTitle());
        assertEquals("Top", topCustomMenu.getShortTitle());
        assertEquals("Haut", topCustomMenu.getTitle(Locale.FRENCH));
        assertEquals("H", topCustomMenu.getShortTitle(Locale.FRENCH));
        assertNotNull(topCustomMenu.getMenuElements());
        assertEquals(5, topCustomMenu.getMenuElements().size());
        assertTrue(topCustomMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
        assertTrue(((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).isRegexp());
        assertEquals("groups", ((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).getProfile());
        assertTrue(topCustomMenu.getMenuElements().get(1) instanceof MenuDefinition);
        assertTrue(topCustomMenu.getMenuElements().get(2) instanceof MenuExcludeDefinition);
        assertEquals("top-role-pages", ((MenuExcludeDefinition)topCustomMenu.getMenuElements().get(2)).getName());
        assertTrue(topCustomMenu.getMenuElements().get(3) instanceof MenuSeparatorDefinition);
        assertEquals("More Top Pages", ((MenuSeparatorDefinition)topCustomMenu.getMenuElements().get(3)).getText());
        assertTrue(topCustomMenu.getMenuElements().get(4) instanceof MenuIncludeDefinition);
        assertEquals("simple", ((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).getName());
        assertTrue(((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).isNest());

        MenuDefinition topCustomNestedMenu = (MenuDefinition)topCustomMenu.getMenuElements().get(1);
        assertEquals("/", topCustomNestedMenu.getOptions());
        assertEquals("page", topCustomNestedMenu.getProfile());
        assertEquals(5, topCustomNestedMenu.getMenuElements().size());
        assertTrue(topCustomNestedMenu.getMenuElements().get(0) instanceof MenuSeparatorDefinition);
        assertEquals("Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText());
        assertEquals("Ye Olde Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText(Locale.ENGLISH));
        assertEquals("Select from Top Pages menu...", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle());
        assertEquals("Haut", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle(Locale.FRENCH));
        assertTrue(topCustomNestedMenu.getMenuElements().get(1) instanceof MenuOptionsDefinition);
        assertTrue(topCustomNestedMenu.getMenuElements().get(2) instanceof MenuSeparatorDefinition);
        assertEquals("bold", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getSkin());
        assertEquals("Custom Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getTitle());
        assertTrue(topCustomNestedMenu.getMenuElements().get(3) instanceof MenuOptionsDefinition);
        assertEquals(1, ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getDepth());
        assertEquals("*.psml", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getOrder());
        assertTrue(topCustomNestedMenu.getMenuElements().get(4) instanceof MenuOptionsDefinition);
        assertTrue(((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).isPaths());
        assertEquals("*", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getProfile());
        assertEquals("links", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getSkin());
        assertEquals("@", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getOptions());

        // test page resident menu definitions
        Page page = pageManager.getPage("/test001.psml");
        assertNotNull(page);
        menus = page.getMenuDefinitions();
        assertNotNull(menus);
        assertEquals(1, menus.size());

        simpleMenu = (MenuDefinition)menus.get(0);
        assertNotNull(simpleMenu);
        assertEquals("simple", simpleMenu.getName());
        assertNotNull(simpleMenu.getMenuElements());
        assertEquals(2, simpleMenu.getMenuElements().size());

        // test writing page menu definitions
        page = pageManager.getPage("/test002.psml");
        page.setMenuDefinitions(new ArrayList());
        MenuDefinition newMenu = page.newMenuDefinition();
        newMenu.setName("updated-menu");
        newMenu.setSkin("tabs");
        newMenu.setMenuElements(new ArrayList());
        MenuSeparatorDefinition newSeparator = page.newMenuSeparatorDefinition();
        newSeparator.setText("-- Updated Menu --");
        newMenu.getMenuElements().add(newSeparator);
        MenuOptionsDefinition newOptions0 = page.newMenuOptionsDefinition();
        newOptions0.setOptions("/*.psml");
        newOptions0.setRegexp(true);
        newMenu.getMenuElements().add(newOptions0);
        MenuOptionsDefinition newOptions1 = page.newMenuOptionsDefinition();
        newOptions1.setOptions("/folder0");
        newMenu.getMenuElements().add(newOptions1);
        MenuDefinition newNestedMenu = page.newMenuDefinition();
        newNestedMenu.setOptions("/*/");
        newNestedMenu.setRegexp(true);
        newMenu.getMenuElements().add(newNestedMenu);
        MenuExcludeDefinition newExcludeMenu = page.newMenuExcludeDefinition();
        newExcludeMenu.setName("exclude-menu");
        newMenu.getMenuElements().add(newExcludeMenu);
        MenuIncludeDefinition newIncludeMenu = page.newMenuIncludeDefinition();
View Full Code Here

                        }
                    }
                    else if (menuElement instanceof MenuDefinition)
                    {
                        // construct nested menu element from definition
                        MenuDefinition menuDefinition = (MenuDefinition)menuElement;
                        MenuImpl nestedMenu = new MenuImpl(view, this, menuDefinition, path, context, menus);

                        // append menu element to current separated elements list
                        if (separatedElements == null)
                        {
View Full Code Here

                // with no paths expansion, (negative depth values are
                // interpreted as complete menu expansion)
                if ((elementView instanceof Folder) && ((depth < 0) || (depth > 1)) && !paths)
                {
                    // construct menu definition and associated menu
                    MenuDefinition nestedMenuDefinition = new DefaultMenuDefinition(elementView.getUrl(), depth - 1, locatorName);
                    menuElement = new MenuImpl(view, this, nestedMenuDefinition, null, context, null);
                }
                else
                {
                    // construct shared default menu option definition and menu option
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.folder.MenuDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.