Author: nbelaevski
Date: 2007-05-28 15:26:41 -0400 (Mon, 28 May 2007)
New Revision: 912
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/richfaces/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-242 in progress
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java
===================================================================
---
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java 2007-05-28
19:24:36 UTC (rev 911)
+++
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java 2007-05-28
19:26:41 UTC (rev 912)
@@ -33,4 +33,16 @@
public abstract boolean isDisabled();
public abstract void setDisabled(boolean disabled);
+
+ public abstract String getIcon();
+ public abstract void setIcon(String icon);
+
+ public abstract String getIconDisabled();
+ public abstract void setIconDisabled(String icon);
+
+ public abstract String getIconFolder();
+ public abstract void setIconFolder(String icon);
+
+ public abstract String getIconFolderDisabled();
+ public abstract void setIconFolderDisabled(String icon);
}
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-28
19:24:36 UTC (rev 911)
+++
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-05-28
19:26:41 UTC (rev 912)
@@ -21,13 +21,24 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.ComponentVariables;
+import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.framework.util.command.CommandScriptBuilder;
+import org.richfaces.component.MenuComponent;
import org.richfaces.component.UIMenuGroup;
+import org.richfaces.component.UIMenuItem;
+import org.richfaces.component.util.ViewUtil;
public class MenuGroupRendererBase extends HeaderResourcesRendererBase {
-
+
protected Class getComponentClass() {
return UIMenuGroup.class;
}
@@ -35,5 +46,43 @@
public boolean getRendersChildren() {
return true;
}
+
+ private String getSpacerUri(FacesContext context, UIMenuGroup menuGroup) {
+ return getResource("images/spacer.gif").getUri(
+ context, menuGroup);
+ }
+ public void initializeResources(FacesContext context, UIMenuGroup menuGroup)
+ throws IOException {
+ ComponentVariables variables =
+ ComponentsVariableResolver.getVariables(this, menuGroup);
+
+ String icon = ViewUtil.getResourceURL(menuGroup.getIcon());
+ if (icon == null) {
+ icon = getSpacerUri(context, menuGroup);
+ }
+
+ variables.setVariable("icon", icon);
+
+ String iconDisabled = ViewUtil.getResourceURL(menuGroup.getIconDisabled());
+ if (iconDisabled == null) {
+ iconDisabled = getSpacerUri(context, menuGroup);
+ }
+
+ variables.setVariable("iconDisabled", iconDisabled);
+
+ String iconFolder = ViewUtil.getResourceURL(menuGroup.getIconFolder());
+ if (iconFolder == null) {
+ iconFolder = getSpacerUri(context, menuGroup);
+ }
+
+ variables.setVariable("iconFolder", iconFolder);
+
+ String iconFolderDisabled =
ViewUtil.getResourceURL(menuGroup.getIconFolderDisabled());
+ if (iconFolderDisabled == null) {
+ iconFolderDisabled = getSpacerUri(context, menuGroup);
+ }
+
+ variables.setVariable("iconFolderDisabled", iconFolderDisabled);
+ }
}
Modified:
trunk/richfaces/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss
===================================================================
---
trunk/richfaces/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss 2007-05-28
19:24:36 UTC (rev 911)
+++
trunk/richfaces/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss 2007-05-28
19:26:41 UTC (rev 912)
@@ -37,16 +37,21 @@
.dr-menu-item a {
text-decoration : none;
}
+
.dr-menu-node {
position : absolute;
- background : url(node.gif) no-repeat top;
width : 7px;
height : 7px;
+ font-size : 1px;
+ right : 0px;
+}
+
+.dr-menu-node-icon {
top : 7px;
right : 6px;
- font-size : 1px;
}
-.dr-menu-item-disabled .dr-menu-node {
+
+.dr-menu-item-disabled .dr-menu-node-icon {
background-position : bottom;
}
]]>
@@ -74,7 +79,7 @@
<u:style name="background-color" skin="tipBackgroundColor" />
</u:selector>
-<u:selector name=".dr-menu-node">
+<u:selector name=".dr-menu-node-icon">
<u:style name="background-image">
<f:resource
f:key="org.richfaces.renderkit.html.images.MenuNodeImage"/>
</u:style>
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-28
19:24:36 UTC (rev 911)
+++
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-05-28
19:26:41 UTC (rev 912)
@@ -18,6 +18,7 @@
</h:scripts>
<f:clientid var="clientId"/>
+ <f:call name="initializeResources" />
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif"
var="spacer" />
<jsp:scriptlet><![CDATA[
@@ -40,7 +41,7 @@
</jsp:scriptlet>
<img width="16" height="16"
style="#{component.attributes['iconStyle']}"
- src="#{component.attributes['icon']}"/>
+ src="#{icon}"/>
<jsp:scriptlet>
<![CDATA[} else {]]>
</jsp:scriptlet>
@@ -51,8 +52,28 @@
</span>
<span id="ref#{clientId}:anchor"
class="rich-menu-item-label">#{component.attributes['value']}</span>
- <div id="ref#{clientId}:folder" class="dr-menu-node
rich-menu-item-folder"/>
-
+
+ <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="iconFolderDisabled" />
+ </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>
@@ -71,7 +92,7 @@
</jsp:scriptlet>
<img width="16" height="16"
style="#{component.attributes['iconStyle']}"
- src="#{component.attributes['iconDisabled']}"/>
+ src="#{iconDisabled}"/>
<jsp:scriptlet>
<![CDATA[} else {]]>
</jsp:scriptlet>
@@ -82,7 +103,28 @@
</span>
<span
class="rich-menu-item-label-disabled">#{component.attributes['value']}</span>
- <div id="ref#{clientId}:folder" class="dr-menu-node
rich-menu-item-folder-disabled"/>
+
+ <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>
</div>
<jsp:scriptlet><![CDATA[}]]></jsp:scriptlet>
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
---
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-05-28
19:24:36 UTC (rev 911)
+++
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-05-28
19:26:41 UTC (rev 912)
@@ -232,7 +232,7 @@
assertNotNull(div);
assertEquals("div", div.getNodeName());
classAttr = div.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-menu-node rich-menu-item-folder"));
+ assertTrue(classAttr.contains("dr-menu-node dr-menu-node-icon
rich-menu-item-folder"));
}