Author: Alex.Kolonitsky
Date: 2010-12-29 10:03:28 -0500 (Wed, 29 Dec 2010)
New Revision: 20839
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.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-9435
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java 2010-12-29
14:01:34 UTC (rev 20838)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java 2010-12-29
15:03:28 UTC (rev 20839)
@@ -23,8 +23,8 @@
package org.richfaces.component.html;
import org.richfaces.component.UICollapsiblePanel;
+
import javax.faces.component.behavior.ClientBehaviorHolder;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -53,6 +53,11 @@
public enum PropertyKeys {
+ leftCollapsedIcon,
+ leftExpandedIcon,
+ rightCollapsedIcon,
+ rightExpandedIcon,
+
bodyClass,
headerClass,
headerControlClass,
@@ -83,6 +88,38 @@
return COMPONENT_FAMILY;
}
+ public String getLeftCollapsedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.leftCollapsedIcon);
+ }
+
+ public void setLeftCollapsedIcon(String leftCollapsedIcon) {
+ getStateHelper().put(PropertyKeys.leftCollapsedIcon, leftCollapsedIcon);
+ }
+
+ public String getLeftExpandedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.leftExpandedIcon);
+ }
+
+ public void setLeftExpandedIcon(String leftExpandedIcon) {
+ getStateHelper().put(PropertyKeys.leftExpandedIcon, leftExpandedIcon);
+ }
+
+ public String getRightCollapsedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.rightCollapsedIcon);
+ }
+
+ public void setRightCollapsedIcon(String rightCollapsedIcon) {
+ getStateHelper().put(PropertyKeys.rightCollapsedIcon, rightCollapsedIcon);
+ }
+
+ public String getRightExpandedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.rightExpandedIcon);
+ }
+
+ public void setRightExpandedIcon(String rightExpandedIcon) {
+ getStateHelper().put(PropertyKeys.rightExpandedIcon, rightExpandedIcon);
+ }
+
public String getBodyClass() {
return (String) getStateHelper().eval(PropertyKeys.bodyClass);
}
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
(rev 0)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java 2010-12-29
15:03:28 UTC (rev 20839)
@@ -0,0 +1,112 @@
+package org.richfaces.renderkit.html;
+
+import org.richfaces.component.html.HtmlPanelMenuGroup;
+import org.richfaces.renderkit.RenderKitUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.renderkit.HtmlConstants.*;
+import static org.richfaces.renderkit.html.DivPanelRenderer.styleElement;
+
+public class TableIconsRendererHelper {
+
+ public void encodeHeaderGroup(ResponseWriter writer, FacesContext context,
HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ writer.startElement(TABLE_ELEMENT, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-gr", null);
+ writer.startElement(TBODY_ELEMENT, null);
+ writer.startElement(TR_ELEMENT, null);
+
+ encodeHeaderGroupIconLeft(writer, context, menuItem, classPrefix);
+
+ writer.startElement(TD_ELEM, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-lbl", null);
+
+ UIComponent headerFacet = menuItem.getFacet("label");
+ if (headerFacet != null && headerFacet.isRendered()) {
+ headerFacet.encodeAll(context);
+ } else {
+ Object label = menuItem.getLabel();
+ if (label != null && !label.equals("")) {
+ writer.writeText(label, null);
+ }
+ }
+
+ writer.endElement(TD_ELEM);
+
+ encodeHeaderGroupIconRight(writer, context, menuItem, classPrefix);
+
+ writer.endElement(TR_ELEMENT);
+ writer.endElement(TBODY_ELEMENT);
+ writer.endElement(TABLE_ELEMENT);
+ }
+
+ public void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context,
HtmlPanelMenuGroup menuGroup, String classPrefix) throws IOException {
+ String iconCollapsed = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() :
menuGroup.getIconLeftCollapsed();
+ String iconExpanded = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() :
menuGroup.getIconLeftExpanded();
+
+ encodeTdIcon(writer, context, classPrefix + "-ico",
menuGroup.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ public void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context,
HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ String iconCollapsed = menuItem.isDisabled() ? menuItem.getIconRightDisabled() :
menuItem.getIconRightCollapsed();
+ String iconExpanded = menuItem.isDisabled() ? menuItem.getIconRightDisabled() :
menuItem.getIconRightExpanded();
+
+ //TODO nick - should this be "-ico-exp"? also why expanded icon state
is connected with right icon alignment?
+ encodeTdIcon(writer, context, classPrefix + "-exp-ico",
menuItem.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ public void encodeTdIcon(ResponseWriter writer, FacesContext context, String
cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue)
throws IOException {
+ writer.startElement(TD_ELEM, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, cssClass, null);
+
+ encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue,
"rf-pm-ico-colps");
+ encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue,
"rf-pm-ico-exp");
+
+ writer.endElement(TD_ELEM);
+ }
+
+ public void encodeIdIcon(ResponseWriter writer, FacesContext context, boolean
isExpanded, String attrIconValue, String styleClass) throws IOException {
+ if (attrIconValue == null || attrIconValue.trim().length() <= 0) {
+ encodeDivIcon(writer, isExpanded, PanelMenuIcons.none, styleClass);
+ } else {
+ PanelMenuIcons icon = getIcon(attrIconValue);
+ if (icon != null) {
+ encodeDivIcon(writer, isExpanded, icon, styleClass);
+ } else {
+ encodeImage(writer, context, attrIconValue);
+ }
+ }
+ }
+
+ public PanelMenuIcons getIcon(String attrIconCollapsedValue) {
+ if (attrIconCollapsedValue == null) {
+ return null;
+ }
+
+ try {
+ return PanelMenuIcons.valueOf(attrIconCollapsedValue);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public void encodeDivIcon(ResponseWriter writer, boolean isDisplay, PanelMenuIcons
icon, String styleClass) throws IOException {
+ writer.startElement(DIV_ELEM, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, concatClasses(styleClass,
icon.cssClass()), null);
+ writer.writeAttribute(STYLE_ATTRIBUTE, styleElement("display",
isDisplay ? "none" : "block"), null);
+ writer.endElement(DIV_ELEM);
+ }
+
+ public void encodeImage(ResponseWriter writer, FacesContext context, String
attrIconValue) throws IOException {
+ writer.startElement(IMG_ELEMENT, null);
+ writer.writeAttribute(ALT_ATTRIBUTE, "", null);
+ writer.writeURIAttribute(SRC_ATTRIBUTE,
RenderKitUtils.getResourceURL(attrIconValue, context), null);
+ writer.endElement(IMG_ELEMENT);
+ }
+
+
+}
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-29 14:01:34
UTC (rev 20838)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-29 15:03:28
UTC (rev 20839)
@@ -939,6 +939,22 @@
<component-type>org.richfaces.CollapsiblePanel</component-type>
<component-class>org.richfaces.component.html.HtmlCollapsiblePanel</component-class>
<property>
+ <property-name>leftCollapsedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>leftExpandedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>rightExpandedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>rightCollapsedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
<description></description>
<property-name>switchType</property-name>
<property-class>org.richfaces.component.SwitchType</property-class>
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-29 14:01:34 UTC
(rev 20838)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-29 15:03:28 UTC
(rev 20839)
@@ -1047,6 +1047,22 @@
<renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
<handler-class>org.richfaces.view.facelets.html.CollapsiblePanelTagHandler</handler-class>
</component>
+ <attribute>
+ <name>leftCollapsedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>leftExpandedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>rightExpandedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>rightCollapsedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
<attribute>
<name>switchType</name>
<type>org.richfaces.component.SwitchType</type>