Author: sergeyhalipov
Date: 2007-05-29 08:35:36 -0400 (Tue, 29 May 2007)
New Revision: 929
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
Log:
Compact templates removing duplicated sections for enabled/disabled states.
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
---
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-05-29
12:35:15 UTC (rev 928)
+++
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-05-29
12:35:36 UTC (rev 929)
@@ -52,6 +52,24 @@
context, menuGroup);
}
+ public void initializeStyleClasses(FacesContext context, UIMenuGroup menuGroup) {
+ ComponentVariables variables =
+ ComponentsVariableResolver.getVariables(this, menuGroup);
+ if (menuGroup.isDisabled()) {
+ variables.setVariable("menuGroupClass", "dr-menu-item-disabled
rich-menu-group-disabled");
+ 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("menuGroupMouseMove",
menuGroup.getAttributes().get("onmousemove"));
+ variables.setVariable("menuGroupItemIconClass",
"rich-menu-item-icon-enabled");
+ variables.setVariable("menuGroupItemLabelClass",
"rich-menu-item-label");
+ variables.setVariable("menuGroupItemFolderClass",
"rich-menu-item-folder");
+ }
+ }
+
public void initializeResources(FacesContext context, UIMenuGroup menuGroup)
throws IOException {
ComponentVariables variables =
@@ -70,6 +88,9 @@
}
variables.setVariable("iconDisabled", iconDisabled);
+
+ String actualIcon = menuGroup.isDisabled() ? iconDisabled : icon;
+ variables.setVariable("actualIcon", actualIcon);
String iconFolder = ViewUtil.getResourceURL(menuGroup.getIconFolder());
if (iconFolder == null) {
@@ -84,5 +105,8 @@
}
variables.setVariable("iconFolderDisabled", iconFolderDisabled);
+
+ String actualIconFolder = menuGroup.isDisabled() ? iconFolderDisabled : iconFolder;
+ variables.setVariable("actualIconFolder", actualIconFolder);
}
}
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
---
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-05-29
12:35:15 UTC (rev 928)
+++
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-05-29
12:35:36 UTC (rev 929)
@@ -96,6 +96,7 @@
if (menuItem.isDisabled()) {
variables.setVariable("iconDisabledClasses",
"dr-menu-icon-disabled rich-menu-item-icon-disabled");
+ variables.setVariable("menuItemLabelClass",
"rich-menu-item-label rich-menu-item-label-disabled");
} else {
variables.setVariable("onmouseoutInlineStyles",
@@ -127,6 +128,7 @@
if (resource.length() > 0) {
variables.setVariable("onclick", scriptValue.toString());
}
+ variables.setVariable("menuItemLabelClass",
"rich-menu-item-label");
}
}
Modified:
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
---
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-05-29
12:35:15 UTC (rev 928)
+++
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-05-29
12:35:36 UTC (rev 929)
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<f:root
-
xmlns:f="http://ajax4jsf.org/cdk/template"
- xmlns:c="
http://java.sun.com/jsf/core"
- xmlns:ui="
http://ajax4jsf.org/cdk/ui"
- xmlns:u="
http://ajax4jsf.org/cdk/u"
- xmlns:x="
http://ajax4jsf.org/cdk/x"
- xmlns:vcp="
http://jsf.exadel.com/vcp"
- baseclass="org.richfaces.renderkit.html.MenuGroupRendererBase"
- class="org.richfaces.renderkit.html.MenuGroupRenderer"
- component="org.richfaces.component.UIMenuGroup"
- >
+
xmlns:f="http://ajax4jsf.org/cdk/template"
+ xmlns:c="
http://java.sun.com/jsf/core"
+ xmlns:ui="
http://ajax4jsf.org/cdk/ui"
+ xmlns:u="
http://ajax4jsf.org/cdk/u"
+ xmlns:x="
http://ajax4jsf.org/cdk/x"
+ xmlns:vcp="
http://jsf.exadel.com/vcp"
+ baseclass="org.richfaces.renderkit.html.MenuGroupRendererBase"
+ class="org.richfaces.renderkit.html.MenuGroupRenderer"
+ component="org.richfaces.component.UIMenuGroup" >
+
<h:styles>css/menucomponents.xcss</h:styles>
<h:scripts>
@@ -18,115 +18,71 @@
</h:scripts>
<f:clientid var="clientId"/>
- <f:call name="initializeResources" />
+ <f:call name="initializeResources" />
+ <f:call name="initializeStyleClasses" />
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif"
var="spacer" />
- <jsp:scriptlet><![CDATA[
- boolean disabled = ((Boolean)
component.getAttributes().get("disabled")).booleanValue();
- if (! disabled) {
- ]]></jsp:scriptlet>
- <div id="ref#{clientId}"
- class="dr-menu-item dr-menu-item-enabled rich-menu-group
#{component.attributes['styleClass']}"
- style="#{component.attributes['style']}"
- onmousemove="#{component.attributes['onmousemove']}">
-
- <span id="ref#{clientId}:icon"
- class="dr-menu-icon rich-menu-item-icon
#{component.attributes['iconClass']}">
- <jsp:scriptlet>
- <![CDATA[if(component.getFacet("icon")!=null &&
component.getFacet("icon").isRendered()) {]]>
- </jsp:scriptlet>
- <u:insertFacet name="icon" />
- <jsp:scriptlet>
- <![CDATA[} else if (component.getAttributes().get("icon")!=null)
{]]>
- </jsp:scriptlet>
- <img width="16" height="16"
- style="#{component.attributes['iconStyle']}"
- src="#{icon}"/>
- <jsp:scriptlet>
- <![CDATA[} else {]]>
- </jsp:scriptlet>
- <img width="16" height="16"
- style="#{component.attributes['iconStyle']}"
- src="#{spacer}"/>
- <jsp:scriptlet><![CDATA[}]]></jsp:scriptlet>
- </span>
- <span id="ref#{clientId}:anchor"
class="rich-menu-item-label">#{component.attributes['value']}</span>
-
- <jsp:scriptlet>
- <![CDATA[if(component.getFacet("iconFolder")!=null &&
component.getFacet("iconFolder").isRendered()) {]]>
- </jsp:scriptlet>
- <div id="ref#{clientId}:folder" class="dr-menu-node
rich-menu-item-folder">
- <u:insertFacet name="iconFolder" />
- </div>
- <jsp:scriptlet>
- <![CDATA[} else if (component.getAttributes().get("iconFolder")!=null)
{]]>
- </jsp:scriptlet>
- <div id="ref#{clientId}:folder" class="dr-menu-node
rich-menu-item-folder #{component.attributes['iconClass']}">
- <img width="16" height="16"
- style="#{component.attributes['iconStyle']}"
- src="#{iconFolder}"/>
- </div>
- <jsp:scriptlet>
- <![CDATA[} else {]]>
- </jsp:scriptlet>
- <div id="ref#{clientId}:folder" class="dr-menu-node
dr-menu-node-icon rich-menu-item-folder"/>
- <jsp:scriptlet>
- <![CDATA[}]]>
- </jsp:scriptlet>
- </div>
-
- <jsp:scriptlet><![CDATA[} else {]]></jsp:scriptlet>
- <div id="ref#{clientId}"
- class="dr-menu-item dr-menu-item-disabled rich-menu-group
rich-menu-group-disabled #{component.attributes['styleClass']}"
- style="#{component.attributes['style']}">
-
- <span id="ref#{clientId}:icon"
- class="dr-menu-icon rich-menu-item-icon-disabled
#{component.attributes['iconClass']}">
- <jsp:scriptlet>
- <![CDATA[if(component.getFacet("iconDisabled")!=null &&
component.getFacet("iconDisabled").isRendered()) {]]>
- </jsp:scriptlet>
- <u:insertFacet name="iconDisabled" />
- <jsp:scriptlet>
- <![CDATA[} else if
(component.getAttributes().get("iconDisabled")!=null) {]]>
- </jsp:scriptlet>
- <img width="16" height="16"
- style="#{component.attributes['iconStyle']}"
- src="#{iconDisabled}"/>
- <jsp:scriptlet>
- <![CDATA[} else {]]>
- </jsp:scriptlet>
- <img width="16" height="16"
- style="#{component.attributes['iconStyle']}"
- src="#{spacer}"/>
- <jsp:scriptlet><![CDATA[}]]></jsp:scriptlet>
- </span>
-
- <span
class="rich-menu-item-label-disabled">#{component.attributes['value']}</span>
+ <div id="ref#{clientId}"
+ class="dr-menu-item #{menuGroupClass} rich-menu-group
#{component.attributes['styleClass']}"
+ style="#{component.attributes['style']}"
+ onmousemove="#{menuGroupMouseMove}">
+
+ <span id="ref#{clientId}:icon"
+ class="dr-menu-icon #{menuGroupItemIconClass}
#{component.attributes['iconClass']}">
+ <jsp:scriptlet>
+ <![CDATA[
+ boolean disabled = ((Boolean)
component.getAttributes().get("disabled")).booleanValue();
+ String iconFacet = disabled ? "iconDisabled" : "icon";
+ ComponentsVariableResolver.getVariables(this,
component).setVariable("iconFacet", iconFacet);
+ if(component.getFacet(iconFacet)!=null &&
component.getFacet(iconFacet).isRendered()) {
+ ]]>
+ </jsp:scriptlet>
+ <u:insertFacet name="#{iconFacet}" />
+ <jsp:scriptlet>
+ <![CDATA[} else if (component.getAttributes().get(iconFacet)!=null) {]]>
+ </jsp:scriptlet>
+ <img width="16" height="16"
+ style="#{component.attributes['iconStyle']}"
+ src="#{actualIcon}"/>
+ <jsp:scriptlet>
+ <![CDATA[} else {]]>
+ </jsp:scriptlet>
+ <img width="16" height="16"
+ style="#{component.attributes['iconStyle']}"
+ src="#{spacer}"/>
+ <jsp:scriptlet><![CDATA[}]]></jsp:scriptlet>
+ </span>
- <jsp:scriptlet>
- <![CDATA[if(component.getFacet("iconFolderDisabled")!=null &&
component.getFacet("iconFolderDisabled").isRendered()) {]]>
- </jsp:scriptlet>
- <div id="ref#{clientId}:folder" class="dr-menu-node
rich-menu-item-folder-disabled">
- <u:insertFacet name="iconFolderDisabled" />
- </div>
- <jsp:scriptlet>
- <![CDATA[} else if
(component.getAttributes().get("iconFolderDisabled")!=null) {]]>
- </jsp:scriptlet>
- <div id="ref#{clientId}:folder" class="dr-menu-node
rich-menu-item-folder-disabled #{component.attributes['iconClass']}">
- <img width="16" height="16"
- style="#{component.attributes['iconStyle']}"
- src="#{iconFolderDisabled}"/>
- </div>
- <jsp:scriptlet>
- <![CDATA[} else {]]>
- </jsp:scriptlet>
- <div id="ref#{clientId}:folder" class="dr-menu-node
dr-menu-node-icon rich-menu-item-folder-disabled"/>
- <jsp:scriptlet>
- <![CDATA[}]]>
- </jsp:scriptlet>
+ <span id="ref#{clientId}:anchor"
class="#{menuGroupItemLabelClass}">
+ #{component.attributes['value']}
+ </span>
+
+ <jsp:scriptlet>
+ <![CDATA[
+ String iconFolder = disabled ? "iconFolderDisabled" :
"iconFolder";
+ ComponentsVariableResolver.getVariables(this,
component).setVariable("iconFolder", iconFolder);
+ if(component.getFacet(iconFolder)!=null &&
component.getFacet(iconFolder).isRendered()) {
+ ]]>
+ </jsp:scriptlet>
+ <div id="ref#{clientId}:folder" class="dr-menu-node
#{menuGroupItemFolderClass}">
+ <u:insertFacet name="#{iconFolder}" />
+ </div>
+ <jsp:scriptlet>
+ <![CDATA[} else if (component.getAttributes().get(iconFolder)!=null) {]]>
+ </jsp:scriptlet>
+ <div id="ref#{clientId}:folder" class="dr-menu-node
#{menuGroupItemFolderClass} #{component.attributes['iconClass']}">
+ <img width="16" height="16"
+ style="#{component.attributes['iconStyle']}"
+ src="#{actualIconFolder}"/>
</div>
-
- <jsp:scriptlet><![CDATA[}]]></jsp:scriptlet>
+ <jsp:scriptlet>
+ <![CDATA[} else {]]>
+ </jsp:scriptlet>
+ <div id="ref#{clientId}:folder" class="dr-menu-node
dr-menu-node-icon #{menuGroupItemFolderClass}"/>
+ <jsp:scriptlet>
+ <![CDATA[}]]>
+ </jsp:scriptlet>
+ </div>
</f:root>
\ No newline at end of file
Modified:
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
---
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-05-29
12:35:15 UTC (rev 928)
+++
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-05-29
12:35:36 UTC (rev 929)
@@ -77,32 +77,13 @@
</span>
- <jsp:scriptlet><![CDATA[
- if (((org.richfaces.component.UIMenuItem) component).isDisabled()) {
- ]]></jsp:scriptlet>
-
- <span id="#{clientId}:disabled"
- class="rich-menu-item-label rich-menu-item-label-disabled"
+ <span id="#{clientId}:anchor"
+ class="#{menuItemLabelClass}"
#{component.attributes['value']}
<f:call name="renderChildren" />
</span>
-
- <jsp:scriptlet><![CDATA[
- } else {
- ]]></jsp:scriptlet>
-
- <span id="#{clientId}:anchor"
- class="rich-menu-item-label">
- #{component.attributes['value']}
- <f:call name="renderChildren" />
- </span>
-
- <jsp:scriptlet><![CDATA[
- }
- ]]></jsp:scriptlet>
-
-
+
<jsp:scriptlet><![CDATA[
if (((org.richfaces.component.UIMenuItem) component).isDisabled()) {
]]></jsp:scriptlet>