Package org.exoplatform.navigation.webui

Examples of org.exoplatform.navigation.webui.TreeNode


    public static class SaveActionListener extends EventListener<UIPageNodeForm> {
        public void execute(Event<UIPageNodeForm> event) throws Exception {
            WebuiRequestContext ctx = event.getRequestContext();
            UIPageNodeForm uiPageNodeForm = event.getSource();
            UIApplication uiPortalApp = ctx.getUIApplication();
            TreeNode pageNode = uiPageNodeForm.getPageNode();
            boolean isVisible = uiPageNodeForm.getUICheckBoxInput(VISIBLE).isChecked();
            boolean isShowPubDate = uiPageNodeForm.getUICheckBoxInput(SHOW_PUBLICATION_DATE).isChecked();
            boolean isSystemVisibility = false;
            if (pageNode != null)
                isSystemVisibility = pageNode.getVisibility() == Visibility.SYSTEM;

            if (isVisible && isShowPubDate && !isSystemVisibility) {
                Calendar currentCalendar = Calendar.getInstance();
                currentCalendar.set(currentCalendar.get(Calendar.YEAR), currentCalendar.get(Calendar.MONTH),
                        currentCalendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
                Date currentDate = currentCalendar.getTime();

                Calendar startCalendar = uiPageNodeForm.getUIFormDateTimeInput(UIWizardPageSetInfo.START_PUBLICATION_DATE)
                        .getCalendar();
                Date startDate = startCalendar != null ? startCalendar.getTime() : currentDate;
                Calendar endCalendar = uiPageNodeForm.getUIFormDateTimeInput(UIWizardPageSetInfo.END_PUBLICATION_DATE)
                        .getCalendar();
                Date endDate = endCalendar != null ? endCalendar.getTime() : null;

                // Case 1: current date after start date
                if (currentDate.after(startDate)) {
                    Object[] args = {};
                    uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.currentDateBeforeStartDate", args,
                            ApplicationMessage.WARNING));
                    return;

                // Case 2: start date after end date
                } else if ((endCalendar != null) && (startCalendar != null) && (startDate.after(endDate))) {
                    Object[] args = {};
                    uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.startDateBeforeEndDate", args,
                            ApplicationMessage.WARNING));
                    return;

                // Case 3: start date is null and current date after end date
                } else if ((endCalendar != null) && (currentDate.after(endDate))) {
                    Object[] args = {};
                    uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.currentDateBeforeEndDate", args,
                            ApplicationMessage.WARNING));
                    return;
                }

            }

            UIFormStringInput nameInput = uiPageNodeForm.getUIStringInput("name");
            String nodeName = nameInput.getValue();

            TreeNode selectedParent = (TreeNode) uiPageNodeForm.getSelectedParent();
            if (pageNode == null && selectedParent.getChild(nodeName) != null) {
                uiPortalApp.addMessage(new ApplicationMessage("UIPageNodeForm.msg.SameName", null));
                return;
            }

            // Add node that need to be rebased to context
            if (pageNode == null) {
                pageNode = selectedParent.addChild(nodeName);
                uiPageNodeForm.pageNode_ = pageNode;
            }

            UIPageSelector pageSelector = uiPageNodeForm.getChild(UIPageSelector.class);
            if (pageSelector.getPage() == null) {
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.