Author: abelevich
Date: 2010-12-03 10:19:27 -0500 (Fri, 03 Dec 2010)
New Revision: 20359
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbarGroup.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/ToolbarSeparatorImage.java
trunk/ui/output/ui/src/main/templates/toolbar.template.xml
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/DotSeparatorImage.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/GridSeparatorImage.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/LineSeparatorImage.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/SquareSeparatorImage.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
Log:
Rf-9884, RF-9885, RF-9886
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
(rev 0)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.renderkit.html.ToolbarRendererBase;
+
+@JsfComponent(family = AbstractToolbar.COMPONENT_FAMILY, type =
AbstractToolbar.COMPONENT_TYPE,
+ renderer=@JsfRenderer(type = ToolbarRendererBase.RENDERER_TYPE), tag =
@Tag(name="toolbar")
+)
+public abstract class AbstractToolbar extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Toolbar";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Toolbar";
+
+ @Attribute
+ public abstract String getHeight();
+
+ @Attribute
+ public abstract String getWidth();
+
+ @Attribute
+ public abstract String getItemSeparator();
+
+ @Attribute(events=@EventName("itemclick"))
+ public abstract String getOnitemclick();
+
+ @Attribute(events=@EventName("itemdblclick"))
+ public abstract String getOnitemdblclick();
+
+ @Attribute(events=@EventName("itemmousedown"))
+ public abstract String getOnitemmousedown();
+
+ @Attribute(events=@EventName("itemmouseup"))
+ public abstract String getOnitemmouseup();
+
+ @Attribute(events=@EventName("itemmouseover"))
+ public abstract String getOnitemmouseover();
+
+ @Attribute(events=@EventName("itemmousemove"))
+ public abstract String getOnitemmousemove();
+
+ @Attribute(events=@EventName("itemmouseout"))
+ public abstract String getOnitemmouseout();
+
+ @Attribute(events=@EventName("itemkeypress"))
+ public abstract String getOnitemkeypress();
+
+ @Attribute(events=@EventName("itemkeydown"))
+ public abstract String getOnitemkeydown();
+
+ @Attribute(events=@EventName("itemkeyup"))
+ public abstract String getOnitemkeyup();
+
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbarGroup.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbarGroup.java
(rev 0)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbarGroup.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.renderkit.html.ToolbarGroupRenderer;
+
+@JsfComponent(family = AbstractToolbar.COMPONENT_FAMILY, type =
AbstractToolbarGroup.COMPONENT_TYPE,
+ renderer=@JsfRenderer(type = ToolbarGroupRenderer.RENDERER_TYPE), tag =
@Tag(name="toolbarGroup"))
+public abstract class AbstractToolbarGroup extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.ToolbarGroup";
+
+ @Attribute
+ public abstract String getItemSeparator();
+
+ @Attribute
+ public abstract String getLocation();
+
+ @Attribute(events=@EventName("itemclick"))
+ public abstract String getOnitemclick();
+
+ @Attribute(events=@EventName("itemdblclick"))
+ public abstract String getOnitemdblclick();
+
+ @Attribute(events=@EventName("itemmousedown"))
+ public abstract String getOnitemmousedown();
+
+ @Attribute(events=@EventName("itemmouseup"))
+ public abstract String getOnitemmouseup();
+
+ @Attribute(events=@EventName("itemmouseover"))
+ public abstract String getOnitemmouseover();
+
+ @Attribute(events=@EventName("itemmousemove"))
+ public abstract String getOnitemmousemove();
+
+ @Attribute(events=@EventName("itemmouseout"))
+ public abstract String getOnitemmouseout();
+
+ @Attribute(events=@EventName("itemkeypress"))
+ public abstract String getOnitemkeypress();
+
+ @Attribute(events=@EventName("itemkeydown"))
+ public abstract String getOnitemkeydown();
+
+ @Attribute(events=@EventName("itemkeyup"))
+ public abstract String getOnitemkeyup();
+
+ public AbstractToolbar getToolBar() {
+ UIComponent component = this.getParent();
+ if (component == null) {
+ throw new FacesException("The component: " +
this.getClientId(getFacesContext()) +
+ " is not nested within " +
AbstractToolbar.class.getSimpleName());
+ } else if (!(component instanceof AbstractToolbar)) {
+ throw new FacesException("The component: " +
this.getClientId(getFacesContext()) +
+ " is not a direct child of " +
AbstractToolbar.class.getSimpleName());
+ }
+ return (AbstractToolbar) component;
+ }
+
+ public List<UIComponent> getRenderedChildren() {
+ List<UIComponent> children = this.getChildren();
+ List<UIComponent> renderedChildren = new
ArrayList<UIComponent>(children.size());
+
+ for (UIComponent child : children) {
+ if (child.isRendered()) {
+ renderedChildren.add(child);
+ }
+ }
+
+ return renderedChildren;
+ }
+
+}
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
(rev 0)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.component.AbstractToolbar;
+import org.richfaces.component.AbstractToolbarGroup;
+import org.richfaces.renderkit.HtmlConstants;
+
+@JsfRenderer(type = ToolbarGroupRenderer.RENDERER_TYPE, family =
AbstractToolbar.COMPONENT_FAMILY)
+public class ToolbarGroupRenderer extends ToolbarRendererBase {
+
+ public static final String RENDERER_TYPE =
"org.richfaces.ToolbarGroupRenderer";
+
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractToolbarGroup.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void encodeChildren(FacesContext facesContext, UIComponent component) throws
IOException {
+ AbstractToolbarGroup toolbarGroup = (AbstractToolbarGroup) component;
+ List<UIComponent> renderedChildren = toolbarGroup.getRenderedChildren();
+ if (renderedChildren.size() <= 0) {
+ return;
+ }
+
+ ResponseWriter writer = facesContext.getResponseWriter();
+ renderChild(facesContext, toolbarGroup, writer, renderedChildren.get(0));
+ for (int i = 1; i < renderedChildren.size(); i++) {
+ insertSeparatorIfNeed(facesContext, toolbarGroup, writer);
+ renderChild(facesContext, toolbarGroup, writer, renderedChildren.get(i));
+ }
+ }
+
+ private void renderChild(FacesContext facesContext, AbstractToolbarGroup
toolbarGroup, ResponseWriter writer,
+ UIComponent child) throws IOException {
+ writer.startElement(HtmlConstants.TD_ELEM, toolbarGroup);
+ writeClassValue(toolbarGroup, writer);
+ writeStyleValue(toolbarGroup, writer);
+ encodeEventsAttributes(facesContext, toolbarGroup);
+ child.encodeAll(facesContext);
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+
+ private void writeStyleValue(AbstractToolbarGroup toolbarGroup, ResponseWriter
writer) throws IOException {
+ String style = getStringAttribute(toolbarGroup, HtmlConstants.STYLE_ATTRIBUTE);
+ String contentStyle = getStringAttribute(getParentToolBar(toolbarGroup),
"contentStyle");
+
+ String value = concatStyles(contentStyle, style);
+
+ if (isPropertyRendered(value)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, value, null);
+ }
+ }
+
+ private void writeClassValue(AbstractToolbarGroup toolbarGroup, ResponseWriter
writer) throws IOException {
+ String styleClass = getStringAttribute(toolbarGroup,
HtmlConstants.STYLE_CLASS_ATTR);
+ AbstractToolbar toolbar = getParentToolBar(toolbarGroup);
+ String contentClass = null;
+
+ if(toolbar != null) {
+ contentClass = getStringAttribute(toolbar, "contentClass");
+ }
+
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
concatClasses("rf-tb-itm", contentClass, styleClass), null);
+ }
+
+ private String getStringAttribute(UIComponent toolbarGroup, String attribute) {
+ String value = (String) toolbarGroup.getAttributes().get(attribute);
+ return null == value ? "" : value;
+ }
+
+ public AbstractToolbar getParentToolBar(UIComponent component) {
+ return (component instanceof AbstractToolbarGroup) ? ((AbstractToolbarGroup)
component).getToolBar() : null;
+ }
+
+}
\ No newline at end of file
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
(rev 0)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -0,0 +1,279 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.component.AbstractToolbar;
+import org.richfaces.component.AbstractToolbarGroup;
+import org.richfaces.renderkit.ComponentAttribute;
+import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.RenderKitUtils;
+import org.richfaces.renderkit.RendererBase;
+
+
+@ResourceDependency(library = "org.richfaces", name =
"toolbar.ecss")
+public abstract class ToolbarRendererBase extends RendererBase {
+
+ public static final String RENDERER_TYPE =
"org.richfaces.ToolbarRenderer";
+
+ public static final Map<String, ComponentAttribute> ITEMS_HANDLER_ATTRIBUTES =
Collections
+ .unmodifiableMap(ComponentAttribute.createMap(
+ new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
+ .setEventNames("itemclick")
+ .setComponentAttributeName("onitemclick"),
+ new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE)
+ .setEventNames("itemdblclick")
+ .setComponentAttributeName("onitemdblclick"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE)
+ .setEventNames("itemmousedown")
+ .setComponentAttributeName("onitemmousedown"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE)
+ .setEventNames("itemmouseup")
+ .setComponentAttributeName("onitemmouseup"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE)
+ .setEventNames("itemmouseover")
+ .setComponentAttributeName("onitemmouseover"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE)
+ .setEventNames("itemmousemove")
+ .setComponentAttributeName("onitemmousemove"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE)
+ .setEventNames("itemmouseout")
+ .setComponentAttributeName("onitemmouseout"),
+ new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE)
+ .setEventNames("itemkeypress")
+ .setComponentAttributeName("onitemkeypress"),
+ new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE)
+ .setEventNames("itemkeydown")
+ .setComponentAttributeName("onitemkeydown"),
+ new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
+ .setEventNames("itemkeyup")
+ .setComponentAttributeName("onitemkeyup")
+ ));
+
+ public enum ItemSeparators {
+ NONE, SQUARE, DISC, GRID, LINE
+ }
+
+ public enum Locations {
+ RIGHT, LEFT
+ }
+
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ AbstractToolbar toolbar = (AbstractToolbar) component;
+ String contentClass = (String)
toolbar.getAttributes().get("contentClass");
+ String contentStyle = (String)
toolbar.getAttributes().get("contentStyle");
+
+ List<UIComponent> children = toolbar.getChildren();
+
+ if (children != null) {
+ List<UIComponent> childrenToTheLeft = new
LinkedList<UIComponent>();
+ List<UIComponent> childrenToTheRight = new
LinkedList<UIComponent>();
+ for (UIComponent child : children) {
+ if (child.isRendered()) {
+ if (child instanceof AbstractToolbarGroup) {
+ AbstractToolbarGroup group = (AbstractToolbarGroup) child;
+ String location = group.getLocation();
+ if (location != null &&
location.equalsIgnoreCase(Locations.RIGHT.toString())) {
+ childrenToTheRight.add(child);
+ } else {
+ childrenToTheLeft.add(child);
+ }
+ } else {
+ childrenToTheLeft.add(child);
+ }
+ }
+ }
+
+ ResponseWriter writer = context.getResponseWriter();
+ for (Iterator<UIComponent> it = childrenToTheLeft.iterator();
it.hasNext();) {
+
+ UIComponent child = it.next();
+
+ if (!(child instanceof AbstractToolbarGroup)) {
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
concatClasses("rf-tb-itm", contentClass), null);
+ if (isPropertyRendered(contentStyle)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE,
contentStyle, null);
+ }
+ encodeEventsAttributes(context, toolbar);
+ }
+
+ child.encodeAll(context);
+
+ if (!(child instanceof AbstractToolbarGroup)) {
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+
+
+
+ if (it.hasNext()) {
+ insertSeparatorIfNeed(context, toolbar, writer);
+ }
+ }
+
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, "width:100%",
null);
+ writer.endElement(HtmlConstants.TD_ELEM);
+
+ for (Iterator<UIComponent> it = childrenToTheRight.iterator();
it.hasNext();) {
+ UIComponent child = it.next();
+ child.encodeAll(context);
+ if (it.hasNext()) {
+ insertSeparatorIfNeed(context, toolbar, writer);
+ }
+ }
+ }
+ }
+
+ public void encodeItem(FacesContext facesContext, UIComponent component,
ResponseWriter writer, String contentStyle, String contentClass) throws IOException {
+ if (!(component instanceof AbstractToolbarGroup)) {
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
concatClasses("rf-tb-itm", contentClass), null);
+ if (isPropertyRendered(contentStyle)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle,
null);
+ }
+ encodeEventsAttributes(facesContext, component);
+ }
+
+ component.encodeAll(facesContext);
+
+ if (!(component instanceof AbstractToolbarGroup)) {
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+ }
+
+ /**
+ * Inserts separator between toolbar items. Uses facet "itemSeparator" if
it
+ * is set and default separator implementation if facet is not set.
+ *
+ * @param context
+ * - faces context
+ * @param component
+ * - component
+ * @param writer
+ * - response writer
+ * @throws IOException
+ * - in case of IOException during writing to the ResponseWriter
+ */
+ protected void insertSeparatorIfNeed(FacesContext context, UIComponent component,
ResponseWriter writer)
+ throws IOException {
+ UIComponent separatorFacet = component.getFacet("itemSeparator");
+ boolean isSeparatorFacetRendered = (separatorFacet != null) ?
separatorFacet.isRendered() : false;
+ if (isSeparatorFacetRendered) {
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-tb-sep",
null);
+ separatorFacet.encodeAll(context);
+ writer.endElement(HtmlConstants.TD_ELEM);
+ } else {
+ insertDefaultSeparatorIfNeed(context, component, writer);
+ }
+ }
+
+ /**
+ * Inserts default separator. Possible values are: "square",
"disc", "grid",
+ * "line" - for separators provided by component implementation;
"none" -
+ * for no separators between toolbar items; URI string value - for custom
+ * images specified by the page author.
+ *
+ * @param context
+ * - faces context
+ * @param component
+ * - component
+ * @param writer
+ * - response writer
+ * @throws IOException
+ * - in case of IOException during writing to the ResponseWriter
+ */
+ protected void insertDefaultSeparatorIfNeed(FacesContext context, UIComponent
component, ResponseWriter writer)
+ throws IOException {
+ String itemSeparator = (String)
component.getAttributes().get("itemSeparator");
+
+ if (itemSeparator != null && itemSeparator.trim().length() != 0
+ &&
!itemSeparator.equalsIgnoreCase(ItemSeparators.NONE.toString())) {
+
+ ItemSeparators separator = null;
+ if (itemSeparator.equalsIgnoreCase(ItemSeparators.SQUARE.toString())) {
+ separator = ItemSeparators.SQUARE;
+ } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.DISC.toString())) {
+ separator = ItemSeparators.DISC;
+ } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.GRID.toString())) {
+ separator = ItemSeparators.GRID;
+ } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.LINE.toString())) {
+ separator = ItemSeparators.LINE;
+ }
+
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ String separatorClass = "rf-tb-sep";
+ concatClasses(separatorClass, (String)
component.getAttributes().get("separatorClass"));
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, separatorClass, null);
+
+ if (separator != null) {
+ String itemSeparatorClass = "rf-tb-sep-" +
separator.toString().toLowerCase();
+ writer.startElement(HtmlConstants.DIV_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, itemSeparatorClass,
null);
+ writer.write(" ");
+ writer.endElement(HtmlConstants.DIV_ELEM);
+ } else {
+ concatClasses(separatorClass, (String)
component.getAttributes().get("separatorClass"));
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, separatorClass,
null);
+
+ String uri = RenderKitUtils.getResourceURL(itemSeparator, context);
+ writer.startElement(HtmlConstants.IMG_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, uri, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+ }
+
+ protected Class<? extends javax.faces.component.UIComponent>
getComponentClass() {
+ return AbstractToolbar.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ protected void encodeEventsAttributes(FacesContext facesContext, UIComponent
component)
+ throws IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component,
ITEMS_HANDLER_ATTRIBUTES);
+ }
+
+ protected boolean isPropertyRendered(String property) {
+ return (null != property && !"".equals(property));
+ }
+}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/DotSeparatorImage.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/DotSeparatorImage.java 2010-12-03
15:19:09 UTC (rev 20358)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/DotSeparatorImage.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -36,7 +36,7 @@
*
*/
@DynamicUserResource
-public class DotSeparatorImage extends ToolBarSeparatorImage {
+public class DotSeparatorImage extends ToolbarSeparatorImage {
private static final Dimension DIMENSIONS = new Dimension(9, 9);
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/GridSeparatorImage.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/GridSeparatorImage.java 2010-12-03
15:19:09 UTC (rev 20358)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/GridSeparatorImage.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -10,7 +10,7 @@
import org.richfaces.resource.DynamicUserResource;
@DynamicUserResource
-public class GridSeparatorImage extends ToolBarSeparatorImage {
+public class GridSeparatorImage extends ToolbarSeparatorImage {
public Dimension getDimension() {
return calculateDimension();
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/LineSeparatorImage.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/LineSeparatorImage.java 2010-12-03
15:19:09 UTC (rev 20358)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/LineSeparatorImage.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -8,7 +8,7 @@
import org.richfaces.resource.DynamicUserResource;
@DynamicUserResource
-public class LineSeparatorImage extends ToolBarSeparatorImage {
+public class LineSeparatorImage extends ToolbarSeparatorImage {
public Dimension getDimension() {
return calculateDimension();
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/SquareSeparatorImage.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/SquareSeparatorImage.java 2010-12-03
15:19:09 UTC (rev 20358)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/SquareSeparatorImage.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -12,7 +12,7 @@
import org.richfaces.resource.DynamicUserResource;
@DynamicUserResource
-public class SquareSeparatorImage extends ToolBarSeparatorImage {
+public class SquareSeparatorImage extends ToolbarSeparatorImage {
private static final Dimension DIMENSIONS = new Dimension(9, 9);
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/ToolbarSeparatorImage.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/ToolbarSeparatorImage.java
(rev 0)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/ToolbarSeparatorImage.java 2010-12-03
15:19:27 UTC (rev 20359)
@@ -0,0 +1,99 @@
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.resource.ResourceParameter;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+public abstract class ToolbarSeparatorImage implements Java2DUserResource,
StateHolderResource {
+
+ private int headerBackgroundColor;
+ private int separatorHeight;
+ private int headerGradientColor;
+
+ public int getHeaderBackgroundColor() {
+ return headerBackgroundColor;
+ }
+
+ public void setHeaderBackgroundColor(int bgColor) {
+ this.headerBackgroundColor = bgColor;
+ }
+
+ public int getSeparatorHeight() {
+ return separatorHeight;
+ }
+
+ @ResourceParameter(defaultValue = "9")
+ public void setSeparatorHeight(int separatorHeight) {
+ this.separatorHeight = separatorHeight;
+ }
+
+ public int getHeaderGradientColor() {
+ return headerGradientColor;
+ }
+
+ public void setHeaderGradientColor(int headerGradientColor) {
+ this.headerGradientColor = headerGradientColor;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ dataOutput.writeInt(headerBackgroundColor);
+ dataOutput.writeInt(separatorHeight);
+ dataOutput.writeInt(headerGradientColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ this.headerBackgroundColor = dataInput.readInt();
+ this.separatorHeight = dataInput.readInt();
+ this.headerGradientColor = dataInput.readInt();
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.GIF;
+ }
+
+ @PostConstructResource
+ public final void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+ Skin defaultSkin = SkinFactory.getInstance(context).getDefaultSkin(context);
+
+ String skinParameter = "headerBackgroundColor";
+ String tmp = (String) skin.getParameter(context, skinParameter);
+ if (null == tmp || "".equals(tmp)) {
+ tmp = (String) defaultSkin.getParameter(context, skinParameter);
+ }
+ this.setHeaderBackgroundColor(Color.decode(tmp == null ? "#224986" :
tmp).getRGB());
+
+ skinParameter = "headerGradientColor";
+ tmp = (String) skin.getParameter(context, skinParameter);
+ if (null == tmp || "".equals(tmp)) {
+ tmp = (String) defaultSkin.getParameter(context, skinParameter);
+ }
+ this.setHeaderGradientColor(Color.decode(tmp == null ? "#CCCCFF" :
tmp).getRGB());
+ }
+}
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-03 15:19:09
UTC (rev 20358)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-03 15:19:27
UTC (rev 20359)
@@ -11,8 +11,8 @@
</behavior>
<component>
- <component-type>org.richfaces.ToolBar</component-type>
- <component-class>org.richfaces.component.UIToolBar</component-class>
+ <component-type>org.richfaces.Toolbar</component-type>
+ <component-class>org.richfaces.component.UIToolbar</component-class>
<property>
<description>
A mutable Map of the attributes associated with
@@ -380,20 +380,20 @@
</property-extension>
</property>
<component-extension>
-
<cdk:base-class>org.richfaces.component.AbstractToolBar</cdk:base-class>
+
<cdk:base-class>org.richfaces.component.AbstractToolbar</cdk:base-class>
<cdk:generate>true</cdk:generate>
-
<cdk:component-family>org.richfaces.ToolBar</cdk:component-family>
-
<cdk:renderer-type>org.richfaces.ToolBarRenderer</cdk:renderer-type>
+
<cdk:component-family>org.richfaces.Toolbar</cdk:component-family>
+
<cdk:renderer-type>org.richfaces.ToolbarRenderer</cdk:renderer-type>
<cdk:tag>
<cdk:generate>false</cdk:generate>
- <cdk:tag-name>toolBar</cdk:tag-name>
+ <cdk:tag-name>toolbar</cdk:tag-name>
<cdk:tag-type>Facelets</cdk:tag-type>
</cdk:tag>
</component-extension>
</component>
<component>
- <component-type>org.richfaces.ToolBarGroup</component-type>
-
<component-class>org.richfaces.component.UIToolBarGroup</component-class>
+ <component-type>org.richfaces.ToolbarGroup</component-type>
+
<component-class>org.richfaces.component.UIToolbarGroup</component-class>
<property>
<description>
A mutable Map of the attributes associated with
@@ -749,13 +749,13 @@
</property-extension>
</property>
<component-extension>
-
<cdk:base-class>org.richfaces.component.AbstractToolBarGroup</cdk:base-class>
+
<cdk:base-class>org.richfaces.component.AbstractToolbarGroup</cdk:base-class>
<cdk:generate>true</cdk:generate>
-
<cdk:component-family>org.richfaces.ToolBar</cdk:component-family>
-
<cdk:renderer-type>org.richfaces.ToolBarGroupRenderer</cdk:renderer-type>
+
<cdk:component-family>org.richfaces.Toolbar</cdk:component-family>
+
<cdk:renderer-type>org.richfaces.ToolbarGroupRenderer</cdk:renderer-type>
<cdk:tag>
<cdk:generate>false</cdk:generate>
- <cdk:tag-name>toolBarGroup</cdk:tag-name>
+ <cdk:tag-name>toolbarGroup</cdk:tag-name>
<cdk:tag-type>Facelets</cdk:tag-type>
</cdk:tag>
</component-extension>
@@ -1757,17 +1757,17 @@
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
- <component-family>org.richfaces.ToolBar</component-family>
- <renderer-type>org.richfaces.ToolBarRenderer</renderer-type>
-
<renderer-class>org.richfaces.renderkit.html.ToolBarRenderer</renderer-class>
+ <component-family>org.richfaces.Toolbar</component-family>
+ <renderer-type>org.richfaces.ToolbarRenderer</renderer-type>
+
<renderer-class>org.richfaces.renderkit.html.ToolbarRenderer</renderer-class>
<renderer-extension>
<cdk:renders-children>false</cdk:renders-children>
</renderer-extension>
</renderer>
<renderer>
- <component-family>org.richfaces.ToolBar</component-family>
-
<renderer-type>org.richfaces.ToolBarGroupRenderer</renderer-type>
-
<renderer-class>org.richfaces.renderkit.html.ToolBarGroupRenderer</renderer-class>
+ <component-family>org.richfaces.Toolbar</component-family>
+
<renderer-type>org.richfaces.ToolbarGroupRenderer</renderer-type>
+
<renderer-class>org.richfaces.renderkit.html.ToolbarGroupRenderer</renderer-class>
<renderer-extension>
<cdk:renders-children>false</cdk:renders-children>
</renderer-extension>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-03 15:19:09 UTC
(rev 20358)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-03 15:19:27 UTC
(rev 20359)
@@ -9,8 +9,8 @@
<tag>
<tag-name>toolbar</tag-name>
<component>
- <component-type>org.richfaces.ToolBar</component-type>
- <renderer-type>org.richfaces.ToolBarRenderer</renderer-type>
+ <component-type>org.richfaces.Toolbar</component-type>
+ <renderer-type>org.richfaces.ToolbarRenderer</renderer-type>
</component>
<attribute>
<description>The value binding expression used to wire up this
component to a component property of a JavaBean class</description>
@@ -88,8 +88,8 @@
<tag>
<tag-name>toolbarGroup</tag-name>
<component>
- <component-type>org.richfaces.ToolBarGroup</component-type>
-
<renderer-type>org.richfaces.ToolBarGroupRenderer</renderer-type>
+ <component-type>org.richfaces.ToolbarGroup</component-type>
+
<renderer-type>org.richfaces.ToolbarGroupRenderer</renderer-type>
</component>
<attribute>
<description>The value binding expression used to wire up this
component to a component property of a JavaBean class</description>
Added: trunk/ui/output/ui/src/main/templates/toolbar.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/toolbar.template.xml
(rev 0)
+++ trunk/ui/output/ui/src/main/templates/toolbar.template.xml 2010-12-03 15:19:27 UTC
(rev 20359)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root
xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
+
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+
xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.ToolbarRenderer</cdk:class>
+
<cdk:superclass>org.richfaces.renderkit.html.ToolbarRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.Toolbar</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.ToolbarRenderer</cdk:renderer-type>
+ </cc:interface>
+
+ <cc:implementation>
+ <table border="0" cellpadding="0"
cellspacing="0" id="#{clientId}"
width="#{component.attributes['width']}"
+ height="#{component.attributes['height']}" class="rf-tb
#{component.attributes['styleClass']}"
+ style="#{component.attributes['style']}"
+ cdk:passThroughWithExclusions="">
+ <tr class="rf-tb-cntr">
+ <cdk:body />
+ </tr>
+ </table>
+ </cc:implementation>
+</cdk:root>