Search in sources :

Example 1 with NavigatorPluginBean

use of org.alfresco.web.bean.ajax.NavigatorPluginBean in project acs-community-packaging by Alfresco.

the class UINavigator method encodeBegin.

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    // TODO: pull width and height from user preferences and/or the main config,
    // if present override below using the style attribute
    ResponseWriter out = context.getResponseWriter();
    NavigationBean navBean = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
    NavigatorPluginBean navPluginBean = (NavigatorPluginBean) FacesHelper.getManagedBean(context, NavigatorPluginBean.BEAN_NAME);
    List<TreeNode> rootNodesForArea = null;
    String area = this.getActiveArea();
    String areaTitle = null;
    boolean treePanel = true;
    if (NavigationBean.LOCATION_COMPANY.equals(area)) {
        rootNodesForArea = navPluginBean.getCompanyHomeRootNodes();
        areaTitle = Application.getMessage(context, NavigationBean.MSG_COMPANYHOME);
    } else if (NavigationBean.LOCATION_HOME.equals(area)) {
        rootNodesForArea = navPluginBean.getMyHomeRootNodes();
        areaTitle = Application.getMessage(context, NavigationBean.MSG_MYHOME);
    } else if (NavigationBean.LOCATION_GUEST.equals(area)) {
        rootNodesForArea = navPluginBean.getGuestHomeRootNodes();
        areaTitle = Application.getMessage(context, NavigationBean.MSG_GUESTHOME);
    } else {
        treePanel = false;
        areaTitle = Application.getMessage(context, NavigationBean.MSG_MYALFRESCO);
    }
    // order the root nodes by the tree label
    if (rootNodesForArea != null && rootNodesForArea.size() > 1) {
        QuickSort sorter = new QuickSort(rootNodesForArea, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    // main container div
    out.write("<div id=\"navigator\" class=\"navigator\">");
    // generate the active panel title
    String cxPath = context.getExternalContext().getRequestContextPath();
    out.write("<div class=\"sidebarButtonSelected\" style=\"background-image: url(" + cxPath + "/images/parts/navigator_blue_gradient_bg.gif)\">");
    out.write("<a class='sidebarButtonSelectedLink' onclick=\"");
    out.write(Utils.generateFormSubmit(context, this, getClientId(context), PANEL_ACTION + area));
    out.write("\" href=\"#\">");
    out.write(Utils.encode(areaTitle));
    out.write("</a></div>");
    // generate the javascript method to capture the tree node click events
    if (treePanel) {
        out.write("<script type=\"text/javascript\">");
        out.write("function treeNodeSelected(nodeRef) {");
        out.write(Utils.generateFormSubmit(context, this, getClientId(context), "nodeRef", true, null));
        out.write("}</script>");
        // generate the active panel containing the tree
        out.write("<div class=\"navigatorPanelBody\">");
        UITree tree = (UITree) context.getApplication().createComponent(UITree.COMPONENT_TYPE);
        tree.setId("tree");
        tree.setRootNodes(rootNodesForArea);
        tree.setRetrieveChildrenUrl(AJAX_URL_START + ".retrieveChildren?area=" + area);
        tree.setNodeCollapsedUrl(AJAX_URL_START + ".nodeCollapsed?area=" + area);
        tree.setNodeSelectedCallback("treeNodeSelected");
        tree.setNodeCollapsedCallback("informOfCollapse");
        Utils.encodeRecursive(context, tree);
        out.write("</div>");
    }
    // generate the closed panel title areas
    String sideBarStyle = "style=\"background-image: url(" + cxPath + "/images/parts/navigator_grey_gradient_bg.gif)\"";
    if (NavigationBean.LOCATION_COMPANY.equals(area) == false && navBean.getCompanyHomeVisible()) {
        encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_COMPANY, NavigationBean.MSG_COMPANYHOME);
    }
    if (NavigationBean.LOCATION_HOME.equals(area) == false) {
        encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_HOME, NavigationBean.MSG_MYHOME);
    }
    if (NavigationBean.LOCATION_GUEST.equals(area) == false && navBean.getIsGuest() == false && navBean.getGuestHomeVisible()) {
        encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_GUEST, NavigationBean.MSG_GUESTHOME);
    }
    if (NavigationBean.LOCATION_MYALFRESCO.equals(area) == false) {
        encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_MYALFRESCO, NavigationBean.MSG_MYALFRESCO);
    }
    out.write("</div>");
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) ResponseWriter(javax.faces.context.ResponseWriter) NavigationBean(org.alfresco.web.bean.NavigationBean) TreeNode(org.alfresco.web.ui.repo.component.UITree.TreeNode) NavigatorPluginBean(org.alfresco.web.bean.ajax.NavigatorPluginBean)

Aggregations

ResponseWriter (javax.faces.context.ResponseWriter)1 NavigationBean (org.alfresco.web.bean.NavigationBean)1 NavigatorPluginBean (org.alfresco.web.bean.ajax.NavigatorPluginBean)1 QuickSort (org.alfresco.web.data.QuickSort)1 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)1