Author: sergeyhalipov
Date: 2008-03-03 13:08:02 -0500 (Mon, 03 Mar 2008)
New Revision: 6501
Modified:
trunk/samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp
trunk/ui/contextMenu/src/main/config/component/contextMenu.xml
trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml
trunk/ui/menu-components/src/main/config/component/menucomponents.xml
trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java
trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1650
90% completed.
Modified: trunk/samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp 2008-03-03 17:07:08
UTC (rev 6500)
+++ trunk/samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp 2008-03-03 18:08:02
UTC (rev 6501)
@@ -5,7 +5,13 @@
<html>
<head>
- <style type="text/css">
+ <style type="text/css">
+ .disabled_item {
+ border: 1px solid blue;
+ }
+ .select_item {
+ border: 1px dashed red;
+ }
</style>
</head>
@@ -17,8 +23,21 @@
<h:commandLink action="#{skinBean.change}" value="set
skin"/>
<h:panelGrid id="grid" columns="2"
cellspacing="4">
- <ddm:dropDownMenu event="#{bean.event}"
id="MenuItem1" verticalOffset="#{bean.verticalOffset}"
horizontalOffset="#{bean.horizontalOffset}" popupWidth="#{bean.width}"
value="Item1" jointPoint="#{bean.jointPoint}"
direction="#{bean.direction}">
- <mc:menuItem id="menuItem11" value="Active11:
ajax" submitMode="ajax"
actionListener="#{bean.actionListener}"/>
+ <ddm:dropDownMenu event="#{bean.event}"
id="MenuItem1"
+ verticalOffset="#{bean.verticalOffset}"
+ horizontalOffset="#{bean.horizontalOffset}"
+ popupWidth="#{bean.width}"
+ value="Item One"
+ jointPoint="#{bean.jointPoint}"
+ direction="#{bean.direction}"
+
+ disabledItemStyle="color: green;"
+ disabledItemClass="disabled_item"
+ selectItemClass="select_item"
+ itemStyle="font-weight: bold;">
+ <mc:menuItem id="menuItem11" value="Active11:
ajax"
+ submitMode="ajax"
actionListener="#{bean.actionListener}"
+ disabled="true" />
<mc:menuItem id="menuItem12" value="Active12"
actionListener="#{bean.actionListener}" immediate="true"/>
<mc:menuItem id="menuItem13" value="Active13"
action="#{bean.action}" icon="/images/ico1.gif"/>
<mc:menuItem id="menuItem14"
value="Active14"/>
Modified: trunk/ui/contextMenu/src/main/config/component/contextMenu.xml
===================================================================
--- trunk/ui/contextMenu/src/main/config/component/contextMenu.xml 2008-03-03 17:07:08 UTC
(rev 6500)
+++ trunk/ui/contextMenu/src/main/config/component/contextMenu.xml 2008-03-03 18:08:02 UTC
(rev 6501)
@@ -145,7 +145,8 @@
<classname>java.lang.String</classname>
<description>
Space-separated list of CSS style class(es) that are be applied to selected item of
this component.
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -153,7 +154,8 @@
<classname>java.lang.String</classname>
<description>
CSS style(s) is/are to be applied to disabled item when this component is rendered.
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -161,7 +163,8 @@
<classname>java.lang.String</classname>
<description>
Space-separated list of CSS style class(es) that are be applied to disabled item of
this component
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -169,7 +172,8 @@
<classname>java.lang.String</classname>
<description>
CSS style(s) is/are to be applied to item when this component is rendered.
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -177,7 +181,8 @@
<classname>java.lang.String</classname>
<description>
Space-separated list of CSS style class(es) that are be applied to item of this
component
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
Modified: trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml
===================================================================
--- trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml 2008-03-03 17:07:08
UTC (rev 6500)
+++ trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml 2008-03-03 18:08:02
UTC (rev 6501)
@@ -153,7 +153,8 @@
<classname>java.lang.String</classname>
<description>
Space-separated list of CSS style class(es) that are be applied to selected item of
this component.
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -161,7 +162,8 @@
<classname>java.lang.String</classname>
<description>
CSS style(s) is/are to be applied to disabled item when this component is rendered.
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -169,7 +171,8 @@
<classname>java.lang.String</classname>
<description>
Space-separated list of CSS style class(es) that are be applied to disabled item of
this component
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -177,7 +180,8 @@
<classname>java.lang.String</classname>
<description>
CSS style(s) is/are to be applied to item when this component is rendered.
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
@@ -185,7 +189,8 @@
<classname>java.lang.String</classname>
<description>
Space-separated list of CSS style class(es) that are be applied to item of this
component
- </description>
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
Modified: trunk/ui/menu-components/src/main/config/component/menucomponents.xml
===================================================================
--- trunk/ui/menu-components/src/main/config/component/menucomponents.xml 2008-03-03
17:07:08 UTC (rev 6500)
+++ trunk/ui/menu-components/src/main/config/component/menucomponents.xml 2008-03-03
18:08:02 UTC (rev 6501)
@@ -124,24 +124,25 @@
<property>
<name>selectStyle</name>
<classname>java.lang.String</classname>
- <description>CSS style rules to be applied to selected
- items</description>
+ <description>CSS style rules to be applied to selected
items</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>selectClass</name>
<classname>java.lang.String</classname>
- <description>Class to be applied to selected items</description>
+ <description>Class to be applied to selected items</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>iconStyle</name>
<classname>java.lang.String</classname>
- <description>CSS style rules to be applied to icon
- element</description>
+ <description>CSS style rules to be applied to icon
element</description>
</property>
<property>
<name>iconClass</name>
<classname>java.lang.String</classname>
- <description>Class to be applied to icon element</description>
+ <description>Class to be applied to icon element</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>converter</name>
@@ -260,24 +261,26 @@
<property>
<name>selectClass</name>
<classname>java.lang.String</classname>
- <description>Class to be applied to selected items</description>
+ <description>Class to be applied to selected items</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>selectStyle</name>
<classname>java.lang.String</classname>
- <description>CSS style rules to be applied to selected
- items</description>
+ <description>CSS style rules to be applied to selected
items</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>iconClass</name>
<classname>java.lang.String</classname>
- <description>Class to be applied to icon element</description>
+ <description>Class to be applied to icon element</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>iconStyle</name>
<classname>java.lang.String</classname>
- <description>CSS style rules to be applied to icon
- element</description>
+ <description>CSS style rules to be applied to icon
element</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
&ajax_component_attributes;
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java 2008-03-03
17:07:08 UTC (rev 6500)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java 2008-03-03
18:08:02 UTC (rev 6501)
@@ -45,4 +45,10 @@
public abstract String getIconFolderDisabled();
public abstract void setIconFolderDisabled(String icon);
+
+ public abstract String getStyleClass();
+ public abstract void setStyleClass(String styleClass);
+
+ public abstract String getStyle();
+ public abstract void setStyle(String style);
}
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java 2008-03-03
17:07:08 UTC (rev 6500)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java 2008-03-03
18:08:02 UTC (rev 6501)
@@ -51,5 +51,10 @@
public abstract boolean isDisabled();
public abstract void setDisabled(boolean disabled);
+
+ public abstract String getStyleClass();
+ public abstract void setStyleClass(String styleClass);
+ public abstract String getStyle();
+ public abstract void setStyle(String style);
}
Modified:
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2008-03-03
17:07:08 UTC (rev 6500)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2008-03-03
18:08:02 UTC (rev 6501)
@@ -23,6 +23,8 @@
import java.io.IOException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.ajax4jsf.renderkit.ComponentVariables;
@@ -51,14 +53,39 @@
public void initializeStyleClasses(FacesContext context, UIMenuGroup menuGroup) {
ComponentVariables variables =
ComponentsVariableResolver.getVariables(this, menuGroup);
+ UIComponent parentMenu = getParentMenu(context, menuGroup);
+ Object itemClass = parentMenu.getAttributes().get("itemClass");
+ Object itemStyle = parentMenu.getAttributes().get("itemStyle");
+ Object disabledItemClass =
parentMenu.getAttributes().get("disabledItemClass");
+ Object disabledItemStyle =
parentMenu.getAttributes().get("disabledItemStyle");
+
+ if (null == itemClass) {
+ itemClass = "";
+ }
+ if (null == itemStyle) {
+ itemStyle = "";
+ }
+ if (null == disabledItemClass) {
+ disabledItemClass = "";
+ }
+ if (null == disabledItemStyle) {
+ disabledItemStyle = "";
+ }
+
if (menuGroup.isDisabled()) {
- variables.setVariable("menuGroupClass", "dr-menu-item-disabled
rich-menu-group-disabled");
+ variables.setVariable("menuGroupClass", "dr-menu-item
dr-menu-item-disabled rich-menu-group rich-menu-group-disabled " +
+ itemClass + " " + disabledItemClass + " " +
menuGroup.getStyleClass());
+ variables.setVariable("menuGroupStyle",
+ itemStyle + "; " + disabledItemStyle + "; " +
menuGroup.getStyle());
variables.setVariable("menuGroupMouseMove", "");
variables.setVariable("menuGroupItemIconClass",
"rich-menu-item-icon-disabled");
variables.setVariable("menuGroupItemLabelClass",
"rich-menu-item-label-disabled");
variables.setVariable("menuGroupItemFolderClass",
"rich-menu-item-folder-disabled");
} else {
- variables.setVariable("menuGroupClass", "dr-menu-item-enabled");
+ variables.setVariable("menuGroupClass", "dr-menu-item
dr-menu-item-enabled rich-menu-group " +
+ itemClass + " " + menuGroup.getStyleClass());
+ variables.setVariable("menuGroupStyle",
+ itemStyle + "; " + menuGroup.getStyle());
variables.setVariable("menuGroupMouseMove",
menuGroup.getAttributes().get("onmousemove"));
variables.setVariable("menuGroupItemIconClass",
"rich-menu-item-icon-enabled");
variables.setVariable("menuGroupItemLabelClass",
"rich-menu-item-label");
@@ -105,4 +132,16 @@
String actualIconFolder = menuGroup.isDisabled() ? iconFolderDisabled : iconFolder;
variables.setVariable("actualIconFolder", actualIconFolder);
}
+
+ protected UIComponent getParentMenu(FacesContext context, UIMenuGroup menuGroup) {
+ UIComponent parent = menuGroup.getParent();
+ while (null != parent) {
+ if (parent instanceof org.richfaces.component.MenuComponent) {
+ return parent;
+ }
+ parent = parent.getParent();
+ }
+ throw new FacesException( "Parent menu for menu group (id="
+ + menuGroup.getClientId(context) + ") has not been found.");
+ }
}
Modified:
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2008-03-03
17:07:08 UTC (rev 6500)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2008-03-03
18:08:02 UTC (rev 6501)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.context.ExternalContext;
@@ -34,7 +35,6 @@
import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseId;
-import org.ajax4jsf.Messages;
import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
@@ -246,10 +246,22 @@
Object style = menuItem.getAttributes().get("style");
Object selectStyle = menuItem.getAttributes().get("selectStyle");
+ UIComponent parentMenu = getParentMenu(context, menuItem);
+ Object selectItemStyle =
parentMenu.getAttributes().get("selectItemStyle");
+ Object itemStyle = parentMenu.getAttributes().get("itemStyle");
+
if (null == selectStyle) {
- return "";
+ selectStyle = "";
}
+ if (null == selectItemStyle) {
+ selectItemStyle = "";
+ }
+ if (null == itemStyle) {
+ itemStyle = "";
+ }
+ selectStyle = itemStyle + "; " + selectItemStyle + "; " +
selectStyle;
+
buffer.append("$('" + menuItem.getClientId(context) +
"').style.cssText='");
if (null != style) {
@@ -259,9 +271,75 @@
if (isOnmouseover) {
buffer.append(selectStyle.toString() + ";';");
} else {
- buffer.append("';");
+ buffer.append(itemStyle.toString() + ";';");
}
return buffer.toString();
}
+
+ protected UIComponent getParentMenu(FacesContext context, UIMenuItem menuItem) {
+ UIComponent parent = menuItem.getParent();
+ while (null != parent) {
+ if (parent instanceof org.richfaces.component.MenuComponent) {
+ return parent;
+ }
+ parent = parent.getParent();
+ }
+ throw new FacesException( "Parent menu for menu item (id="
+ + menuItem.getClientId(context) + ") has not been found.");
+ }
+
+ public void initializeStyles(FacesContext context, UIMenuItem menuItem) {
+ ComponentVariables variables =
+ ComponentsVariableResolver.getVariables(this, menuItem);
+ UIComponent parentMenu = getParentMenu(context, menuItem);
+ Object itemClass = parentMenu.getAttributes().get("itemClass");
+ Object itemStyle = parentMenu.getAttributes().get("itemStyle");
+ Object disabledItemClass =
parentMenu.getAttributes().get("disabledItemClass");
+ Object disabledItemStyle =
parentMenu.getAttributes().get("disabledItemStyle");
+ Object selectItemClass = parentMenu.getAttributes().get("selectItemClass");
+ Object selectClass = menuItem.getAttributes().get("selectClass");
+ Object styleClass = menuItem.getStyleClass();
+
+ if (null == itemClass) {
+ itemClass = "";
+ }
+ if (null == itemStyle) {
+ itemStyle = "";
+ }
+ if (null == disabledItemClass) {
+ disabledItemClass = "";
+ }
+ if (null == disabledItemStyle) {
+ disabledItemStyle = "";
+ }
+ if (null == selectItemClass) {
+ selectItemClass = "";
+ }
+ if (null == styleClass) {
+ styleClass = "";
+ }
+ if (null == selectClass) {
+ selectClass = "";
+ }
+
+ if (menuItem.isDisabled()) {
+ variables.setVariable("menuItemClass",
+ "dr-menu-item dr-menu-item-disabled rich-menu-item rich-menu-item-disabled
" +
+ menuItem.getStyleClass() + " " +
+ itemClass + " " + disabledItemClass);
+ variables.setVariable("menuItemStyle",
+ itemStyle + "; " + disabledItemStyle + "; " +
menuItem.getStyle());
+ } else {
+ variables.setVariable("menuItemClass",
+ "dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled "
+
+ styleClass + " " + itemClass);
+ variables.setVariable("menuItemStyle",
+ itemStyle + "; " + menuItem.getStyle());
+ variables.setVariable("menuItemHoverClass",
+ "this.className='dr-menu-item dr-menu-item-hover rich-menu-item
rich-menu-item-hover " +
+ styleClass + " " + selectClass +
+ selectItemClass + "';");
+ }
+ }
}
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
---
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2008-03-03
17:07:08 UTC (rev 6500)
+++
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2008-03-03
18:08:02 UTC (rev 6501)
@@ -24,7 +24,7 @@
<div id="ref#{clientId}"
- class="dr-menu-item #{menuGroupClass} rich-menu-group
#{component.attributes['styleClass']}"
+ class="#{menuGroupClass}"
style="#{component.attributes['style']}"
onmousemove="#{menuGroupMouseMove}">
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2008-03-03
17:07:08 UTC (rev 6500)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2008-03-03
18:08:02 UTC (rev 6501)
@@ -26,18 +26,21 @@
]]>
</jsp:scriptlet>
- <f:call name="initializeResources" />
+ <f:call name="initializeResources" />
+
+ <f:call name="initializeStyles" />
<f:clientid var="clientId"/>
<jsp:scriptlet><![CDATA[
- if (((org.richfaces.component.UIMenuItem) component).isDisabled()) {
+ if (((org.richfaces.component.UIMenuItem) component).isDisabled()) {
+
]]></jsp:scriptlet>
<div id="#{clientId}"
- class="dr-menu-item dr-menu-item-disabled rich-menu-item rich-menu-item-disabled
#{component.attributes['styleClass']}"
- style="#{component.attributes['style']}"
+ class="#{menuItemClass}"
+ style="#{menuItemStyle}"
onclick="Event.stop(event || window.event);">
<jsp:scriptlet><![CDATA[
@@ -52,16 +55,16 @@
]]></jsp:scriptlet>
<div id="#{clientId}"
- class="dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled
#{component.attributes['styleClass']}"
- onmouseout="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item
rich-menu-item-enabled #{component.attributes['styleClass']}';
+ class="#{menuItemClass}"
+ onmouseout="this.className='#{menuItemClass}';
#{onmouseoutInlineStyles}
$('#{clientId}:icon').className='dr-menu-icon rich-menu-item-icon
#{component.attributes['iconClass']}';
$('#{clientId}:anchor').className='rich-menu-item-label';"
- onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-item
rich-menu-item-hover #{component.attributes['styleClass']}
#{component.attributes['selectClass']}';
+ onmouseover="#{menuItemHoverClass};
#{onmouseoverInlineStyles}
$('#{clientId}:icon').className='dr-menu-icon dr-menu-icon-selected
rich-menu-item-icon rich-menu-item-icon-selected
#{component.attributes['iconClass']}';
$('#{clientId}:anchor').className='rich-menu-item-label
rich-menu-item-label-selected';"
- style="#{component.attributes['style']}"
+ style="#{menuItemStyle}"
onclick="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item
rich-menu-item-enabled #{component.attributes['styleClass']}'; #{onselect}
#{onclick}; Event.stop(event);"
onmouseup="Event.stop(event);
#{component.attributes['onmouseup']}">
<f:call name="utils.encodeAttributes">