Package org.exoplatform.navigation.webui

Examples of org.exoplatform.navigation.webui.TreeNode


            WebuiRequestContext context = event.getRequestContext();
            UIRightClickPopupMenu popupMenu = event.getSource();
            UINavigationNodeSelector uiNodeSelector = popupMenu.getAncestorOfType(UINavigationNodeSelector.class);

            String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
            TreeNode node = uiNodeSelector.findNode(nodeID);
            try {
                node = rebaseNode(node, uiNodeSelector);
                if (node == null)
                    return;
            } catch (NavigationServiceException ex) {
                handleError(ex.getError(), uiNodeSelector);
                return;
            }

            UIApplication uiApp = context.getUIApplication();
            UserPortalConfigService service = uiApp.getApplicationComponent(UserPortalConfigService.class);
            String pageId = node.getPageRef();
            // Page page = (pageId != null) ? service.getPage(pageId) : null;
            PageContext page = (pageId != null) ? service.getPageService().loadPage(PageKey.parse(pageId)) : null;
            if (page != null) {
                UserACL userACL = uiApp.getApplicationComponent(UserACL.class);
                if (!userACL.hasPermission(page)) {
                    uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.UserNotPermission", new String[] { pageId }, 1));
                    return;
                }
            }

            if (node.getI18nizedLabels() == null) {
                uiNodeSelector.invokeI18NizedLabels(node);
            }

            UIPopupWindow uiManagementPopup = uiNodeSelector.getAncestorOfType(UIPopupWindow.class);
            UIPageNodeForm uiNodeForm = uiApp.createUIComponent(UIPageNodeForm.class, null, null);
            uiManagementPopup.setUIComponent(uiNodeForm);

            UserNavigation edittedNav = uiNodeSelector.getEdittedNavigation();
            uiNodeForm.setContextPageNavigation(edittedNav);
            uiNodeForm.setValues(node);
            uiNodeForm.setSelectedParent(node.getParent());
            uiManagementPopup.setWindowSize(800, 500);
            event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());
        }
View Full Code Here


            WebuiRequestContext context = event.getRequestContext();
            UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
            event.getRequestContext().addUIComponentToUpdateByAjax(uiNodeSelector);

            String nodeID = context.getRequestParameter(UIComponent.OBJECTID);
            TreeNode node = uiNodeSelector.findNode(nodeID);
            if (Visibility.SYSTEM.equals(node.getVisibility())) {
                UIApplication uiApp = context.getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-copyclone", null));
                return;
            }
            try {
                node = rebaseNode(node, Scope.ALL, uiNodeSelector);
                if (node == null)
                    return;
            } catch (NavigationServiceException ex) {
                handleError(ex.getError(), uiNodeSelector);
                return;
            }

            node.setDeleteNode(false);
            if (node.getI18nizedLabels() == null) {
                uiNodeSelector.invokeI18NizedLabels(node);
            }
            uiNodeSelector.setCopyNode(node);
            event.getSource().setActions(
                    new String[] { "AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
View Full Code Here

            WebuiRequestContext context = event.getRequestContext();
            UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
            context.addUIComponentToUpdateByAjax(uiNodeSelector);

            String nodeID = context.getRequestParameter(UIComponent.OBJECTID);
            TreeNode node = uiNodeSelector.findNode(nodeID);
            try {
                node = rebaseNode(node, Scope.SINGLE, uiNodeSelector);
                if (node == null)
                    return;
            } catch (NavigationServiceException ex) {
                handleError(ex.getError(), uiNodeSelector);
                return;
            }

            if (node != null && Visibility.SYSTEM.equals(node.getVisibility())) {
                context.getUIApplication().addMessage(
                        new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
                return;
            }

            node.setDeleteNode(true);
            uiNodeSelector.setCopyNode(node);
            event.getSource().setActions(
                    new String[] { "AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
                            "PasteNode", "DeleteNode", "MoveUp", "MoveDown" });
        }
View Full Code Here

    public static class CloneNodeActionListener extends CopyNodeActionListener {
        public void execute(Event<UIRightClickPopupMenu> event) throws Exception {
            super.execute(event);
            UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
            TreeNode currNode = uiNodeSelector.getCopyNode();
            String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
            if (currNode == null)
                return;
            else if (currNode.getId().equals(nodeID))
                currNode.setCloneNode(true);

            if (currNode.getI18nizedLabels() == null) {
                uiNodeSelector.invokeI18NizedLabels(currNode);
            }
        }
View Full Code Here

            UIRightClickPopupMenu uiPopupMenu = event.getSource();
            uiNodeSelector = uiPopupMenu.getAncestorOfType(UINavigationNodeSelector.class);
            context.addUIComponentToUpdateByAjax(uiNodeSelector);

            String nodeID = context.getRequestParameter(UIComponent.OBJECTID);
            TreeNode targetNode = uiNodeSelector.findNode(nodeID);
            TreeNode sourceNode = uiNodeSelector.getCopyNode();
            if (sourceNode == null)
                return;

            try {
                targetNode = rebaseNode(targetNode, uiNodeSelector);
                if (targetNode == null)
                    return;
            } catch (NavigationServiceException ex) {
                handleError(ex.getError(), uiNodeSelector);
                return;
            }

            if (sourceNode.getId().equals(targetNode.getId())) {
                context.getUIApplication().addMessage(
                        new ApplicationMessage("UIPageNodeSelector.msg.paste.sameSrcAndDes", null));
                return;
            }

            if (isExistChild(targetNode, sourceNode)) {
                context.getUIApplication().addMessage(new ApplicationMessage("UIPageNodeSelector.msg.paste.sameName", null));
                return;
            }

            if(isExistsInTree(sourceNode, targetNode)) {
                context.getUIApplication().addMessage(new ApplicationMessage("UIPageNodeSelector.msg.paste.wrongLocation", null, ApplicationMessage.WARNING));
                return;
            }

            UITree uitree = uiNodeSelector.getChild(UITree.class);
            UIRightClickPopupMenu popup = uitree.getUIRightClickPopupMenu();
            popup.setActions(new String[] { "AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CutNode", "CloneNode",
                    "DeleteNode", "MoveUp", "MoveDown" });
            uiNodeSelector.setCopyNode(null);

            if (uiNodeSelector.findNode(sourceNode.getId()) == null) {
                context.getUIApplication().addMessage(
                        new ApplicationMessage("UINavigationNodeSelector.msg.copiedNode.deleted", null,
                                ApplicationMessage.WARNING));
                uiNodeSelector.selectNode(uiNodeSelector.getRootNode());
                return;
            }

            if (sourceNode.isDeleteNode()) {
                targetNode.addChild(sourceNode);
                uiNodeSelector.selectNode(targetNode);
                return;
            }

            pageService = uiNodeSelector.getApplicationComponent(PageService.class);
            pasteNode(sourceNode, targetNode, sourceNode.isCloneNode());
            uiNodeSelector.selectNode(targetNode);
        }
View Full Code Here

            pasteNode(sourceNode, targetNode, sourceNode.isCloneNode());
            uiNodeSelector.selectNode(targetNode);
        }

        private TreeNode pasteNode(TreeNode sourceNode, TreeNode parent, boolean isClone) throws Exception {
            TreeNode node = parent.addChild(sourceNode.getName());
            node.setLabel(sourceNode.getLabel());
            node.setVisibility(sourceNode.getVisibility());
            node.setIcon(sourceNode.getIcon());
            node.setStartPublicationTime(sourceNode.getStartPublicationTime());
            node.setEndPublicationTime(sourceNode.getEndPublicationTime());

            if (isClone) {
                String pageName = "page" + node.hashCode();
                node.setPageRef(clonePageFromNode(sourceNode, pageName, sourceNode.getPageNavigation().getKey()));
            } else {
                node.setPageRef(sourceNode.getPageRef());
            }

            for (TreeNode child : sourceNode.getChildren()) {
                pasteNode(child, node, isClone);
            }

            node.setI18nizedLabels(sourceNode.getI18nizedLabels());
            uiNodeSelector.getUserNodeLabels().put(node.getId(), node.getI18nizedLabels());
            return node;
        }
View Full Code Here

        private boolean isExistsInTree(TreeNode parent, TreeNode child) {
            if(parent == null || child == null) {
                return false;
            }
            TreeNode p = child.getParent();
            while (p != null) {
                if(parent.getId().equals(p.getId())) {
                    return true;
                }
                p = p.getParent();
            }
            return false;
        }
View Full Code Here

            WebuiRequestContext context = event.getRequestContext();
            UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
            context.addUIComponentToUpdateByAjax(uiNodeSelector.getParent());

            String nodeID = context.getRequestParameter(UIComponent.OBJECTID);
            TreeNode targetNode = uiNodeSelector.findNode(nodeID);
            // This happen when browser's not sync with server
            if (targetNode == null)
                return;

            TreeNode parentNode = targetNode.getParent();
            try {
                parentNode = rebaseNode(parentNode, uiNodeSelector);
                if (parentNode == null)
                    return;
                // After update the parentNode, maybe targetNode has been deleted or moved
                TreeNode temp = parentNode.getChild(targetNode.getName());
                if (temp == null || !temp.getId().equals(targetNode.getId())) {
                    context.getUIApplication().addMessage(
                            new ApplicationMessage("UINavigationNodeSelector.msg.staleData", null, ApplicationMessage.WARNING));
                    uiNodeSelector.selectNode(uiNodeSelector.getRootNode());
                    context.addUIComponentToUpdateByAjax(uiNodeSelector);
                    return;
                }
            } catch (NavigationServiceException ex) {
                handleError(ex.getError(), uiNodeSelector);
                return;
            }

            Collection<TreeNode> children = parentNode.getChildren();

            int k;
            for (k = 0; k < children.size(); k++) {
                if (parentNode.getChild(k).getId().equals(targetNode.getId())) {
                    break;
                }
            }

            if (k == 0 && i == -1) {
                return;
            }
            if (k == children.size() - 1 && i == 2) {
                return;
            }

            parentNode.addChild(k + i, targetNode);

            // These lines help to refresh the tree
            TreeNode selectedNode = uiNodeSelector.getSelectedNode();
            uiNodeSelector.selectNode(parentNode);
            uiNodeSelector.selectNode(selectedNode);
        }
View Full Code Here

            WebuiRequestContext pcontext = event.getRequestContext();
            UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
            pcontext.addUIComponentToUpdateByAjax(uiNodeSelector);

            String nodeID = pcontext.getRequestParameter(UIComponent.OBJECTID);
            TreeNode childNode = uiNodeSelector.findNode(nodeID);
            if (childNode == null) {
                return;
            }
            TreeNode parentNode = childNode.getParent();

            if (Visibility.SYSTEM.equals(childNode.getVisibility())) {
                UIApplication uiApp = pcontext.getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-delete", null));
                return;
            }
            uiNodeSelector.getUserNodeLabels().remove(childNode.getId());
            parentNode.removeChild(childNode);
            uiNodeSelector.selectNode(parentNode);
        }
View Full Code Here

        if (edittedNavigation == null || userPortal == null) {
            throw new IllegalStateException("edittedNavigation and userPortal must be initialized first");
        }

        try {
            this.rootNode = new TreeNode(edittedNavigation, userPortal.getNode(edittedNavigation, navigationScope,
                    filterConfig, null));

            TreeNode node = this.rootNode;
            if (this.rootNode.getChildren().size() > 0) {
                node = rebaseNode(this.rootNode.getChild(0), navigationScope);
                if (node == null) {
                    initTreeData();
                    return;
View Full Code Here

TOP

Related Classes of org.exoplatform.navigation.webui.TreeNode

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.