Author: nbelaevski
Date: 2011-01-24 18:50:32 -0500 (Mon, 24 Jan 2011)
New Revision: 21186
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
Log:
https://issues.jboss.org/browse/RF-10270
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2011-01-24
20:28:24 UTC (rev 21185)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2011-01-24
23:50:32 UTC (rev 21186)
@@ -23,13 +23,6 @@
package org.richfaces.component;
-import org.richfaces.PanelMenuMode;
-import org.richfaces.cdk.annotations.*;
-import org.richfaces.event.ItemChangeEvent;
-import org.richfaces.event.ItemChangeListener;
-import org.richfaces.event.ItemChangeSource;
-import org.richfaces.renderkit.util.PanelIcons;
-
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
@@ -39,6 +32,18 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import org.richfaces.PanelMenuMode;
+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.cdk.annotations.TagType;
+import org.richfaces.event.ItemChangeEvent;
+import org.richfaces.event.ItemChangeListener;
+import org.richfaces.event.ItemChangeSource;
+import org.richfaces.renderkit.util.PanelIcons;
+
/**
* @author akolonitsky
* @since 2010-10-25
@@ -174,10 +179,10 @@
@Attribute
public abstract boolean isDisabled();
- @Attribute(defaultValue = "click")
+ @Attribute
public abstract String getExpandEvent();
- @Attribute(defaultValue = "click")
+ @Attribute
public abstract String getCollapseEvent();
@Attribute(defaultValue = "PanelMenuMode.client")
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java 2011-01-24
20:28:24 UTC (rev 21185)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java 2011-01-24
23:50:32 UTC (rev 21186)
@@ -23,17 +23,21 @@
package org.richfaces.component;
-import org.richfaces.PanelMenuMode;
-import org.richfaces.cdk.annotations.*;
-import org.richfaces.event.ItemChangeEvent;
-import org.richfaces.event.PanelToggleEvent;
-
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import org.richfaces.PanelMenuMode;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.event.ItemChangeEvent;
+import org.richfaces.event.PanelToggleEvent;
+
/**
* @author akolonitsky
* @since 2010-10-25
@@ -161,35 +165,12 @@
@Attribute(defaultValue = "getPanelMenu().isExpandSingle()")
public abstract boolean isExpandSingle();
- @Attribute(generate = false)
- public String getCollapseEvent() {
- String value = (String) getStateHelper().eval(Properties.collapseEvent);
- if (value != null) {
- return value;
- }
+ @Attribute
+ public abstract String getCollapseEvent();
- return getPanelMenu().getCollapseEvent();
- }
+ @Attribute
+ public abstract String getExpandEvent();
- public void setCollapseEvent(String collapseEvent) {
- getStateHelper().put(Properties.collapseEvent, collapseEvent);
- }
-
-
- @Attribute(generate = false)
- public String getExpandEvent() {
- String value = (String) getStateHelper().eval(Properties.expandEvent);
- if (value != null) {
- return value;
- }
-
- return getPanelMenu().getExpandEvent();
- }
-
- public void setExpandEvent(String expandEvent) {
- getStateHelper().put(Properties.expandEvent, expandEvent);
- }
-
@Attribute(defaultValue = "getPanelMenu().isBubbleSelection()")
public abstract boolean isBubbleSelection();
@@ -199,7 +180,7 @@
// ------------------------------------------------ Html Attributes
enum Properties {
- leftIconDisabled, leftIconExpanded, rightIconCollapsed, rightIconDisabled,
rightIconExpanded, disabledClass, styleClass, expandEvent, collapseEvent,
leftIconCollapsed
+ leftIconDisabled, leftIconExpanded, rightIconCollapsed, rightIconDisabled,
rightIconExpanded, disabledClass, styleClass, leftIconCollapsed
}
@Attribute(generate = false)
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2011-01-24
20:28:24 UTC (rev 21185)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2011-01-24
23:50:32 UTC (rev 21186)
@@ -47,6 +47,8 @@
import org.richfaces.component.AbstractPanelMenuGroup;
import org.richfaces.component.AbstractPanelMenuItem;
+import com.google.common.base.Strings;
+
/**
* @author akolonitsky
* @since 2010-10-25
@@ -64,6 +66,8 @@
//TODO nick - shouldn't this be rf-pm-gr-top?
private static final String TOP_CSS_CLASS_PREFIX = "rf-pm-top-gr";
+ private static final String DEFAULT_EXPAND_EVENT = "click";
+ private static final String DEFAULT_COLLAPSE_EVENT = "click";
private final TableIconsRendererHelper<AbstractPanelMenuGroup> headerRenderer =
new PanelMenuGroupHeaderRenderer(CSS_CLASS_PREFIX);
private final TableIconsRendererHelper<AbstractPanelMenuGroup>
topHeaderRenderer = new PanelMenuGroupHeaderRenderer(TOP_CSS_CLASS_PREFIX);
@@ -154,6 +158,28 @@
component.getClientId(context), getScriptObjectOptions(context, component));
}
+ private String getExpandEvent(AbstractPanelMenuGroup group) {
+ String expandEvent = group.getExpandEvent();
+ if (Strings.isNullOrEmpty(expandEvent)) {
+ expandEvent = group.getPanelMenu().getExpandEvent();
+ }
+ if (Strings.isNullOrEmpty(expandEvent)) {
+ expandEvent = DEFAULT_EXPAND_EVENT;
+ }
+ return expandEvent;
+ }
+
+ private String getCollapseEvent(AbstractPanelMenuGroup group) {
+ String collapseEvent = group.getCollapseEvent();
+ if (Strings.isNullOrEmpty(collapseEvent)) {
+ collapseEvent = group.getPanelMenu().getCollapseEvent();
+ }
+ if (Strings.isNullOrEmpty(collapseEvent)) {
+ collapseEvent = DEFAULT_COLLAPSE_EVENT;
+ }
+ return collapseEvent;
+ }
+
@Override
protected Map<String, Object> getScriptObjectOptions(FacesContext context,
UIComponent component) {
AbstractPanelMenuGroup panelMenuGroup = (AbstractPanelMenuGroup) component;
@@ -164,8 +190,8 @@
options.put("name", panelMenuGroup.getName());
options.put("mode", panelMenuGroup.getMode());
options.put("disabled", panelMenuGroup.isDisabled());
- options.put("expandEvent", panelMenuGroup.getExpandEvent());
- options.put("collapseEvent", panelMenuGroup.getCollapseEvent());
+ options.put("expandEvent", getExpandEvent(panelMenuGroup));
+ options.put("collapseEvent", getCollapseEvent(panelMenuGroup));
options.put("expandSingle", panelMenuGroup.isExpandSingle());
options.put("bubbleSelection", panelMenuGroup.isBubbleSelection());
options.put("expanded", panelMenuGroup.isExpanded());