protected void encodeToolbarGroups(FacesContext context, Toolbar toolbar) throws IOException { ResponseWriter writer = context.getResponseWriter(); for (UIComponent child : toolbar.getChildren()) { if (child.isRendered() && child instanceof ToolbarGroup) { ToolbarGroup group = (ToolbarGroup) child; String defaultGroupClass = "ui-toolbar-group-" + group.getAlign(); String groupClass = group.getStyleClass(); String groupStyle = group.getStyle(); groupClass = groupClass == null ? defaultGroupClass : defaultGroupClass + " " + groupClass; writer.startElement("div", null); writer.writeAttribute("class", groupClass, null); if (groupStyle != null) { writer.writeAttribute("style", groupStyle, null); } for (UIComponent groupChild : group.getChildren()) { if (groupChild instanceof UISeparator && groupChild.isRendered()) encodeSeparator(context, (UISeparator) groupChild); else groupChild.encodeAll(context); } writer.endElement("div"); } } }
/** * Enable or Disable the toolbar. If passed in false it will disable all buttons, if true it will * restore the buttons to their previous state. * * @param enabled boolean flag */ public void setEnabled(boolean enabled) { try { for (ToolbarButton button : this.buttons) { button.setTempDisabled(enabled); } for (ToolbarGroup gp : groups) { gp.setTempDisabled(enabled); } } catch (Exception e) { System.out.println("Error with Disable: " + e); // $NON-NLS-1$ e.printStackTrace(System.out); } }
/** * Add in a collection of buttons assembled as a ToolbarGroup * * @param group ToolbarGroup to add. */ public void add(ToolbarGroup group) { // check to see if there's already a separator added before this group if (!(bar.getWidget(bar.getWidgetCount() - 1) instanceof Image)) { bar.add(group.getLeadingSeparator()); bar.setCellVerticalAlignment(group.getLeadingSeparator(), ALIGN_MIDDLE); } // if the group has a label tag, add it before the buttons if (group.getLabel() != null) { bar.add(group.getGroupLabel()); bar.setCellVerticalAlignment(group.getGroupLabel(), ALIGN_MIDDLE); } // add the buttons to the bar and buttons collection for (ToolbarButton btn : group.getButtons()) { bar.add(btn.getPushButton()); } bar.add(group.getTrailingSeparator()); bar.setCellVerticalAlignment(group.getTrailingSeparator(), ALIGN_MIDDLE); groups.add(group); }