Search in sources :

Example 16 with UIModeList

use of org.alfresco.web.ui.common.component.UIModeList in project acs-community-packaging by Alfresco.

the class ForumsBean method topicViewModeChanged.

/**
 * Change the current topic view mode based on user selection
 *
 * @param event      ActionEvent
 */
public void topicViewModeChanged(ActionEvent event) {
    UIModeList viewList = (UIModeList) event.getComponent();
    // get the view mode ID
    String viewMode = viewList.getValue().toString();
    // push the view mode into the lists
    setTopicViewMode(viewMode);
    // change the default page size if necessary
    this.topicPageSize = this.viewsConfig.getDefaultPageSize(PAGE_NAME_TOPIC, this.topicViewMode);
    if (logger.isDebugEnabled())
        logger.debug("Set default topic page size to: " + this.topicPageSize);
}
Also used : UIModeList(org.alfresco.web.ui.common.component.UIModeList)

Example 17 with UIModeList

use of org.alfresco.web.ui.common.component.UIModeList in project acs-community-packaging by Alfresco.

the class ForumsBean method forumsViewModeChanged.

// ------------------------------------------------------------------------------
// Navigation action event handlers
/**
 * Change the current forums view mode based on user selection
 *
 * @param event      ActionEvent
 */
public void forumsViewModeChanged(ActionEvent event) {
    UIModeList viewList = (UIModeList) event.getComponent();
    // get the view mode ID
    String viewMode = viewList.getValue().toString();
    // push the view mode into the lists
    setForumsViewMode(viewMode);
    // get the default for the forum page
    this.forumsPageSize = this.viewsConfig.getDefaultPageSize(PAGE_NAME_FORUMS, this.forumsViewMode);
    if (logger.isDebugEnabled())
        logger.debug("Set default forums page size to: " + this.forumsPageSize);
}
Also used : UIModeList(org.alfresco.web.ui.common.component.UIModeList)

Example 18 with UIModeList

use of org.alfresco.web.ui.common.component.UIModeList in project acs-community-packaging by Alfresco.

the class GroupsDialog method filterModeChanged.

public void filterModeChanged(ActionEvent event) {
    UIModeList filterList = (UIModeList) event.getComponent();
    // update list filter mode from user selection
    setFilterMode(filterList.getValue().toString());
}
Also used : UIModeList(org.alfresco.web.ui.common.component.UIModeList)

Example 19 with UIModeList

use of org.alfresco.web.ui.common.component.UIModeList in project acs-community-packaging by Alfresco.

the class ModeListRenderer method encodeChildren.

/**
 * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
    if (!component.isRendered()) {
        return;
    }
    UIModeList list = (UIModeList) component;
    ResponseWriter out = context.getResponseWriter();
    // get the child components
    for (Iterator i = list.getChildren().iterator(); i.hasNext(); ) /**/
    {
        UIComponent child = (UIComponent) i.next();
        if (child instanceof UIListItems) {
            // get the value of the list items component and iterate
            // through it's collection
            Object listItems = ((UIListItems) child).getValue();
            if (listItems instanceof Collection) {
                Iterator iter = ((Collection) listItems).iterator();
                while (iter.hasNext()) {
                    UIListItem item = (UIListItem) iter.next();
                    if (item.isRendered()) {
                        renderItem(context, out, list, item);
                    }
                }
            }
        } else if (child instanceof UIListItem && child.isRendered()) {
            // found a valid UIListItem child to render
            renderItem(context, out, list, (UIListItem) child);
        }
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) UIListItem(org.alfresco.web.ui.common.component.UIListItem) Iterator(java.util.Iterator) UIComponent(javax.faces.component.UIComponent) UIListItems(org.alfresco.web.ui.common.component.UIListItems) UIModeList(org.alfresco.web.ui.common.component.UIModeList) Collection(java.util.Collection)

Example 20 with UIModeList

use of org.alfresco.web.ui.common.component.UIModeList in project acs-community-packaging by Alfresco.

the class ModeListRenderer method encodeBegin.

/**
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    if (component.isRendered() == false) {
        return;
    }
    UIModeList list = (UIModeList) component;
    ResponseWriter out = context.getResponseWriter();
    Map attrs = list.getAttributes();
    if (!list.isMenu()) {
        // start outer table container the list items
        out.write("<table cellspacing='1' cellpadding='0'");
        outputAttribute(out, attrs.get("styleClass"), "class");
        outputAttribute(out, attrs.get("style"), "style");
        outputAttribute(out, attrs.get("width"), "width");
        out.write('>');
        // horizontal rendering outputs a single row with each item as a column cell
        if (list.isHorizontal()) {
            out.write("<tr>");
        }
        // output title row if present
        if (list.getLabel() != null) {
            // first column contains an icon if present, second column contains text
            if (!list.isHorizontal()) {
                out.write("<tr>");
            }
            out.write("<td><table cellpadding='0' style='width:100%;'");
            outputAttribute(out, attrs.get("itemSpacing"), "cellspacing");
            out.write("><tr>");
            // output icon column
            if (list.getIconColumnWidth() != 0) {
                out.write("<td style='width:");
                out.write(String.valueOf(list.getIconColumnWidth()));
                out.write("px'></td>");
            }
            // output title label
            out.write("<td><span");
            outputAttribute(out, attrs.get("labelStyle"), "style");
            outputAttribute(out, attrs.get("labelStyleClass"), "class");
            out.write('>');
            out.write(Utils.encode(list.getLabel()));
            out.write("</span></td></tr></table></td>");
            if (!list.isHorizontal()) {
                out.write("</tr>");
            }
        }
    } else {
        // render as a pop-up menu
        // TODO: show the image set for the individual item if available?
        out.write("<table cellspacing='0' cellpadding='0' style='white-space:nowrap'><tr>");
        String selectedImage = (String) attrs.get("selectedImage");
        if (selectedImage != null) {
            out.write("<td style='padding-right:4px'>");
            out.write(Utils.buildImageTag(context, selectedImage, null, "middle"));
            out.write("</td>");
        }
        String menuId = UIMenu.getNextMenuId(list, context);
        out.write("<td style='white-space: nowrap;'><a href='#' onclick=\"javascript:_toggleMenu(event, '");
        out.write(menuId);
        out.write("');return false;\">");
        // use default label if available
        String label = list.getLabel();
        if (label == null || label.length() == 0) {
            // else get the child components and walk to find the selected
            for (Iterator i = list.getChildren().iterator(); i.hasNext(); ) /**/
            {
                UIComponent child = (UIComponent) i.next();
                if (child instanceof UIListItems) {
                    // get the value of the list items component and iterate
                    // through it's collection
                    Object listItems = ((UIListItems) child).getValue();
                    if (listItems instanceof Collection) {
                        Iterator iter = ((Collection) listItems).iterator();
                        while (iter.hasNext()) {
                            UIListItem item = (UIListItem) iter.next();
                            // if selected render as the label
                            if (item.getValue().equals(list.getValue())) {
                                label = item.getLabel();
                                break;
                            }
                        }
                    }
                } else if (child instanceof UIListItem && child.isRendered()) {
                    // found a valid UIListItem child to render
                    UIListItem item = (UIListItem) child;
                    // if selected render as the label
                    if (item.getValue().equals(list.getValue())) {
                        label = item.getLabel();
                        break;
                    }
                }
            }
        }
        // render the label
        if (label != null && label.length() != 0) {
            out.write("<span");
            outputAttribute(out, attrs.get("labelStyle"), "style");
            outputAttribute(out, attrs.get("labelStyleClass"), "class");
            out.write('>');
            out.write(Utils.encode(label));
            out.write("</span>&nbsp;");
        }
        // output image
        if (list.getMenuImage() != null) {
            out.write(Utils.buildImageTag(context, list.getMenuImage(), null, "-4px"));
        }
        out.write("</a></td></tr></table>");
        // output the hidden DIV section to contain the menu item table
        out.write("<div id='");
        out.write(menuId);
        out.write("' style='position:absolute;display:none;padding-left:2px;'>");
        // start outer table container the list items
        out.write("<table cellspacing='1' cellpadding='0'");
        outputAttribute(out, attrs.get("styleClass"), "class");
        outputAttribute(out, attrs.get("style"), "style");
        outputAttribute(out, attrs.get("width"), "width");
        out.write('>');
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) UIListItem(org.alfresco.web.ui.common.component.UIListItem) Iterator(java.util.Iterator) UIComponent(javax.faces.component.UIComponent) UIListItems(org.alfresco.web.ui.common.component.UIListItems) UIModeList(org.alfresco.web.ui.common.component.UIModeList) Collection(java.util.Collection) Map(java.util.Map)

Aggregations

UIModeList (org.alfresco.web.ui.common.component.UIModeList)20 ResponseWriter (javax.faces.context.ResponseWriter)5 UIComponent (javax.faces.component.UIComponent)3 UIListItems (org.alfresco.web.ui.common.component.UIListItems)3 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 FacesContext (javax.faces.context.FacesContext)2 UIListItem (org.alfresco.web.ui.common.component.UIListItem)2 Map (java.util.Map)1 MethodBinding (javax.faces.el.MethodBinding)1 ValueBinding (javax.faces.el.ValueBinding)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)1 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)1