use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class DashboardWizard method buildLayoutValueLists.
/**
* Build the cached list of values for the layout page. The lists are used by the
* image radio picker and dynamic description components.
*/
private void buildLayoutValueLists() {
List<UIListItem> icons = new ArrayList<UIListItem>(4);
List<UIDescription> descriptions = new ArrayList<UIDescription>(4);
FacesContext context = FacesContext.getCurrentInstance();
DashboardsConfigElement config = DashboardManager.getDashboardConfig();
Iterator<LayoutDefinition> layoutItr = config.getLayouts().iterator();
while (layoutItr.hasNext()) {
LayoutDefinition layoutDef = layoutItr.next();
// build UIListItem to represent the layout image
String label = layoutDef.Label;
if (label == null) {
label = Application.getMessage(context, layoutDef.LabelId);
}
String desc = layoutDef.Description;
if (desc == null) {
desc = Application.getMessage(context, layoutDef.DescriptionId);
}
UIListItem item = new UIListItem();
item.setLabel(label);
item.setTooltip(desc);
item.setValue(layoutDef.Id);
item.setImage(layoutDef.Image);
icons.add(item);
// build UIDescription to represent the layout description text
UIDescription description = new UIDescription();
description.setControlValue(layoutDef.Id);
description.setText(desc);
descriptions.add(description);
}
this.layoutIcons = icons;
this.layoutDescriptions = descriptions;
}
use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class GroupsDialog method getFilterItems.
// ------------------------------------------------------------------------------
// FilterViewSupport implementation
public List<UIListItem> getFilterItems() {
FacesContext context = FacesContext.getCurrentInstance();
List<UIListItem> items = new ArrayList<UIListItem>(2);
UIListItem item1 = new UIListItem();
item1.setValue(FILTER_CHILDREN);
item1.setLabel(Application.getMessage(context, LABEL_FILTER_CHILDREN));
items.add(item1);
UIListItem item2 = new UIListItem();
item2.setValue(FILTER_ALL);
item2.setLabel(Application.getMessage(context, LABEL_FILTER_ALL));
items.add(item2);
return items;
}
use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class ImagePickerRadioRenderer method encodeChildren.
/**
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@SuppressWarnings("unchecked")
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
if (component.isRendered() == false) {
return;
}
UIImagePicker imagePicker = (UIImagePicker) component;
Map attrs = imagePicker.getAttributes();
Integer cols = (Integer) attrs.get("columns");
if (cols != null && cols instanceof Integer) {
this.columns = cols.intValue();
}
// retrieve the onclick handler, if there is one
String onclick = (String) attrs.get("onclick");
ResponseWriter out = context.getResponseWriter();
// determine whether the options should be pulled from config or
// from the child components
String configSection = (String) attrs.get("configSection");
if (configSection != null && configSection.length() > 0) {
// render all the icons from the list that appear in the given
// config section
ConfigService cfgService = Application.getConfigService(context);
Config cfg = cfgService.getConfig(configSection);
if (cfg != null) {
ConfigElement iconsCfg = cfg.getConfigElement("icons");
if (iconsCfg != null) {
for (ConfigElement icon : iconsCfg.getChildren()) {
String iconName = icon.getAttribute("name");
String iconPath = icon.getAttribute("path");
if (iconName != null && iconPath != null) {
UIListItem item = new UIListItem();
item.setValue(iconName);
item.setImage(iconPath);
renderItem(context, out, imagePicker, item, onclick);
}
}
}
}
} else {
try {
// get the child components
for (Iterator i = imagePicker.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, imagePicker, item, onclick);
}
}
}
} else if (child instanceof UIListItem && child.isRendered() == true) {
// found a valid UIListItem child to render
UIListItem item = (UIListItem) child;
renderItem(context, out, imagePicker, item, onclick);
}
}
} catch (PropertyNotFoundException pnfe) {
// method specified in the value binding expression
if (logger.isWarnEnabled())
logger.warn("Failed to retrieve icons: " + pnfe.toString());
out.write(Application.getMessage(context, "no_icons_found"));
}
}
// if we are in the middle of a row, close it
if (open) {
out.write("</tr>\n");
}
}
use of org.alfresco.web.ui.common.component.UIListItem 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);
}
}
}
use of org.alfresco.web.ui.common.component.UIListItem 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> ");
}
// 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('>');
}
}
Aggregations