Author: dbiatenia
Date: 2007-05-18 09:07:07 -0400 (Fri, 18 May 2007)
New Revision: 806
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
Log:
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-18
13:06:45 UTC (rev 805)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-18
13:07:07 UTC (rev 806)
@@ -34,7 +34,11 @@
public abstract String getMode();
public abstract void setMode(String mode);
public abstract String getIconExpanded();
- public abstract void setIconExpanded(String iconExpanded);
+ public abstract void setIconExpanded(String expanded);
+
+ public abstract boolean isExpanded();
+ public abstract void setExpanded(boolean expanded);
+
public abstract String getIconCollapsed();
public abstract void setIconCollapsed(String iconCollapsed);
public abstract String getIconDisabled();
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-18
13:06:45 UTC (rev 805)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18
13:07:07 UTC (rev 806)
@@ -97,14 +97,14 @@
Object iconCollapsed = component.getAttributes().get("iconCollapsed");
Object iconExpanded = component.getAttributes().get("iconExpanded");
-
- if (( isOpened ? iconExpanded : iconCollapsed ).equals("")){
+ String icon = (isOpened ? iconExpanded : iconCollapsed).toString();
+ if (icon.equals("")){
source = getIconByType("custom", isTopLevel,context, component);
} else {
if (iconNode.equals("none")){
return;
} else {
- source =
getIconByType(data.equals("spacer")?"custom":iconCollapsed.toString(),isTopLevel,context,component);
+ source = getIconByType(data.equals("spacer") ? "custom" : icon,
isTopLevel, context, component);
}
}
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18
13:06:45 UTC (rev 805)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18
13:07:07 UTC (rev 806)
@@ -24,13 +24,13 @@
import java.io.IOException;
import java.util.Map;
-import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.component.panelmenu.UIPanelMenuGroup;
import org.richfaces.component.panelmenu.UIPanelMenuItem;
@@ -156,5 +156,29 @@
.append(item.getDisabledStyle());
return styleBuffer.toString();
}
+
+ @Override
+ public String getHideStyle(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ if (!(component.getParent() instanceof UIPanelMenu)) {
+ CSSFormat format = new CSSFormat();
+ format.add("display", "none");
+ if(component.getParent() instanceof UIPanelMenuGroup) {
+ UIPanelMenuGroup parent = (UIPanelMenuGroup)component.getParent();
+ PanelMenuGroupRenderer renderer = (PanelMenuGroupRenderer)
context.getRenderKit().getRenderer(parent.getFamily(), parent.getRendererType());
+ try {
+ if ( renderer.isOpened(context, parent).equals("opened") ){
+ return "";
+ } else
+ return format.toString();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else return format.toString();
+ }
+ return "";
+ }
+
}
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-18
13:06:45 UTC (rev 805)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18
13:07:07 UTC (rev 806)
@@ -34,6 +34,7 @@
import org.ajax4jsf.framework.skin.Skin;
import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
+import org.richfaces.component.panelmenu.UIPanelMenuGroup;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrow;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowDown;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowUp;
@@ -160,10 +161,34 @@
if (value.equals("opened")) {
return "opened";
}
+ } else {
+ if(component instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)component).isExpanded() ){
+ return "opened";
+ } else {
+ //check expanded attributes in children groups, if exists
+ return isChildrenExpanded(component) ? "opened" : "closed";
+ }
+ }
}
return "closed";
}
+ public boolean isChildrenExpanded(UIComponent component){
+ if (component.getChildren() != null){
+ for(Object child : component.getChildren()){
+ if(child instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)child).isExpanded() ){
+ return true;
+ } else {
+ return isChildrenExpanded((UIComponent)child);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
protected boolean isSubmitted(FacesContext context, UIComponent component){
boolean submitted = false;
String clientId = component.getClientId(context);
@@ -177,4 +202,5 @@
}
return submitted;
}
+
}
Show replies by date