return;
}
final String clientId = command.getClientId(facesContext);
final boolean disabled = ComponentUtil.getBooleanAttribute(command, ATTR_DISABLED);
final LabelWithAccessKey label = new LabelWithAccessKey(command);
final UIComponent popupMenu = command.getFacet(FACET_MENUPOPUP);
String labelPosition = getLabelPosition(command.getParent());
String iconSize = getIconSize(command.getParent());
String iconName = (String) command.getAttributes().get(ATTR_IMAGE);
String image = getImage(facesContext, iconName, iconSize, disabled, selected);
String graphicId = clientId + SUBCOMPONENT_SEP + "icon";
final String hover = getHoverClasses(first, last);
final String mouseOverScript = "Tobago.toolbarMousesover(this, '" + hover + "', '" + graphicId + "');";
final String mouseOutScript = "Tobago.toolbarMousesout(this, '" + hover + "', '" + graphicId + "');";
writer.startElement(HtmlConstants.DIV, null);
writer.writeIdAttribute(command.getClientId(facesContext));
String divClasses = getDivClasses(selected, disabled);
writer.writeClassAttribute(divClasses);
if (!disabled) {
writer.writeAttribute(HtmlAttributes.ONMOUSEOVER, mouseOverScript, null);
writer.writeAttribute(HtmlAttributes.ONMOUSEOUT, mouseOutScript, null);
writer.writeAttribute(HtmlAttributes.ONCLICK, onClick, null);
}
writer.startElement(HtmlConstants.TABLE, null);
writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
writer.writeAttribute(HtmlAttributes.BORDER, 0);
String tableClasses = getTableClasses(selected, disabled);
writer.writeClassAttribute(tableClasses);
writer.startElement(HtmlConstants.TR, null);
boolean anchorOnLabel = label.getText() != null && !ToolBarTag.LABEL_OFF.equals(labelPosition);
if (!ToolBarTag.ICON_OFF.equals(iconSize)) {
HtmlRendererUtil.addImageSources(facesContext, writer,
iconName != null ? iconName : "image/1x1.gif", graphicId);
writer.startElement(HtmlConstants.TD, command);
writer.writeAttribute(HtmlAttributes.ALIGN, "center", false);
HtmlRendererUtil.renderTip(command, writer);
boolean render1pxImage = (iconName == null
&& (!ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
&& label.getText() != null));
if (((!ToolBarTag.LABEL_OFF.equals(labelPosition)
&& label.getText() != null)
|| popupMenu != null)
&& !render1pxImage) {
writer.writeStyleAttribute("padding-right: 3px;");
// TODO: make this '3px' configurable
}
String className = getIconClass(iconSize);
if (!anchorOnLabel) {
renderAnchorBegin(facesContext, writer, command, label, disabled);
}
writer.startElement(HtmlConstants.IMG, command);
writer.writeIdAttribute(graphicId);
writer.writeAttribute(HtmlAttributes.SRC, image, false);
writer.writeAttribute(HtmlAttributes.ALT, "", false);
HtmlRendererUtil.renderTip(command, writer);
writer.writeAttribute(HtmlAttributes.BORDER, 0);
writer.writeClassAttribute(className);
if (render1pxImage) {
writer.writeStyleAttribute("width: 1px;");
}
writer.endElement(HtmlConstants.IMG);
if (!anchorOnLabel) {
writer.endElement(HtmlConstants.A);
}
writer.endElement(HtmlConstants.TD);
}
boolean popupOn2 = ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
&& !ToolBarTag.ICON_OFF.equals(iconSize);
if (popupOn2) {
if (popupMenu != null) {
renderPopupTd(facesContext, writer, command, popupMenu,
true);
}
writer.endElement(HtmlConstants.TR);
writer.startElement(HtmlConstants.TR, null);
}
if (!ToolBarTag.LABEL_OFF.equals(labelPosition)) {
writer.startElement(HtmlConstants.TD, null);
writer.writeClassAttribute("tobago-toolbar-label-td");
writer.writeAttribute(HtmlAttributes.ALIGN, "center", false);
if (popupMenu != null) {
writer.writeAttribute(HtmlAttributes.STYLE, "padding-right: 3px;", false);
// TODO: make this '3px' configurable
}
if (label.getText() != null) {
renderAnchorBegin(facesContext, writer, command, label, disabled);
HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
writer.endElement(HtmlConstants.A);
}
writer.endElement(HtmlConstants.TD);