Author: sergeyhalipov
Date: 2007-05-16 08:09:45 -0400 (Wed, 16 May 2007)
New Revision: 778
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
Log:
Panel Menu: Some improvements in look and feel and script.
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-16
09:28:44 UTC (rev 777)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-16
12:09:45 UTC (rev 778)
@@ -97,17 +97,5 @@
writer.writeAttribute("height",String.valueOf(h), null);
writer.endElement("img");
}
-
- public String isOpened(FacesContext context, UIComponent component)throws IOException {
- String clientId = component.getClientId(context);
- Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
- Object value = requestParameterMap.get("panelMenuState"+clientId);
- if (value != null) {
- if (value.equals("opened")) {
- return "opened";
- }
- }
- return "closed";
- }
}
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-16
09:28:44 UTC (rev 777)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-16
12:09:45 UTC (rev 778)
@@ -243,19 +243,19 @@
String sourceIconNodeClosed = getIconByType(iconNodeClosed, isTopLevel,context,
component);
String sourceIconNodeOpened = getIconByType(iconNodeOpened, isTopLevel,context,
component);
- String customIconOpened = "";
- String customIconClosed = "";
- String customIconOpenedSource = "";
- String customIconClosedSource = "";
+ String iconExpanded = "";
+ String iconCollapsed = "";
+ String iconExpandedSource = "";
+ String iconCollapsedSource = "";
String customIcon = "";
String customIconSource = "";
if (component instanceof UIPanelMenuGroup){
- customIconOpened = (String) component.getAttributes().get("iconOpened");
- customIconClosed = (String) component.getAttributes().get("iconClosed");
- customIconOpenedSource =
getIconByType(customIconOpened,isTopLevel,context,component);
- customIconClosedSource =
getIconByType(customIconClosed,isTopLevel,context,component);
+ iconExpanded = ((UIPanelMenuGroup)component).getIconExpanded();
+ iconCollapsed = ((UIPanelMenuGroup)component).getIconCollapsed();
+ iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
+ iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
} else if (component instanceof UIPanelMenuItem){
@@ -265,30 +265,40 @@
}
if (component instanceof UIPanelMenuGroup){
- if
(!iconNodeClosed.equals("")&&!iconNodeOpened.equals("")){
+ if (null != iconCollapsed && !"".equals(iconCollapsed))
+ iconNodeClosed = iconCollapsed;
+ if (null != iconExpanded && !"".equals(iconExpanded))
+ iconNodeOpened = iconExpanded;
+ if
(!"".equals(iconNodeClosed)&&!"".equals(iconNodeOpened)){
if
(!iconNodeClosed.equals("custom")&&!iconNodeOpened.equals("custom")){
- if(component.getAttributes().get("iconOpened").equals("")&&component.getAttributes().get("iconClosed").equals("")){
- buffer.append(","+'"'+
(sourceIconNodeOpened.equals("")?customIconOpenedSource:sourceIconNodeOpened) +
'"').append(","+'"'+(sourceIconNodeClosed.equals("")?customIconClosedSource:sourceIconNodeClosed)+'"'+";");
- } else
if(component.getAttributes().get("iconOpened").equals("")){
- buffer.append(","+'"'+customIconClosedSource+'"').append(","+'"'+customIconClosedSource+'"'+";");
- } else if
(component.getAttributes().get("iconClosed").equals("")) {
- buffer.append(","+'"'+customIconOpenedSource+'"').append(","+'"'+customIconOpenedSource+'"'+";");
+ if("".equals(iconExpanded)&&"".equals(iconCollapsed)){
+ buffer.append(","+'"'+
("".equals(sourceIconNodeOpened)?iconExpandedSource:sourceIconNodeOpened) +
'"').append(","+
+ '"'+("".equals(sourceIconNodeClosed)?iconCollapsedSource:sourceIconNodeClosed)+'"'+";");
+ } else if("".equals(iconExpanded)){
+ buffer.append(","+'"'+iconCollapsedSource+'"').append(","+'"'+iconCollapsedSource+'"');
+ } else if ("".equals(iconCollapsed)) {
+ buffer.append(","+'"'+iconExpandedSource+'"').append(","+'"'+iconExpandedSource+'"');
} else {
- buffer.append(","+'"'+customIconOpenedSource+'"').append(","+'"'+customIconClosedSource+'"'+";");
+ buffer.append(","+'"'+iconExpandedSource+'"').append(","+'"'+iconCollapsedSource+'"');
}
} else if (iconNodeClosed.equals("custom")){
- buffer.append(",\"" + (customIconOpened.equals("")?
sourceIconNodeOpened : customIconOpenedSource) +
'"').append(",\"" + (customIconClosed.equals("")?
PANEL_MENU_SPACER_ICON : customIconClosedSource)+"\";");
+ buffer.append(",\"" + ("".equals(iconExpanded)?
sourceIconNodeOpened : iconExpandedSource) + '"').
+ append(",\"" + ("".equals(iconCollapsed)?
PANEL_MENU_SPACER_ICON : iconCollapsedSource)+"\";");
} else if (iconNodeOpened.equals("custom")){
- buffer.append(",\"" + (customIconOpened.equals("")?
PANEL_MENU_SPACER_ICON : customIconOpenedSource) +
'"').append(",\"" + (customIconClosed.equals("")?
sourceIconNodeClosed : customIconClosedSource)+"\";");
+ buffer.append(",\"" + ("".equals(iconExpanded)?
PANEL_MENU_SPACER_ICON : iconExpandedSource) + '"').
+ append(",\"" + ("".equals(iconCollapsed)?
sourceIconNodeClosed : iconCollapsedSource)+"\";");
} else{
- buffer.append(",\"" + (customIconOpened.equals("")?
PANEL_MENU_SPACER_ICON : customIconOpenedSource) +
'"').append(",\"" + (customIconClosed.equals("")?
PANEL_MENU_SPACER_ICON : customIconClosedSource)+"\";");
+ buffer.append(",\"" + ("".equals(iconExpanded)?
PANEL_MENU_SPACER_ICON : iconExpandedSource) + '"')
+ .append(",\"" + ("".equals(iconCollapsed)?
PANEL_MENU_SPACER_ICON : iconCollapsedSource)+"\";");
}
} else {
- buffer.append(",null, null");
+ String iconCollapsedScript = ("".equals(iconNodeClosed)) ? "null"
: "\"" + iconCollapsedSource + "\"";
+ String iconExpandedScript = ("".equals(iconNodeOpened)) ? "null"
: "\"" + iconExpandedSource + "\"";
+ buffer.append("," + iconExpandedScript + "," +
iconCollapsedScript);
}
buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\");");
} else {
- if (!iconItem.equals("")){
+ if (!"".equals(iconItem)){
if (!iconItem.equals("custom")){
if(component.getAttributes().get("icon").equals("")){
buffer.append(","+'"'+sourceIconItem+'"').append(","+'"'+sourceIconItem+'"'+");");
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-16
09:28:44 UTC (rev 777)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-16
12:09:45 UTC (rev 778)
@@ -22,6 +22,7 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -30,6 +31,7 @@
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrow;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowDown;
@@ -132,8 +134,12 @@
return (UIPanelMenu) parent;
}
- public String getHideStyle(FacesContext context, UIComponent component)
- throws IOException {
+ public String getHideStyle(FacesContext context, UIComponent component) {
+ if (!(component.getParent() instanceof UIPanelMenu)) {
+ CSSFormat format = new CSSFormat();
+ format.add("display", "none");
+ return format.toString();
+ }
return "";
}
@@ -143,4 +149,17 @@
context.getResponseWriter().write(value.toString());
}
}
+
+
+ public String isOpened(FacesContext context, UIComponent component)throws IOException {
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ Object value = requestParameterMap.get("panelMenuState"+clientId);
+ if (value != null) {
+ if (value.equals("opened")) {
+ return "opened";
+ }
+ }
+ return "closed";
+ }
}
Modified:
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
===================================================================
---
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-05-16
09:28:44 UTC (rev 777)
+++
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-05-16
12:09:45 UTC (rev 778)
@@ -12,7 +12,7 @@
<f:clientid var="clientId"/>
- <tr id="tdhide#{clientId}" style="#{hideStyle}" >
+ <tr id="tdhide#{clientId}" style="#{this:getHideStyle(context,
component)}" >
<td>
<table cellpadding="0" cellspacing="0" border="0"
width="100%"
id="tablehide#{clientId}"
@@ -30,7 +30,7 @@
<td style="width:100%" class="item_content"
id="icon#{clientId}" >
<input type="hidden" name="panelMenuState#{clientId}"
- value="#{isOpened}" >
+ value="#{this:isOpened(context, component)}" >
</input>
<input type="hidden" name="panelMenuAction#{clientId}"
value="" >
Modified:
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
===================================================================
---
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-05-16
09:28:44 UTC (rev 777)
+++
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-05-16
12:09:45 UTC (rev 778)
@@ -12,7 +12,7 @@
<f:clientid var="clientId"/>
- <tr id="tdhide#{clientId}" style="hideStyle" >
+ <tr id="tdhide#{clientId}" style="#{this:getHideStyle(context,
component)}" >
<td>
<table cellpadding="0" cellspacing="0" border="0"
width="100%"
onclick="#{onClick}"
@@ -32,9 +32,9 @@
</td>
<td style="width:100%" class="item_content">
<input type="hidden" name="panelMenuState#{clientId}"
- value="#{isOpened}" >
+ value="#{this:isOpened(context, component)}" >
</input>
- <input type="hidden" name="panelMenuActionn#{clientId}"
+ <input type="hidden" name="panelMenuAction#{clientId}"
value="" >
</input>
<f:call name="insertValue"/>