JBoss Rich Faces SVN: r1166 - in trunk/sandbox/panelmenu/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-06-13 12:46:27 -0400 (Wed, 13 Jun 2007)
New Revision: 1166
Added:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
Removed:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java
Modified:
trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
Log:
Fix some problems with name conversation.
Modified: trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml 2007-06-13 16:46:27 UTC (rev 1166)
@@ -5,7 +5,7 @@
<name>org.richfaces.PanelMenu</name>
<family>org.richfaces.PanelMenu</family>
<description>Defines the menu on the page and the set of the child elements properties in layout.</description>
- <superclass>org.richfaces.component.panelmenu.UIPanelMenu</superclass>
+ <superclass>org.richfaces.component.UIPanelMenu</superclass>
<classname>org.richfaces.component.html.HtmlPanelMenu</classname>
<renderer generate="true" override="true">
<name>org.richfaces.PanelMenuRenderer</name>
@@ -319,7 +319,7 @@
<name>org.richfaces.PanelMenuGroup</name>
<family>org.richfaces.PanelMenuGroup</family>
<description>Defines expandable group of items inside the panel menu or other group.</description>
- <superclass>org.richfaces.component.panelmenu.UIPanelMenuGroup</superclass>
+ <superclass>org.richfaces.component.UIPanelMenuGroup</superclass>
<classname>org.richfaces.component.html.HtmlPanelMenuGroup</classname>
<renderer generate="true" override="true">
<name>org.richfaces.PanelMenuGroupRenderer</name>
@@ -470,7 +470,7 @@
<name>org.richfaces.PanelMenuItem</name>
<family>org.richfaces.PanelMenuItem</family>
<description>Defines single Item inside popup list.</description>
- <superclass>org.richfaces.component.panelmenu.UIPanelMenuItem</superclass>
+ <superclass>org.richfaces.component.UIPanelMenuItem</superclass>
<classname>org.richfaces.component.html.HtmlPanelMenuItem</classname>
<renderer generate="true" override="true">
<name>org.richfaces.PanelMenuItemRenderer</name>
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java (from rev 1162, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -0,0 +1,294 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+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.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuGroup;
+import org.richfaces.component.UIPanelMenuItem;
+import org.richfaces.renderkit.html.PanelMenuGroupRenderer;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevron;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevronDown;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevronUp;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconDisc;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconGrid;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconSpacer;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangle;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleDown;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleUp;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+
+/**
+ * @author hans
+ *
+ */
+public abstract class PanelMenuRendererBase extends HeaderResourcesRendererBase {
+
+ public final static String PANEL_MENU_SPACER_ICON_NAME = "spacer";
+
+ public void insertTDs(FacesContext context , UIComponent component) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ int level = calculateLevel(component);
+ //StringBuffer buffer = new StringBuffer();
+ String src = getIconByType("custom",false,context,component);
+ int w = 16; //width(context);
+
+ for (int i=0;i<level;i++){
+ writer.startElement(HTML.td_ELEM, component);
+ writer.startElement("img", component);
+ writer.writeAttribute("src", src, null);
+ writer.writeAttribute("alt", "", null);
+ writer.writeAttribute("hspace", "0", null);
+ writer.writeAttribute("vspace", "0", null);
+ writer.writeAttribute("height", String.valueOf(w), null);
+ writer.writeAttribute("width", String.valueOf(w), null);
+ writer.writeAttribute("style", "display:block; ", null);
+ writer.endElement("img");
+ writer.endElement(HTML.td_ELEM);
+ }
+ }
+
+ protected int calculateLevel (UIComponent component){
+ int level = 0;
+ UIComponent parent = component.getParent();
+ while(parent != null){
+ if(parent instanceof UIPanelMenu){
+ return level;
+ } else if(parent instanceof UIPanelMenuGroup){
+ level++;
+ }
+ parent = parent.getParent();
+ }
+ return level;
+ }
+
+ /**
+ * If icon type is a pre-defined value, return corresponding image, otherwise
+ * otherwise
+ * @param iconType
+ * @param context
+ * @param component
+ * @return URI of requested image
+ */
+ protected String getIconByType(String iconType, boolean isTopLevel, FacesContext context,
+ UIComponent component){
+
+ String source = "";
+ String color = "";
+ Skin skin = getSkin(context);
+
+ if (isTopLevel){
+ color = (String) skin.getParameter(context,"panelmenu.headerBulletColor");
+ } else {
+ color = (String) skin.getParameter(context,"panelmenu.itemBulletColor");
+ }
+ if(iconType != null && !iconType.equals("none")){
+ if (iconType.equals("custom")){
+ source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
+ } else if (iconType.equals("spacer")){
+ source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
+ } else if (iconType.equals("triangle")) {
+ source = getResource(PanelMenuIconTriangle.class.getName()).getUri(context, color);
+ } else if (iconType.equals("triangleDown")) {
+ source = getResource(PanelMenuIconTriangleDown.class.getName()).getUri(context, color);
+ } else if (iconType.equals("triangleUp")) {
+ source = getResource(PanelMenuIconTriangleUp.class.getName()).getUri(context, color);
+ } else if (iconType.equals("chevron")) {
+ source = getResource(PanelMenuIconChevron.class.getName()).getUri(context, color);
+ } else if (iconType.equals("chevronUp")) {
+ source = getResource(PanelMenuIconChevronUp.class.getName()).getUri(context, color);
+ } else if (iconType.equals("chevronDown")) {
+ source = getResource(PanelMenuIconChevronDown.class.getName()).getUri(context, color);
+// } else if (iconType.equals("square")) {
+// source = getResource(PanelMenuIconSquare.class.getName()).getUri(context, color);
+ } else if (iconType.equals("disc")) {
+ source = getResource(PanelMenuIconDisc.class.getName()).getUri(context, color);
+ } else if (iconType.equals("grid")) {
+ source = getResource(PanelMenuIconGrid.class.getName()).getUri(context, color);
+ } else {
+ //TODO by nick - dima - TemplateContext is deprecated and shouldn't be used
+ source = (String)getUtils().encodeResourceURL(new TemplateContext(this,context,component),iconType);
+ }
+ }
+ return source;
+ }
+
+ protected UIPanelMenu findMenu (UIComponent component){
+ if (component instanceof UIPanelMenu) return (UIPanelMenu)component;
+ UIComponent parent = component;
+ while(parent != null){
+ if(parent instanceof UIPanelMenu){
+ return (UIPanelMenu) parent;
+ }
+ parent = parent.getParent();
+ }
+ return (UIPanelMenu) parent;
+ }
+
+ public String getHideStyle(FacesContext context, UIComponent component) {
+ 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) ){
+ return "";
+ } else
+ return format.toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else return format.toString();
+ }
+ return "";
+ }
+
+ public void insertValue(FacesContext context, UIComponent component) throws IOException {
+ Object value = component.getAttributes().get("value");
+ if (value!=null){
+ context.getResponseWriter().write(value.toString());
+ }
+ }
+
+ protected boolean isChildrenExpanded(UIComponent component){
+ if (component.getChildren() != null){
+ Iterator itr = component.getChildren().iterator();
+ while(itr.hasNext()){
+ UIComponent child = (UIComponent)itr.next();
+ if(child instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)child).isExpanded() ){
+ return true;
+ } else {
+ return isChildrenExpanded(child);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ protected boolean isParentDisabled(UIComponent component){
+ boolean returnValue = false;
+ UIComponent parent = component.getParent();
+ if(parent instanceof UIPanelMenuGroup){
+ UIPanelMenuGroup parentGroup = (UIPanelMenuGroup)parent;
+ if(parentGroup.isDisabled()){
+ returnValue = true;
+ } else {
+ returnValue = isParentDisabled(parentGroup);
+ }
+ }
+ return returnValue;
+ }
+
+ protected boolean isSubmitted(FacesContext context, UIComponent component){
+ boolean submitted = false;
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+
+ Object value = requestParameterMap.get("panelMenuAction"+clientId);
+ if (clientId!=null&&value!=null){
+ if (value.equals(clientId)) {
+ submitted = true;
+ }
+ }
+ return submitted;
+ }
+
+ protected String getItemMode(UIComponent component) {
+ String parentExpandMode = findMenu(component).getExpandMode();
+ String parentMode = findMenu(component).getMode();
+ if (null == parentMode || "".equals(parentMode))
+ parentMode = "server";
+ if (null == parentExpandMode || "".equals(parentExpandMode))
+ parentExpandMode = "none";
+ String mode = "none";
+ if (component instanceof UIPanelMenuGroup) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup) component;
+ if (null != group.getMode() && ! "".equals(group.getMode()))
+ mode = group.getMode();
+ else
+ mode = parentExpandMode;
+ } else if (component instanceof UIPanelMenuItem) {
+ UIPanelMenuItem item = (UIPanelMenuItem) component;
+ if (null != item.getMode() && ! "".equals(item.getMode()))
+ mode = item.getMode();
+ else
+ mode = parentMode;
+ }
+ return mode;
+ }
+
+ /**
+ *
+ * @param component
+ * @return
+ */
+ public boolean isTopLevel(UIComponent component){
+ UIComponent parent = component.getParent();
+ while( !(parent instanceof UIPanelMenu) && !(parent instanceof UIPanelMenuGroup)) {
+ parent = parent.getParent();
+ }
+ if(parent instanceof UIPanelMenu){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param writer
+ * @param iconType
+ * @param imageSrc
+ * @param component
+ * @throws IOException
+ */
+ public void drawIcon(ResponseWriter writer, String iconType, String imageSrc, UIComponent component) throws IOException{
+ if (iconType != null && !iconType.equals("") && !iconType.equals("none")){
+ int h = 16; //width(context);
+ writer.startElement("img", component);
+ writer.writeAttribute("src", imageSrc, null);
+ writer.writeAttribute("alt", "", null);
+ writer.writeAttribute("vspace", "0", null);
+ writer.writeAttribute("hspace", "0", null);
+ writer.writeAttribute("style", "display:block; ", null);
+ writer.writeAttribute("width", String.valueOf(h), null);
+ writer.writeAttribute("height", String.valueOf(h), null);
+ writer.endElement("img");
+ }
+
+ }
+
+}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -1,262 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.Map;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.ConverterException;
-import javax.faces.event.ActionEvent;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.richfaces.component.UIPanelMenu;
-import org.richfaces.component.UIPanelMenuGroup;
-import org.richfaces.component.UISwitchablePanel;
-
-public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
-
- protected Class getComponentClass() {
- return UIPanelMenuGroup.class;
- }
-
- protected void doDecode(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- Map requestMap =context.getExternalContext().getRequestParameterMap();
- UIPanelMenuGroup group = ((UIPanelMenuGroup)component);
-
- if(requestMap.containsKey("panelMenuState"+clientId)){
- Object property = requestMap.get("panelMenuState"+clientId);
- if (property.equals("opened")) {
- group.setSubmittedValue("true");
- } else if (property.equals("closed")) {
- group.setSubmittedValue("false");
- }
-
- }
- if(isSubmitted(context, component)){
- new ActionEvent(component).queue();
- if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
- new AjaxEvent(component).queue();
- }
- }
- }
-
- public void insertImage(FacesContext context, UIComponent component, Object data)
- throws IOException {
-
- String from = (String)data;
- String align = "";
-
- UIPanelMenu panelMenu = findMenu(component);
- boolean isTopLevel = isTopLevel(component);
-
- if (isTopLevel){
- align = panelMenu.getIconGroupTopPosition();
- } else {
- align = panelMenu.getIconGroupPosition();
- }
-
- if (align.equalsIgnoreCase(from)){
- image(context,component);
- } else {
- String iconType = PANEL_MENU_SPACER_ICON_NAME;
- String imageSrc = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
- }
- }
-
- private void image(FacesContext context, UIComponent component )throws IOException {
- ResponseWriter writer = context.getResponseWriter();
-
- UIPanelMenu panelMenu = findMenu(component);
- if(panelMenu == null){
- return;
- }
- UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup)component;
- boolean isTopLevel = isTopLevel(panelMenuGroup);
-
- boolean isOpened = isOpened(context,component);
-
-
- String defaultIconNodeClosed = null;
-
- if(isTopLevel){
- if(panelMenuGroup.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- }
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
- } else {
- if(panelMenuGroup.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
-
- String defaultIconNodeOpened = null;
-
- if(isTopLevel){
- defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
- if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
- } else {
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
-
- String iconExpanded = "";
- String iconCollapsed = "";
-
- iconExpanded = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconExpanded();
- iconCollapsed = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconCollapsed();
-
- String icon = null;
- if(isOpened){
- if(iconExpanded != null && !iconExpanded.equals("")){
- if(iconExpanded.equals("none")){
- return;
- } else {
- icon = iconExpanded;
- }
- } else {
- icon = defaultIconNodeOpened;
- }
- } else {
- if(iconCollapsed!= null && !iconCollapsed.equals("")){
- if(iconCollapsed.equals("none")){
- return;
- } else {
- icon = iconCollapsed;
- }
- } else {
- icon = defaultIconNodeClosed;
- }
- }
- String source = getIconByType(icon, isTopLevel, context, component);
- drawIcon(writer, icon, source, component);
- }
-
- public String getFullStyleClass(FacesContext context, UIComponent component) {
- StringBuffer classBuffer = new StringBuffer("");
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if (!parentMenu.isDisabled() && !group.isDisabled()) {
- if (calculateLevel(group) == 0)
- classBuffer.append(parentMenu.getTopGroupClass() + " ");
- else
- classBuffer.append(parentMenu.getGroupClass() + " ");
- classBuffer.append(group.getStyleClass());
- } else
- classBuffer.append(parentMenu.getDisabledGroupClass() + " ")
- .append(group.getDisabledClass());
- return classBuffer.toString();
- }
-
- public String getFullStyle(FacesContext context, UIComponent component) {
- StringBuffer styleBuffer = new StringBuffer("");
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if (!group.isDisabled()) {
- if (calculateLevel(group) == 0)
- styleBuffer.append(parentMenu.getTopGroupStyle() + "; ");
- else
- styleBuffer.append(parentMenu.getGroupStyle() + "; ");
- styleBuffer.append(group.getStyle());
- } else
- styleBuffer.append(parentMenu.getDisabledGroupStyle() + "; ")
- .append(group.getDisabledStyle());
- return styleBuffer.toString();
- }
-
- public void insertLabel(FacesContext context, UIComponent component) throws IOException {
- Object label = component.getAttributes().get("label");
- if (label!=null){
- context.getResponseWriter().write(label.toString());
- }
- }
-
- public Object getConvertedValue(FacesContext context,
- UIComponent component, Object submittedValue)
- throws ConverterException {
-
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- if(group.getConverter() != null){
- return group.getConverter().getAsObject(context, component, (String)submittedValue);
- } else {
- return submittedValue;
- }
-
- }
-
- public boolean isOpened(FacesContext context, UIComponent component)throws IOException {
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
-
- Boolean value = (Boolean)group.getValue();
- if (value != null) {
- return value.booleanValue();
- } else {
- boolean isParentDisabled = isParentDisabled(component);
- if(component instanceof UIPanelMenuGroup){
- if( ((UIPanelMenuGroup)component).isExpanded() && !((UIPanelMenuGroup)component).isDisabled() && !isParentDisabled ){
- return true;
- } else {
- //check expanded attributes in children groups, if exists
- boolean isChildrenExpanded = isChildrenExpanded(component);
- return isChildrenExpanded && !isParentDisabled && !((UIPanelMenuGroup)component).isDisabled();// ? "opened" : "closed";
- }
- }
- }
- return false;
- }
-
- public String getLabelClass(FacesContext context, UIComponent component) {
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if(!group.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-group-self-label rich-pmenu-top-group-self-label";
- } else return "rich-pmenu-group-self-label";
- }
- return "";
- }
-
- public String getIconClass(FacesContext context, UIComponent component) {
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if(!group.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-group-self-icon rich-pmenu-top-group-self-icon";
- } else return "rich-pmenu-group-self-icon";
- }
- return "";
- }
-
-
-}
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -0,0 +1,263 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.ActionEvent;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.richfaces.component.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuGroup;
+import org.richfaces.component.UISwitchablePanel;
+import org.richfaces.renderkit.PanelMenuRendererBase;
+
+public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
+
+ protected Class getComponentClass() {
+ return UIPanelMenuGroup.class;
+ }
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map requestMap =context.getExternalContext().getRequestParameterMap();
+ UIPanelMenuGroup group = ((UIPanelMenuGroup)component);
+
+ if(requestMap.containsKey("panelMenuState"+clientId)){
+ Object property = requestMap.get("panelMenuState"+clientId);
+ if (property.equals("opened")) {
+ group.setSubmittedValue("true");
+ } else if (property.equals("closed")) {
+ group.setSubmittedValue("false");
+ }
+
+ }
+ if(isSubmitted(context, component)){
+ new ActionEvent(component).queue();
+ if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
+ new AjaxEvent(component).queue();
+ }
+ }
+ }
+
+ public void insertImage(FacesContext context, UIComponent component, Object data)
+ throws IOException {
+
+ String from = (String)data;
+ String align = "";
+
+ UIPanelMenu panelMenu = findMenu(component);
+ boolean isTopLevel = isTopLevel(component);
+
+ if (isTopLevel){
+ align = panelMenu.getIconGroupTopPosition();
+ } else {
+ align = panelMenu.getIconGroupPosition();
+ }
+
+ if (align.equalsIgnoreCase(from)){
+ image(context,component);
+ } else {
+ String iconType = PANEL_MENU_SPACER_ICON_NAME;
+ String imageSrc = getIconByType(iconType, isTopLevel, context, component);
+ drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
+ }
+ }
+
+ private void image(FacesContext context, UIComponent component )throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ UIPanelMenu panelMenu = findMenu(component);
+ if(panelMenu == null){
+ return;
+ }
+ UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup)component;
+ boolean isTopLevel = isTopLevel(panelMenuGroup);
+
+ boolean isOpened = isOpened(context,component);
+
+
+ String defaultIconNodeClosed = null;
+
+ if(isTopLevel){
+ if(panelMenuGroup.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ }
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+ } else {
+ if(panelMenuGroup.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+
+ String defaultIconNodeOpened = null;
+
+ if(isTopLevel){
+ defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
+ if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+ } else {
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+
+ String iconExpanded = "";
+ String iconCollapsed = "";
+
+ iconExpanded = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconExpanded();
+ iconCollapsed = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconCollapsed();
+
+ String icon = null;
+ if(isOpened){
+ if(iconExpanded != null && !iconExpanded.equals("")){
+ if(iconExpanded.equals("none")){
+ return;
+ } else {
+ icon = iconExpanded;
+ }
+ } else {
+ icon = defaultIconNodeOpened;
+ }
+ } else {
+ if(iconCollapsed!= null && !iconCollapsed.equals("")){
+ if(iconCollapsed.equals("none")){
+ return;
+ } else {
+ icon = iconCollapsed;
+ }
+ } else {
+ icon = defaultIconNodeClosed;
+ }
+ }
+ String source = getIconByType(icon, isTopLevel, context, component);
+ drawIcon(writer, icon, source, component);
+ }
+
+ public String getFullStyleClass(FacesContext context, UIComponent component) {
+ StringBuffer classBuffer = new StringBuffer("");
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if (!parentMenu.isDisabled() && !group.isDisabled()) {
+ if (calculateLevel(group) == 0)
+ classBuffer.append(parentMenu.getTopGroupClass() + " ");
+ else
+ classBuffer.append(parentMenu.getGroupClass() + " ");
+ classBuffer.append(group.getStyleClass());
+ } else
+ classBuffer.append(parentMenu.getDisabledGroupClass() + " ")
+ .append(group.getDisabledClass());
+ return classBuffer.toString();
+ }
+
+ public String getFullStyle(FacesContext context, UIComponent component) {
+ StringBuffer styleBuffer = new StringBuffer("");
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if (!group.isDisabled()) {
+ if (calculateLevel(group) == 0)
+ styleBuffer.append(parentMenu.getTopGroupStyle() + "; ");
+ else
+ styleBuffer.append(parentMenu.getGroupStyle() + "; ");
+ styleBuffer.append(group.getStyle());
+ } else
+ styleBuffer.append(parentMenu.getDisabledGroupStyle() + "; ")
+ .append(group.getDisabledStyle());
+ return styleBuffer.toString();
+ }
+
+ public void insertLabel(FacesContext context, UIComponent component) throws IOException {
+ Object label = component.getAttributes().get("label");
+ if (label!=null){
+ context.getResponseWriter().write(label.toString());
+ }
+ }
+
+ public Object getConvertedValue(FacesContext context,
+ UIComponent component, Object submittedValue)
+ throws ConverterException {
+
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ if(group.getConverter() != null){
+ return group.getConverter().getAsObject(context, component, (String)submittedValue);
+ } else {
+ return submittedValue;
+ }
+
+ }
+
+ public boolean isOpened(FacesContext context, UIComponent component)throws IOException {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+
+ Boolean value = (Boolean)group.getValue();
+ if (value != null) {
+ return value.booleanValue();
+ } else {
+ boolean isParentDisabled = isParentDisabled(component);
+ if(component instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)component).isExpanded() && !((UIPanelMenuGroup)component).isDisabled() && !isParentDisabled ){
+ return true;
+ } else {
+ //check expanded attributes in children groups, if exists
+ boolean isChildrenExpanded = isChildrenExpanded(component);
+ return isChildrenExpanded && !isParentDisabled && !((UIPanelMenuGroup)component).isDisabled();// ? "opened" : "closed";
+ }
+ }
+ }
+ return false;
+ }
+
+ public String getLabelClass(FacesContext context, UIComponent component) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if(!group.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-group-self-label rich-pmenu-top-group-self-label";
+ } else return "rich-pmenu-group-self-label";
+ }
+ return "";
+ }
+
+ public String getIconClass(FacesContext context, UIComponent component) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if(!group.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-group-self-icon rich-pmenu-top-group-self-icon";
+ } else return "rich-pmenu-group-self-icon";
+ }
+ return "";
+ }
+
+
+}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -1,190 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.richfaces.component.UIPanelMenu;
-import org.richfaces.component.UIPanelMenuItem;
-import org.richfaces.component.UISwitchablePanel;
-
-public class PanelMenuItemRenderer extends PanelMenuRendererBase {
- protected Class getComponentClass() {
- return UIPanelMenuItem.class;
- }
-
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context,UIComponent component) throws IOException {
-
- }
- protected void doDecode(FacesContext context, UIComponent component) {
- if(isSubmitted(context, component)) {
- new ActionEvent(component).queue();
- if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
- new AjaxEvent(component).queue();
- } else {
-
- }
- }
- }
-
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
-
- }
-
- /*
- public String getOnClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- return ";PanelMenuStorage['" + clientId + "'].trigger(event);";
- }
- */
- public void insertImage(FacesContext context, UIComponent component, Object data) throws IOException {
- String from = (String)data;
- UIPanelMenu panelMenu = findMenu(component);
- if(panelMenu == null){
- return;
- }
- String align = "";
- UIPanelMenuItem panelMenuItem = (UIPanelMenuItem)component;
- boolean isTopLevel = isTopLevel(panelMenuItem);
-
- if (isTopLevel){
- align = panelMenu.getIconItemTopPosition();
- } else {
- align = panelMenu.getIconItemPosition();
- }
-
- if (align.equalsIgnoreCase(from)){
- image(context,component);
- } else {
- String iconType = PANEL_MENU_SPACER_ICON_NAME;
- String imageSrc = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
- }
- }
-
- private void image(FacesContext context, UIComponent component)
- throws IOException{
-
- UIPanelMenu panelMenu = findMenu(component);
- ResponseWriter writer = context.getResponseWriter();
- boolean isTopLevel = isTopLevel(component);
- String source = null;
- String iconType = null;
- UIPanelMenuItem item = (UIPanelMenuItem)component;
-
- String defaultItemIcon = null;
- String customItemIcon = null;
-
- if(isTopLevel){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconTopDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconTopItem();
- }
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- } else {
- //isTopLevel == false
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- }
-
- customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
-
- if(customItemIcon == null || customItemIcon.equals("")){
- iconType = defaultItemIcon;
- } else iconType = customItemIcon;
-
- source = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(writer, iconType, source, component);
- }
-
-
- public String getFullStyleClass(FacesContext context, UIComponent component) {
- StringBuffer classBuffer = new StringBuffer("");
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if (!parentMenu.isDisabled() && !item.isDisabled()) {
- if (calculateLevel(item) == 0) {
- classBuffer.append(parentMenu.getTopItemClass()).append(" ");
- classBuffer.append("rich-pmenu-top-item ");
- } else
- classBuffer.append(parentMenu.getItemClass() + " ");
- classBuffer.append(item.getStyleClass());
- } else
- classBuffer.append(parentMenu.getDisabledItemClass() + " ")
- .append(item.getDisabledClass());
- return classBuffer.toString();
- }
-
- public String getFullStyle(FacesContext context, UIComponent component) {
- StringBuffer styleBuffer = new StringBuffer("");
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if (!item.isDisabled()) {
- if (calculateLevel(item) == 0)
- styleBuffer.append(parentMenu.getTopItemStyle() + "; ");
- else
- styleBuffer.append(parentMenu.getItemStyle() + "; ");
- styleBuffer.append(item.getStyle());
- } else
- styleBuffer.append(parentMenu.getDisabledItemStyle() + "; ")
- .append(item.getDisabledStyle());
- return styleBuffer.toString();
- }
-
- public String getLabelClass(FacesContext context, UIComponent component) {
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if(!item.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-item-label rich-pmenu-top-item-label";
- } else return "rich-pmenu-item-label";
- }
- return "";
- }
-
- public String getIconClass(FacesContext context, UIComponent component) {
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if(!item.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-item-icon rich-pmenu-top-item-icon";
- } else return "rich-pmenu-item-icon";
- }
- return "";
- }
-}
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -0,0 +1,191 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.richfaces.component.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuItem;
+import org.richfaces.component.UISwitchablePanel;
+import org.richfaces.renderkit.PanelMenuRendererBase;
+
+public class PanelMenuItemRenderer extends PanelMenuRendererBase {
+ protected Class getComponentClass() {
+ return UIPanelMenuItem.class;
+ }
+
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,UIComponent component) throws IOException {
+
+ }
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if(isSubmitted(context, component)) {
+ new ActionEvent(component).queue();
+ if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
+ new AjaxEvent(component).queue();
+ } else {
+
+ }
+ }
+ }
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ }
+
+ /*
+ public String getOnClick(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ return ";PanelMenuStorage['" + clientId + "'].trigger(event);";
+ }
+ */
+ public void insertImage(FacesContext context, UIComponent component, Object data) throws IOException {
+ String from = (String)data;
+ UIPanelMenu panelMenu = findMenu(component);
+ if(panelMenu == null){
+ return;
+ }
+ String align = "";
+ UIPanelMenuItem panelMenuItem = (UIPanelMenuItem)component;
+ boolean isTopLevel = isTopLevel(panelMenuItem);
+
+ if (isTopLevel){
+ align = panelMenu.getIconItemTopPosition();
+ } else {
+ align = panelMenu.getIconItemPosition();
+ }
+
+ if (align.equalsIgnoreCase(from)){
+ image(context,component);
+ } else {
+ String iconType = PANEL_MENU_SPACER_ICON_NAME;
+ String imageSrc = getIconByType(iconType, isTopLevel, context, component);
+ drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
+ }
+ }
+
+ private void image(FacesContext context, UIComponent component)
+ throws IOException{
+
+ UIPanelMenu panelMenu = findMenu(component);
+ ResponseWriter writer = context.getResponseWriter();
+ boolean isTopLevel = isTopLevel(component);
+ String source = null;
+ String iconType = null;
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+
+ String defaultItemIcon = null;
+ String customItemIcon = null;
+
+ if(isTopLevel){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconTopDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconTopItem();
+ }
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ } else {
+ //isTopLevel == false
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ }
+
+ customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
+
+ if(customItemIcon == null || customItemIcon.equals("")){
+ iconType = defaultItemIcon;
+ } else iconType = customItemIcon;
+
+ source = getIconByType(iconType, isTopLevel, context, component);
+ drawIcon(writer, iconType, source, component);
+ }
+
+
+ public String getFullStyleClass(FacesContext context, UIComponent component) {
+ StringBuffer classBuffer = new StringBuffer("");
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if (!parentMenu.isDisabled() && !item.isDisabled()) {
+ if (calculateLevel(item) == 0) {
+ classBuffer.append(parentMenu.getTopItemClass()).append(" ");
+ classBuffer.append("rich-pmenu-top-item ");
+ } else
+ classBuffer.append(parentMenu.getItemClass() + " ");
+ classBuffer.append(item.getStyleClass());
+ } else
+ classBuffer.append(parentMenu.getDisabledItemClass() + " ")
+ .append(item.getDisabledClass());
+ return classBuffer.toString();
+ }
+
+ public String getFullStyle(FacesContext context, UIComponent component) {
+ StringBuffer styleBuffer = new StringBuffer("");
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if (!item.isDisabled()) {
+ if (calculateLevel(item) == 0)
+ styleBuffer.append(parentMenu.getTopItemStyle() + "; ");
+ else
+ styleBuffer.append(parentMenu.getItemStyle() + "; ");
+ styleBuffer.append(item.getStyle());
+ } else
+ styleBuffer.append(parentMenu.getDisabledItemStyle() + "; ")
+ .append(item.getDisabledStyle());
+ return styleBuffer.toString();
+ }
+
+ public String getLabelClass(FacesContext context, UIComponent component) {
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if(!item.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-item-label rich-pmenu-top-item-label";
+ } else return "rich-pmenu-item-label";
+ }
+ return "";
+ }
+
+ public String getIconClass(FacesContext context, UIComponent component) {
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if(!item.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-item-icon rich-pmenu-top-item-icon";
+ } else return "rich-pmenu-item-icon";
+ }
+ return "";
+ }
+}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -1,436 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.richfaces.component.UIPanelMenu;
-import org.richfaces.component.UIPanelMenuGroup;
-import org.richfaces.component.UIPanelMenuItem;
-
-public class PanelMenuRenderer extends PanelMenuRendererBase {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- return UIComponent.class;
- }
-
- public void insertScript(FacesContext context, UIComponent component)
- throws IOException {
-
- StringBuffer buffer = new StringBuffer();
- StringBuffer panelMenu = new StringBuffer();
- List flatList = new LinkedList();
- Map levels = new HashMap();
-
- boolean expandSingle = ((UIPanelMenu)component).isExpandSingle();
-
- flatten(component.getChildren(), flatList, levels, 0);
-
- panelMenu
- .append("new PanelMenu('")
- .append(component.getClientId(context).toString())
- .append("',")
- .append(new Boolean(expandSingle).toString())
- .append(");\n");
-
- for (Iterator iter = flatList.iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
- boolean childDisabled;
- if (!((UIPanelMenu)component).isDisabled())
- childDisabled = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
- else
- childDisabled = true;
- boolean childRendered = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
- boolean parentRendered = true;
- if (! (child.getParent() instanceof UIPanelMenu))
- parentRendered = child.getParent() instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child.getParent()).isRendered() : ((UIPanelMenuItem)child.getParent()).isRendered();
- if (!parentRendered){
- child.getAttributes().put("rendered",Boolean.FALSE);
- }
-
- UIPanelMenu parentMenu = findMenu(child);
-
- String event = parentMenu.getEvent();
- if ("".equals(event))
- event = "click";
- else if (event.startsWith("on"))
- event = event.substring(2);
-
- String onopen = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
- parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
- String onclose = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
- parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
- String hoveredStyle = (child instanceof UIPanelMenuGroup ?
- parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
- + ";" + (child instanceof UIPanelMenuGroup ?
- ((UIPanelMenuGroup)child).getHoverStyle() : ((UIPanelMenuItem)child).getHoverStyle());
- String hoveredClass = (child instanceof UIPanelMenuGroup ?
- parentMenu.getHoveredGroupClass() : parentMenu.getHoveredItemClass())
- + " " + (child instanceof UIPanelMenuGroup ?
- ((UIPanelMenuGroup)child).getHoverClass() : ((UIPanelMenuItem)child).getHoverClass());
- String [] hoveredStyles = hoveredStyle.split(";");
- String [] hoveredClasses = hoveredClass.split(" ");
-
- String mode = getItemMode(child);
- Object target = child.getAttributes().get("target");
- String targetString;
- if (null == target)
- targetString = "";
- else
- targetString = target.toString();
-
-
-
- if (childRendered && parentRendered){
- if ( !isParentDisabled(child) ){
- buffer
- .append("new PanelMenuItem({myId:'")
- .append((String) child.getClientId(context))
- .append("',parentId:'")
- .append((String) child.getParent().getClientId(context))
- .append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
- .append(",onopen:"+("".equals(onopen) ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+("".equals(onclose) ? "\"\"" : "\"" + onclose + "\""))
- .append(",event:\"" + event + "\"")
- .append(",mode:\"" + mode + "\"")
- .append(",target:\"" + targetString + "\"")
- .append(",disabled:" +
- new Boolean(childDisabled).toString())
- .append("},{");
-
-
- for (int i = 0; i < hoveredStyles.length; i++)
- if (!"".equals(hoveredStyles[i])) {
- String [] temp = hoveredStyles[i].split(":");
- String cssName = temp[0].trim();
- String cssValue = temp[1].trim();
- buffer.append("\"" + cssName + "\": \"" + cssValue + "\"");
- if (i != hoveredStyles.length - 1)
- buffer.append(",");
- }
-
- buffer.append("},");
- if (hoveredClasses.length > 0) {
- buffer.append("new Array(");
- for (int i = 0; i < hoveredClasses.length; i++)
- if (!"".equals(hoveredClasses[i])) {;
- buffer.append("\"" + hoveredClasses[i] + "\"");
- if (i != hoveredClasses.length - 1)
- buffer.append(",");
- }
- buffer.append("),");
- } else
- buffer.append("new Array(),");
-
- buffer.append(levels.get(child.getClientId(context)));
- switchOnImagesIfNeeded(context,child,buffer);
-
- addActionIfNeeded(context,child,buffer);
-
- setExpandedIfNeeded(context,child,buffer);
-
- addAjaxFunction(context,child,buffer);
-
- addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
-
- String iconPos = "left";
- boolean isTopLevel = isTopLevel(child);
- if(child instanceof UIPanelMenuGroup){
- iconPos = isTopLevel ? parentMenu.getIconGroupTopPosition() : parentMenu.getIconGroupPosition();
- } else {
- iconPos = isTopLevel ? parentMenu.getIconItemTopPosition() : parentMenu.getIconItemPosition();
- }
-
- buffer.append(","+'"'+iconPos+'"');
-
- addImages(buffer,context,child,component.getClientId(context).toString());
-
- buffer.append(");\n");
- }
- } else {
- continue;
- }
- }
- }
- StringBuffer ret = new StringBuffer();
- ret.append("<script ");
- ret.append("type=\"text/javascript\" ");
- ret.append("id =\"script" + component.getClientId(context)+"\">\n");
- ret.append(panelMenu);
- ret.append(buffer);
- ret.append("\n</script>");
-
- ResponseWriter writer = context.getResponseWriter();
- writer.write(ret.toString());
- }
-
- public void flatten(List children, List flatList, Map levels,int initialLevel) {
- FacesContext context = FacesContext.getCurrentInstance();
- if (children != null) {
- for (Iterator iter = children.iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof UIPanelMenu){
- continue;
- }
- flatList.add(child);
- levels.put(child.getClientId(context), new Integer(initialLevel));
- flatten(child.getChildren(), flatList, levels, initialLevel + 1);
- }
- }
- }
-
- private void switchOnImagesIfNeeded(FacesContext context, UIComponent child, StringBuffer buffer)throws IOException {
- boolean isToplevel = isTopLevel(child);
- String customIconOpened = "";
- String customIconClosed = "";
-
- UIPanelMenu panelMenu = findMenu(child);
- if(panelMenu == null){
- return;
- }
- String iconOpened = isToplevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
- String iconClosed = isToplevel ? panelMenu.getIconCollapsedTopGroup() : panelMenu.getIconCollapsedGroup();
-
- try {
- customIconOpened = (String)child.getAttributes().get("iconOpened");
- customIconClosed = (String)child.getAttributes().get("iconClosed");
- } catch (Exception e) {}
-
- if (child instanceof UIPanelMenuItem){
- buffer.append(",false");
- } else {
- if (iconClosed.equals("custom")&&iconOpened.equals("custom")){
- if (customIconClosed.equals("")&&customIconOpened.equals("")){
- buffer.append(",false");
- } else {
- buffer.append(",true");
- }
- } else {
- buffer.append(",true");
- }
- }
- }
-
- private void addActionIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
- //TODO by nick - dima - use CommandScriptBuilder
- if (child instanceof UIPanelMenuItem){
- if (((UIPanelMenuItem)child).getAction() == null){
- buffer.append(",false");
- } else {
- buffer.append(",true");
- }
- } else {
- if (((UIPanelMenuGroup)child).getAction()!=null&&!((UIPanelMenuGroup)child).getAction().equals("")){
- buffer.append(",'panelMenuNodeAction'");
- } else {
- buffer.append(",false");
- }
- }
- }
-
- private void setExpandedIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
- if(child instanceof UIPanelMenuItem){
- buffer.append(",false");
- } else {
- UIPanelMenuGroup group = (UIPanelMenuGroup)child;
- if(group.getValue() != null){
- buffer.append(",").append(group.getValue().toString());
- } else {
- PanelMenuGroupRenderer r = (PanelMenuGroupRenderer)context.getRenderKit().getRenderer(group.getFamily(), group.getRendererType());
- boolean isNodeOpened;
- try {
- isNodeOpened = r.isOpened(context, child);
- } catch (IOException e) {
- // TODO Auto-generated catch block
-// e.printStackTrace();
- isNodeOpened = false;
- }
- buffer.append(",").append(String.valueOf(isNodeOpened));
- }
- }
- }
-
- private void addImages(StringBuffer buffer,FacesContext context,UIComponent component,String id){
- UIPanelMenu panelMenu = findMenu(component);
- if(panelMenu == null){
- return;
- }
- boolean isTopLevel = isTopLevel(component);
-
- final String PANEL_MENU_SPACER_ICON = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel,context, component);
-
- if(component instanceof UIPanelMenuItem){
- UIPanelMenuItem item = (UIPanelMenuItem)component;
-
- String defaultItemIcon = null;
- String defaultItemIconSrc = null;
- String customItemIcon = null;
- String customIconSource = null;
-
- if(isTopLevel){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconTopDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconTopItem();
- }
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- } else {
- //isTopLevel == false
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- }
-
- if(defaultItemIcon != null && defaultItemIcon.equals("none")){
- defaultItemIconSrc = PANEL_MENU_SPACER_ICON;
- } else {
- defaultItemIconSrc = getIconByType(defaultItemIcon, isTopLevel,context, component);
- }
-
-
- customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
- if(customItemIcon != null && customItemIcon.equals("none")){
- customIconSource = PANEL_MENU_SPACER_ICON;
- } else {
- customIconSource = getIconByType(customItemIcon, isTopLevel,context, component);
- }
-
- if(customItemIcon != null && !customItemIcon.equals("")){
- buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+" ");
- } else if (defaultItemIcon != null && !defaultItemIcon.equals("")){
- buffer.append(","+'"'+defaultItemIconSrc+'"').append(","+'"'+defaultItemIconSrc+'"'+" ");
- } else {
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+" ");
- }
- buffer.append(",\"\" ");
-
- } else if(component instanceof UIPanelMenuGroup){
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
-
- String defaultIconNodeClosed = isTopLevel ? (group.isDisabled() ? panelMenu.getIconTopDisableGroup() : panelMenu.getIconCollapsedTopGroup()) : (group.isDisabled() ? panelMenu.getIconDisabledGroup() : panelMenu.getIconCollapsedGroup());
-
- if(isTopLevel){
- if(group.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- }
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
- } else {
- if(group.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
-
- String defaultIconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
-
- if(isTopLevel){
- defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
- if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
- } else {
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
-
- String defaultIconNodeClosedSrc = getIconByType(defaultIconNodeClosed, isTopLevel,context, component);
- String defaultIconNodeOpenedSrc = getIconByType(defaultIconNodeOpened, isTopLevel,context, component);
-
- String iconExpanded = "";
- String iconCollapsed = "";
- String iconExpandedSource = "";
- String iconCollapsedSource = "";
-
- iconExpanded = group.isDisabled() ? group.getIconDisabled() : group.getIconExpanded();
- iconCollapsed = group.isDisabled() ? group.getIconDisabled() : group.getIconCollapsed();
- iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
- iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
-
- if(iconExpanded != null && !iconExpanded.equals("")){
- buffer.append(","+'"'+ iconExpandedSource + '"');
- } else if(defaultIconNodeOpened != null && !defaultIconNodeOpened.equals("")){
- buffer.append(","+'"'+defaultIconNodeOpenedSrc + '"');
- } else {
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
- }
-
- if(iconCollapsed != null && !iconCollapsed.equals("")){
- buffer.append(","+'"'+iconCollapsedSource+'"');
- } else if(defaultIconNodeClosed != null && !defaultIconNodeClosed.equals("")){
- buffer.append(","+'"'+defaultIconNodeClosedSrc+'"');
- } else {
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
- }
- }
- buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
- }
-
- protected void addAjaxFunction(FacesContext context, UIComponent child, StringBuffer buffer) {
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(child,
- context);
- Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
- child);
- function.addParameter(eventOptions);
-
- buffer.append(",\"");
- function.appendScript(buffer);
- buffer.append("\"");
- }
-
- protected void addOnItemHover(String menuOnItemHover, UIComponent child, StringBuffer buffer) {
- buffer.append(",\"");
- if(child instanceof UIPanelMenuItem){
- if(menuOnItemHover != null && !menuOnItemHover.equals("")) buffer.append(menuOnItemHover);
- }
- buffer.append("\"");
- }
-
-}
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -0,0 +1,437 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.richfaces.component.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuGroup;
+import org.richfaces.component.UIPanelMenuItem;
+import org.richfaces.renderkit.PanelMenuRendererBase;
+
+public class PanelMenuRenderer extends PanelMenuRendererBase {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ return UIComponent.class;
+ }
+
+ public void insertScript(FacesContext context, UIComponent component)
+ throws IOException {
+
+ StringBuffer buffer = new StringBuffer();
+ StringBuffer panelMenu = new StringBuffer();
+ List flatList = new LinkedList();
+ Map levels = new HashMap();
+
+ boolean expandSingle = ((UIPanelMenu)component).isExpandSingle();
+
+ flatten(component.getChildren(), flatList, levels, 0);
+
+ panelMenu
+ .append("new PanelMenu('")
+ .append(component.getClientId(context).toString())
+ .append("',")
+ .append(new Boolean(expandSingle).toString())
+ .append(");\n");
+
+ for (Iterator iter = flatList.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
+ boolean childDisabled;
+ if (!((UIPanelMenu)component).isDisabled())
+ childDisabled = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
+ else
+ childDisabled = true;
+ boolean childRendered = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
+ boolean parentRendered = true;
+ if (! (child.getParent() instanceof UIPanelMenu))
+ parentRendered = child.getParent() instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child.getParent()).isRendered() : ((UIPanelMenuItem)child.getParent()).isRendered();
+ if (!parentRendered){
+ child.getAttributes().put("rendered",Boolean.FALSE);
+ }
+
+ UIPanelMenu parentMenu = findMenu(child);
+
+ String event = parentMenu.getEvent();
+ if ("".equals(event))
+ event = "click";
+ else if (event.startsWith("on"))
+ event = event.substring(2);
+
+ String onopen = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
+ parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
+ String onclose = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
+ parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
+ String hoveredStyle = (child instanceof UIPanelMenuGroup ?
+ parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
+ + ";" + (child instanceof UIPanelMenuGroup ?
+ ((UIPanelMenuGroup)child).getHoverStyle() : ((UIPanelMenuItem)child).getHoverStyle());
+ String hoveredClass = (child instanceof UIPanelMenuGroup ?
+ parentMenu.getHoveredGroupClass() : parentMenu.getHoveredItemClass())
+ + " " + (child instanceof UIPanelMenuGroup ?
+ ((UIPanelMenuGroup)child).getHoverClass() : ((UIPanelMenuItem)child).getHoverClass());
+ String [] hoveredStyles = hoveredStyle.split(";");
+ String [] hoveredClasses = hoveredClass.split(" ");
+
+ String mode = getItemMode(child);
+ Object target = child.getAttributes().get("target");
+ String targetString;
+ if (null == target)
+ targetString = "";
+ else
+ targetString = target.toString();
+
+
+
+ if (childRendered && parentRendered){
+ if ( !isParentDisabled(child) ){
+ buffer
+ .append("new PanelMenuItem({myId:'")
+ .append((String) child.getClientId(context))
+ .append("',parentId:'")
+ .append((String) child.getParent().getClientId(context))
+ .append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
+ .append(",onopen:"+("".equals(onopen) ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+("".equals(onclose) ? "\"\"" : "\"" + onclose + "\""))
+ .append(",event:\"" + event + "\"")
+ .append(",mode:\"" + mode + "\"")
+ .append(",target:\"" + targetString + "\"")
+ .append(",disabled:" +
+ new Boolean(childDisabled).toString())
+ .append("},{");
+
+
+ for (int i = 0; i < hoveredStyles.length; i++)
+ if (!"".equals(hoveredStyles[i])) {
+ String [] temp = hoveredStyles[i].split(":");
+ String cssName = temp[0].trim();
+ String cssValue = temp[1].trim();
+ buffer.append("\"" + cssName + "\": \"" + cssValue + "\"");
+ if (i != hoveredStyles.length - 1)
+ buffer.append(",");
+ }
+
+ buffer.append("},");
+ if (hoveredClasses.length > 0) {
+ buffer.append("new Array(");
+ for (int i = 0; i < hoveredClasses.length; i++)
+ if (!"".equals(hoveredClasses[i])) {;
+ buffer.append("\"" + hoveredClasses[i] + "\"");
+ if (i != hoveredClasses.length - 1)
+ buffer.append(",");
+ }
+ buffer.append("),");
+ } else
+ buffer.append("new Array(),");
+
+ buffer.append(levels.get(child.getClientId(context)));
+ switchOnImagesIfNeeded(context,child,buffer);
+
+ addActionIfNeeded(context,child,buffer);
+
+ setExpandedIfNeeded(context,child,buffer);
+
+ addAjaxFunction(context,child,buffer);
+
+ addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
+
+ String iconPos = "left";
+ boolean isTopLevel = isTopLevel(child);
+ if(child instanceof UIPanelMenuGroup){
+ iconPos = isTopLevel ? parentMenu.getIconGroupTopPosition() : parentMenu.getIconGroupPosition();
+ } else {
+ iconPos = isTopLevel ? parentMenu.getIconItemTopPosition() : parentMenu.getIconItemPosition();
+ }
+
+ buffer.append(","+'"'+iconPos+'"');
+
+ addImages(buffer,context,child,component.getClientId(context).toString());
+
+ buffer.append(");\n");
+ }
+ } else {
+ continue;
+ }
+ }
+ }
+ StringBuffer ret = new StringBuffer();
+ ret.append("<script ");
+ ret.append("type=\"text/javascript\" ");
+ ret.append("id =\"script" + component.getClientId(context)+"\">\n");
+ ret.append(panelMenu);
+ ret.append(buffer);
+ ret.append("\n</script>");
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.write(ret.toString());
+ }
+
+ public void flatten(List children, List flatList, Map levels,int initialLevel) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (children != null) {
+ for (Iterator iter = children.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof UIPanelMenu){
+ continue;
+ }
+ flatList.add(child);
+ levels.put(child.getClientId(context), new Integer(initialLevel));
+ flatten(child.getChildren(), flatList, levels, initialLevel + 1);
+ }
+ }
+ }
+
+ private void switchOnImagesIfNeeded(FacesContext context, UIComponent child, StringBuffer buffer)throws IOException {
+ boolean isToplevel = isTopLevel(child);
+ String customIconOpened = "";
+ String customIconClosed = "";
+
+ UIPanelMenu panelMenu = findMenu(child);
+ if(panelMenu == null){
+ return;
+ }
+ String iconOpened = isToplevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
+ String iconClosed = isToplevel ? panelMenu.getIconCollapsedTopGroup() : panelMenu.getIconCollapsedGroup();
+
+ try {
+ customIconOpened = (String)child.getAttributes().get("iconOpened");
+ customIconClosed = (String)child.getAttributes().get("iconClosed");
+ } catch (Exception e) {}
+
+ if (child instanceof UIPanelMenuItem){
+ buffer.append(",false");
+ } else {
+ if (iconClosed.equals("custom")&&iconOpened.equals("custom")){
+ if (customIconClosed.equals("")&&customIconOpened.equals("")){
+ buffer.append(",false");
+ } else {
+ buffer.append(",true");
+ }
+ } else {
+ buffer.append(",true");
+ }
+ }
+ }
+
+ private void addActionIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
+ //TODO by nick - dima - use CommandScriptBuilder
+ if (child instanceof UIPanelMenuItem){
+ if (((UIPanelMenuItem)child).getAction() == null){
+ buffer.append(",false");
+ } else {
+ buffer.append(",true");
+ }
+ } else {
+ if (((UIPanelMenuGroup)child).getAction()!=null&&!((UIPanelMenuGroup)child).getAction().equals("")){
+ buffer.append(",'panelMenuNodeAction'");
+ } else {
+ buffer.append(",false");
+ }
+ }
+ }
+
+ private void setExpandedIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
+ if(child instanceof UIPanelMenuItem){
+ buffer.append(",false");
+ } else {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)child;
+ if(group.getValue() != null){
+ buffer.append(",").append(group.getValue().toString());
+ } else {
+ PanelMenuGroupRenderer r = (PanelMenuGroupRenderer)context.getRenderKit().getRenderer(group.getFamily(), group.getRendererType());
+ boolean isNodeOpened;
+ try {
+ isNodeOpened = r.isOpened(context, child);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+// e.printStackTrace();
+ isNodeOpened = false;
+ }
+ buffer.append(",").append(String.valueOf(isNodeOpened));
+ }
+ }
+ }
+
+ private void addImages(StringBuffer buffer,FacesContext context,UIComponent component,String id){
+ UIPanelMenu panelMenu = findMenu(component);
+ if(panelMenu == null){
+ return;
+ }
+ boolean isTopLevel = isTopLevel(component);
+
+ final String PANEL_MENU_SPACER_ICON = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel,context, component);
+
+ if(component instanceof UIPanelMenuItem){
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+
+ String defaultItemIcon = null;
+ String defaultItemIconSrc = null;
+ String customItemIcon = null;
+ String customIconSource = null;
+
+ if(isTopLevel){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconTopDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconTopItem();
+ }
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ } else {
+ //isTopLevel == false
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ }
+
+ if(defaultItemIcon != null && defaultItemIcon.equals("none")){
+ defaultItemIconSrc = PANEL_MENU_SPACER_ICON;
+ } else {
+ defaultItemIconSrc = getIconByType(defaultItemIcon, isTopLevel,context, component);
+ }
+
+
+ customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
+ if(customItemIcon != null && customItemIcon.equals("none")){
+ customIconSource = PANEL_MENU_SPACER_ICON;
+ } else {
+ customIconSource = getIconByType(customItemIcon, isTopLevel,context, component);
+ }
+
+ if(customItemIcon != null && !customItemIcon.equals("")){
+ buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+" ");
+ } else if (defaultItemIcon != null && !defaultItemIcon.equals("")){
+ buffer.append(","+'"'+defaultItemIconSrc+'"').append(","+'"'+defaultItemIconSrc+'"'+" ");
+ } else {
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+" ");
+ }
+ buffer.append(",\"\" ");
+
+ } else if(component instanceof UIPanelMenuGroup){
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+
+ String defaultIconNodeClosed = isTopLevel ? (group.isDisabled() ? panelMenu.getIconTopDisableGroup() : panelMenu.getIconCollapsedTopGroup()) : (group.isDisabled() ? panelMenu.getIconDisabledGroup() : panelMenu.getIconCollapsedGroup());
+
+ if(isTopLevel){
+ if(group.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ }
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+ } else {
+ if(group.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+
+ String defaultIconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
+
+ if(isTopLevel){
+ defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
+ if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+ } else {
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+
+ String defaultIconNodeClosedSrc = getIconByType(defaultIconNodeClosed, isTopLevel,context, component);
+ String defaultIconNodeOpenedSrc = getIconByType(defaultIconNodeOpened, isTopLevel,context, component);
+
+ String iconExpanded = "";
+ String iconCollapsed = "";
+ String iconExpandedSource = "";
+ String iconCollapsedSource = "";
+
+ iconExpanded = group.isDisabled() ? group.getIconDisabled() : group.getIconExpanded();
+ iconCollapsed = group.isDisabled() ? group.getIconDisabled() : group.getIconCollapsed();
+ iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
+ iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
+
+ if(iconExpanded != null && !iconExpanded.equals("")){
+ buffer.append(","+'"'+ iconExpandedSource + '"');
+ } else if(defaultIconNodeOpened != null && !defaultIconNodeOpened.equals("")){
+ buffer.append(","+'"'+defaultIconNodeOpenedSrc + '"');
+ } else {
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
+ }
+
+ if(iconCollapsed != null && !iconCollapsed.equals("")){
+ buffer.append(","+'"'+iconCollapsedSource+'"');
+ } else if(defaultIconNodeClosed != null && !defaultIconNodeClosed.equals("")){
+ buffer.append(","+'"'+defaultIconNodeClosedSrc+'"');
+ } else {
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
+ }
+ }
+ buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
+ }
+
+ protected void addAjaxFunction(FacesContext context, UIComponent child, StringBuffer buffer) {
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(child,
+ context);
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
+ child);
+ function.addParameter(eventOptions);
+
+ buffer.append(",\"");
+ function.appendScript(buffer);
+ buffer.append("\"");
+ }
+
+ protected void addOnItemHover(String menuOnItemHover, UIComponent child, StringBuffer buffer) {
+ buffer.append(",\"");
+ if(child instanceof UIPanelMenuItem){
+ if(menuOnItemHover != null && !menuOnItemHover.equals("")) buffer.append(menuOnItemHover);
+ }
+ buffer.append("\"");
+ }
+
+}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java 2007-06-13 16:46:27 UTC (rev 1166)
@@ -1,293 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-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.UIPanelMenu;
-import org.richfaces.component.UIPanelMenuGroup;
-import org.richfaces.component.UIPanelMenuItem;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevron;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevronDown;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevronUp;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconDisc;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconGrid;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconSpacer;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangle;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleDown;
-import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleUp;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-
-/**
- * @author hans
- *
- */
-public abstract class PanelMenuRendererBase extends HeaderResourcesRendererBase {
-
- final static String PANEL_MENU_SPACER_ICON_NAME = "spacer";
-
- public void insertTDs(FacesContext context , UIComponent component) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- int level = calculateLevel(component);
- //StringBuffer buffer = new StringBuffer();
- String src = getIconByType("custom",false,context,component);
- int w = 16; //width(context);
-
- for (int i=0;i<level;i++){
- writer.startElement(HTML.td_ELEM, component);
- writer.startElement("img", component);
- writer.writeAttribute("src", src, null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("hspace", "0", null);
- writer.writeAttribute("vspace", "0", null);
- writer.writeAttribute("height", String.valueOf(w), null);
- writer.writeAttribute("width", String.valueOf(w), null);
- writer.writeAttribute("style", "display:block; ", null);
- writer.endElement("img");
- writer.endElement(HTML.td_ELEM);
- }
- }
-
- protected int calculateLevel (UIComponent component){
- int level = 0;
- UIComponent parent = component.getParent();
- while(parent != null){
- if(parent instanceof UIPanelMenu){
- return level;
- } else if(parent instanceof UIPanelMenuGroup){
- level++;
- }
- parent = parent.getParent();
- }
- return level;
- }
-
- /**
- * If icon type is a pre-defined value, return corresponding image, otherwise
- * otherwise
- * @param iconType
- * @param context
- * @param component
- * @return URI of requested image
- */
- protected String getIconByType(String iconType, boolean isTopLevel, FacesContext context,
- UIComponent component){
-
- String source = "";
- String color = "";
- Skin skin = getSkin(context);
-
- if (isTopLevel){
- color = (String) skin.getParameter(context,"panelmenu.headerBulletColor");
- } else {
- color = (String) skin.getParameter(context,"panelmenu.itemBulletColor");
- }
- if(iconType != null && !iconType.equals("none")){
- if (iconType.equals("custom")){
- source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
- } else if (iconType.equals("spacer")){
- source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
- } else if (iconType.equals("triangle")) {
- source = getResource(PanelMenuIconTriangle.class.getName()).getUri(context, color);
- } else if (iconType.equals("triangleDown")) {
- source = getResource(PanelMenuIconTriangleDown.class.getName()).getUri(context, color);
- } else if (iconType.equals("triangleUp")) {
- source = getResource(PanelMenuIconTriangleUp.class.getName()).getUri(context, color);
- } else if (iconType.equals("chevron")) {
- source = getResource(PanelMenuIconChevron.class.getName()).getUri(context, color);
- } else if (iconType.equals("chevronUp")) {
- source = getResource(PanelMenuIconChevronUp.class.getName()).getUri(context, color);
- } else if (iconType.equals("chevronDown")) {
- source = getResource(PanelMenuIconChevronDown.class.getName()).getUri(context, color);
-// } else if (iconType.equals("square")) {
-// source = getResource(PanelMenuIconSquare.class.getName()).getUri(context, color);
- } else if (iconType.equals("disc")) {
- source = getResource(PanelMenuIconDisc.class.getName()).getUri(context, color);
- } else if (iconType.equals("grid")) {
- source = getResource(PanelMenuIconGrid.class.getName()).getUri(context, color);
- } else {
- //TODO by nick - dima - TemplateContext is deprecated and shouldn't be used
- source = (String)getUtils().encodeResourceURL(new TemplateContext(this,context,component),iconType);
- }
- }
- return source;
- }
-
- protected UIPanelMenu findMenu (UIComponent component){
- if (component instanceof UIPanelMenu) return (UIPanelMenu)component;
- UIComponent parent = component;
- while(parent != null){
- if(parent instanceof UIPanelMenu){
- return (UIPanelMenu) parent;
- }
- parent = parent.getParent();
- }
- return (UIPanelMenu) parent;
- }
-
- public String getHideStyle(FacesContext context, UIComponent component) {
- 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) ){
- return "";
- } else
- return format.toString();
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else return format.toString();
- }
- return "";
- }
-
- public void insertValue(FacesContext context, UIComponent component) throws IOException {
- Object value = component.getAttributes().get("value");
- if (value!=null){
- context.getResponseWriter().write(value.toString());
- }
- }
-
- protected boolean isChildrenExpanded(UIComponent component){
- if (component.getChildren() != null){
- Iterator itr = component.getChildren().iterator();
- while(itr.hasNext()){
- UIComponent child = (UIComponent)itr.next();
- if(child instanceof UIPanelMenuGroup){
- if( ((UIPanelMenuGroup)child).isExpanded() ){
- return true;
- } else {
- return isChildrenExpanded(child);
- }
- }
- }
- }
- return false;
- }
-
- protected boolean isParentDisabled(UIComponent component){
- boolean returnValue = false;
- UIComponent parent = component.getParent();
- if(parent instanceof UIPanelMenuGroup){
- UIPanelMenuGroup parentGroup = (UIPanelMenuGroup)parent;
- if(parentGroup.isDisabled()){
- returnValue = true;
- } else {
- returnValue = isParentDisabled(parentGroup);
- }
- }
- return returnValue;
- }
-
- protected boolean isSubmitted(FacesContext context, UIComponent component){
- boolean submitted = false;
- String clientId = component.getClientId(context);
- Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
-
- Object value = requestParameterMap.get("panelMenuAction"+clientId);
- if (clientId!=null&&value!=null){
- if (value.equals(clientId)) {
- submitted = true;
- }
- }
- return submitted;
- }
-
- protected String getItemMode(UIComponent component) {
- String parentExpandMode = findMenu(component).getExpandMode();
- String parentMode = findMenu(component).getMode();
- if (null == parentMode || "".equals(parentMode))
- parentMode = "server";
- if (null == parentExpandMode || "".equals(parentExpandMode))
- parentExpandMode = "none";
- String mode = "none";
- if (component instanceof UIPanelMenuGroup) {
- UIPanelMenuGroup group = (UIPanelMenuGroup) component;
- if (null != group.getMode() && ! "".equals(group.getMode()))
- mode = group.getMode();
- else
- mode = parentExpandMode;
- } else if (component instanceof UIPanelMenuItem) {
- UIPanelMenuItem item = (UIPanelMenuItem) component;
- if (null != item.getMode() && ! "".equals(item.getMode()))
- mode = item.getMode();
- else
- mode = parentMode;
- }
- return mode;
- }
-
- /**
- *
- * @param component
- * @return
- */
- public boolean isTopLevel(UIComponent component){
- UIComponent parent = component.getParent();
- while( !(parent instanceof UIPanelMenu) && !(parent instanceof UIPanelMenuGroup)) {
- parent = parent.getParent();
- }
- if(parent instanceof UIPanelMenu){
- return true;
- } else {
- return false;
- }
- }
-
- /**
- *
- * @param writer
- * @param iconType
- * @param imageSrc
- * @param component
- * @throws IOException
- */
- public void drawIcon(ResponseWriter writer, String iconType, String imageSrc, UIComponent component) throws IOException{
- if (iconType != null && !iconType.equals("") && !iconType.equals("none")){
- int h = 16; //width(context);
- writer.startElement("img", component);
- writer.writeAttribute("src", imageSrc, null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("vspace", "0", null);
- writer.writeAttribute("hspace", "0", null);
- writer.writeAttribute("style", "display:block; ", null);
- writer.writeAttribute("width", String.valueOf(h), null);
- writer.writeAttribute("height", String.valueOf(h), null);
- writer.endElement("img");
- }
-
- }
-
-}
Modified: trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
===================================================================
--- trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-06-13 16:46:27 UTC (rev 1166)
@@ -8,8 +8,8 @@
xmlns:x=" http://ajax4jsf.org/cdk/x"
xmlns:vcp="http://ajax4jsf.org/cdk/vcp"
class="org.richfaces.renderkit.html.HtmlPanelMenuRenderer"
- baseclass="org.richfaces.renderkit.PanelMenuRenderer"
- component="org.richfaces.component.panelmenu.UIPanelMenu" >
+ baseclass="org.richfaces.renderkit.html.PanelMenuRenderer"
+ component="org.richfaces.component.UIPanelMenu" >
<h:styles>
/org/richfaces/renderkit/html/css/panelMenu.xcss
Modified: trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
===================================================================
--- trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-06-13 16:46:27 UTC (rev 1166)
@@ -7,8 +7,8 @@
xmlns:x=" http://ajax4jsf.org/cdk/x"
xmlns:vcp=" http://ajax4jsf.org/cdk/vcp"
class="org.richfaces.renderkit.html.HtmlPanelMenuGroupRenderer"
- baseclass="org.richfaces.renderkit.PanelMenuGroupRenderer"
- component="org.richfaces.component.panelmenu.UIPanelMenuGroup"
+ baseclass="org.richfaces.renderkit.html.PanelMenuGroupRenderer"
+ component="org.richfaces.component.UIPanelMenuGroup"
>
<f:clientid var="clientId"/>
Modified: trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
===================================================================
--- trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-06-13 16:28:48 UTC (rev 1165)
+++ trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-06-13 16:46:27 UTC (rev 1166)
@@ -7,8 +7,8 @@
xmlns:x=" http://ajax4jsf.org/cdk/x"
xmlns:vcp=" http://ajax4jsf.org/cdk/vcp"
class="org.richfaces.renderkit.html.HtmlPanelMenuItemRenderer"
- baseclass="org.richfaces.renderkit.PanelMenuItemRenderer"
- component="org.richfaces.component.panelmenu.UIPanelMenuItem"
+ baseclass="org.richfaces.renderkit.html.PanelMenuItemRenderer"
+ component="org.richfaces.component.UIPanelMenuItem"
>
<f:clientid var="clientId"/>
17 years, 7 months
JBoss Rich Faces SVN: r1165 - in trunk/sandbox-samples/scrollable-grid-demo/src/main: java/org/richfaces/demo/converters and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 12:28:48 -0400 (Wed, 13 Jun 2007)
New Revision: 1165
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java
Log:
add inputs to demo
Added: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java (rev 0)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java 2007-06-13 16:28:48 UTC (rev 1165)
@@ -0,0 +1,121 @@
+
+package org.richfaces.demo.converters;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.demo.converters.utils.ConverterUtils;
+import org.richfaces.demo.datagrid.model.Channel;
+import org.richfaces.demo.datagrid.model.Issue;
+import org.richfaces.demo.datagrid.model.JiraUser;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class JiraUserConverter implements Converter, StateHolder {
+
+ private List <? super JiraUser> jiraUsersList = new ArrayList<JiraUser>();
+
+ private Channel channel;
+
+ private boolean transientFlag;
+
+
+ public JiraUserConverter() {
+ transientFlag = false;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException{
+
+ JiraUser user = findUser(value);
+ if( user == null){
+ FacesMessage errorMessage = ConverterUtils.createTypeErrorMessage(value,"real jira username");
+ throw new ConverterException(errorMessage);
+ }
+ return user;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException{
+
+ JiraUser jiraUser = null;
+
+ if(value instanceof JiraUser){
+ jiraUser = (JiraUser)value;
+ }else{
+ FacesMessage errorMessage = ConverterUtils.createTypeErrorMessage(value.getClass().getName(), JiraUser.class.getName());
+ throw new ConverterException(errorMessage);
+ }
+
+ return jiraUser.getName();
+ }
+
+ public boolean isTransient() {
+ return transientFlag;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object [] values = (Object[])state;
+ jiraUsersList = (List<? super JiraUser>)values[0];
+ }
+
+ public Object saveState(FacesContext context) {
+ Object [] values = new Object[1];
+ values [0] = jiraUsersList;
+ return values;
+ }
+
+ public void setTransient(boolean transientFlag) {
+ this.transientFlag = transientFlag;
+ }
+
+ private void createJiraUsersList(Channel channel){
+
+ List issuesList = channel.getIssues();
+ for (Iterator iter = issuesList.iterator(); iter.hasNext();) {
+ Issue element = (Issue) iter.next();
+ JiraUser jiraUser = element.getAssignee();
+
+ if((jiraUser != null) && (!jiraUsersList.contains(jiraUser))){
+ jiraUsersList.add(jiraUser);
+ }
+ }
+ }
+
+ public JiraUser findUser(String user){
+
+ for (Iterator iter = jiraUsersList.iterator(); iter.hasNext();) {
+ JiraUser jiraUser = (JiraUser) iter.next();
+ String name = jiraUser.getName();
+ if(name != null){
+ if(name.equals(user)){
+ return jiraUser;
+ }
+
+ }
+ }
+
+ return null;
+ }
+
+ public Channel getChannel() {
+ return channel;
+ }
+
+ public void setChannel(Channel channel) {
+ this.channel = channel;
+ createJiraUsersList(channel);
+ }
+
+
+}
Added: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java (rev 0)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java 2007-06-13 16:28:48 UTC (rev 1165)
@@ -0,0 +1,67 @@
+package org.richfaces.demo.converters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.demo.converters.utils.ConverterUtils;
+import org.richfaces.demo.datagrid.model.Priority;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PriorityConverter implements Converter{
+
+ public PriorityConverter() {
+ }
+
+
+ private List prioritiesList = new ArrayList<Priority>();
+
+ public List getPrioritiesList() {
+ return prioritiesList;
+ }
+
+ public void setPrioritiesList(List prioritiesList) {
+ this.prioritiesList = prioritiesList;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException{
+
+ int id = Integer.parseInt(value);
+
+ Priority convertedValue = null;
+
+ try {
+ convertedValue = (Priority)prioritiesList.get(id);
+ } catch (IndexOutOfBoundsException e) {
+ FacesMessage errorMessage = new FacesMessage(e.getMessage());
+ errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ConverterException(errorMessage);
+ }
+
+ return convertedValue;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException{
+
+ Priority priority = null;
+
+ if(value instanceof Priority){
+ priority = (Priority)value;
+ }else{
+ FacesMessage errorMessage = ConverterUtils.createTypeErrorMessage(value.getClass().getName(), Priority.class.getName());
+ throw new ConverterException(errorMessage);
+ }
+
+ return Integer.toString(priority.getId());
+ }
+}
Added: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java (rev 0)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java 2007-06-13 16:28:48 UTC (rev 1165)
@@ -0,0 +1,64 @@
+package org.richfaces.demo.converters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.demo.converters.utils.ConverterUtils;
+import org.richfaces.demo.datagrid.model.Status;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class StatusConverter implements Converter{
+
+ private List statusList = new ArrayList<Status>();
+
+
+ public List getStatusList() {
+ return statusList;
+ }
+
+ public void setStatusList(List statusList) {
+ this.statusList = statusList;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException{
+
+ Status convertedValue = null;
+ int id = Integer.parseInt(value);
+
+
+ try {
+ convertedValue = (Status)statusList.get(id);
+ } catch (IndexOutOfBoundsException e) {
+ FacesMessage errorMessage = new FacesMessage(e.getMessage());
+ errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ConverterException(errorMessage);
+ }
+
+ return convertedValue;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException{
+
+ Status status = null;
+
+ if(value instanceof Status){
+ status = (Status)value;
+ }else{
+ FacesMessage errorMessage = ConverterUtils.createTypeErrorMessage(value.getClass().getName(), Status.class.getName());
+ throw new ConverterException(errorMessage);
+ }
+
+ return Integer.toString(status.getId()) ;
+ }
+}
\ No newline at end of file
Added: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java (rev 0)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java 2007-06-13 16:28:48 UTC (rev 1165)
@@ -0,0 +1,19 @@
+package org.richfaces.demo.converters.utils;
+
+import javax.faces.application.FacesMessage;
+
+public class ConverterUtils {
+
+ private static final String CONVERSATION_ERROR = "Conversation error: expected ";
+
+ public static FacesMessage createTypeErrorMessage(String received, String expected ){
+
+ String summary = CONVERSATION_ERROR + expected + "found " + received;
+
+ FacesMessage errorMessage = new FacesMessage();
+ errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
+ errorMessage.setSummary(summary);
+
+ return errorMessage;
+ }
+}
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java 2007-06-13 16:27:58 UTC (rev 1164)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java 2007-06-13 16:28:48 UTC (rev 1165)
@@ -10,7 +10,11 @@
package org.richfaces.demo.datagrid.bean;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
import org.richfaces.demo.datagrid.model.Channel;
import org.richfaces.demo.datagrid.model.Issue;
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java 2007-06-13 16:27:58 UTC (rev 1164)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java 2007-06-13 16:28:48 UTC (rev 1165)
@@ -68,6 +68,6 @@
@Override
public String toString() {
- return getClass().getSimpleName() + ":" + value;
+ return String.valueOf(id);
}
}
Added: trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties (rev 0)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties 2007-06-13 16:28:48 UTC (rev 1165)
@@ -0,0 +1,84 @@
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common Development
+# and Distribution License("CDDL") (collectively, the "License"). You
+# may not use this file except in compliance with the License. You can obtain
+# a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+# or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+# language governing permissions and limitations under the License.
+#
+# When distributing the software, include this License Header Notice in each
+# file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+# Sun designates this particular file as subject to the "Classpath" exception
+# as provided by Sun in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the License
+# Header, with the fields enclosed by brackets [] replaced by your own
+# identifying information: "Portions Copyrighted [year]
+# [name of copyright owner]"
+#
+# Contributor(s):
+#
+# If you wish your version of this file to be governed by only the CDDL or
+# only the GPL Version 2, indicate your decision by adding "[Contributor]
+# elects to include this software in this distribution under the [CDDL or GPL
+# Version 2] license." If you don't indicate a single choice of license, a
+# recipient has the option to distribute your version of this file under
+# either the CDDL, the GPL Version 2 or to extend the choice of license to
+# its licensees as provided above. However, if you add GPL Version 2 code
+# and therefore, elected the GPL Version 2 license, then the option applies
+# only if the new code is made subject to such option by the copyright
+# holder.
+#
+
+# General Errors
+error.convert=Cannot convert {0} of type {1} to {2}
+error.compare=Cannot compare {0} to {1}
+error.function=Problems calling function ''{0}''
+error.unreachable.base=Target Unreachable, identifier ''{0}'' resolved to null
+error.unreachable.property=Target Unreachable, ''{0}'' returned null
+error.resolver.unhandled=ELResolver did not handle type: {0} with property of ''{1}''
+error.resolver.unhandled.null=ELResolver cannot handle a null base Object with identifier ''{0}''
+
+# ValueExpressionLiteral
+error.value.literal.write=ValueExpression is a literal and not writable: {0}
+
+# ExpressionFactoryImpl
+error.null=Expression cannot be null
+error.mixed=Expression cannot contain both '#{..}' and '${..}' : {0}
+error.method=Not a valid MethodExpression : {0}
+error.method.nullParms=Parameter types cannot be null
+error.value.expectedType=Expected type cannot be null
+
+# ExpressionMediator
+error.eval=Error Evaluating {0} : {1}
+
+# ValueSetVisitor
+error.syntax.set=Illegal Syntax for Set Operation
+
+# ReflectionUtil
+error.method.notfound=Method not found: {0}.{1}({2})
+error.property.notfound=Property ''{1}'' not found on {0}
+
+# ValidatingVisitor
+error.fnMapper.null=Expression uses functions, but no FunctionMapper was provided
+error.fnMapper.method=Function ''{0}'' not found
+error.fnMapper.paramcount=Function ''{0}'' specifies {1} params, but {2} were declared
+
+# **ExpressionImpl
+error.context.null=ELContext was null
+
+# ArrayELResolver
+error.array.outofbounds=Index {0} is out of bounds for array of size {1}
+
+# ListELResolver
+error.list.outofbounds=Index {0} is out of bounds for list of size {1}
+
+# BeanELResolver
+error.property.notfound=Property ''{1}'' not found on type: {0}
+error.property.invocation=Property ''{1}'' threw an exception from type: {0}
+error.property.notreadable=Property ''{1}'' doesn't have a 'get' specified on type: {0}
+error.property.notwritable=Property ''{1}'' doesn't have a 'set' specified on type: {0}
\ No newline at end of file
17 years, 7 months
JBoss Rich Faces SVN: r1164 - trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 12:27:58 -0400 (Wed, 13 Jun 2007)
New Revision: 1164
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
Log:
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-06-13 16:27:48 UTC (rev 1163)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-06-13 16:27:58 UTC (rev 1164)
@@ -8,32 +8,23 @@
>
<head>
-
- <script>
- //<![CDATA[
-
- function processCellValue(cell, value) {
- var cell = $(cell);
- if(cell) {
- if(value && value.indexOf("2")>0) {
- cell.setStyle({backgroundColor: "red"});
- }
- else {
- cell.setStyle({backgroundColor: ""});
- }
- }
- }
-
- function onSort(column, order) {
- alert("Column " + column + " sorted in " + order + " order.");
- }
- //]]>
-
- </script>
+ <style type="text/css">
+ .inputStyle{
+ font-family:arial;
+ font-size:6pt;
+ font-size-adjust:none;
+ font-stretch:normal;
+ font-style:normal;
+ font-variant:normal;
+ font-weight:normal;
+ line-height:normal;
+ }
+ </style>
</head>
+
<body>
- <f:view>
+ <f:view>
<h:form>
<sg:scrollable-grid value="#{dataModel2}"
@@ -51,92 +42,137 @@
</f:facet>
<sg:column width="100px" sortable="false">
+
<f:facet name="header">
- <h:outputText value="Index"></h:outputText>
+ <h:outputText value="Index"></h:outputText>
</f:facet>
+
<h:outputText value="#{issues.index}"></h:outputText>
+
<f:facet name="footer">
<h:outputText value="footer0"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
<h:outputText value="Key"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.key.value}"></h:outputText>
+
+ <h:outputText value="#{issues.key.value}"></h:outputText>
+
<f:facet name="footer">
<h:outputText value="footer1"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
<h:outputText value="Summary"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.summary}"></h:outputText>
- <f:facet name="footer">
+
+ <h:inputText value="#{issues.summary}" style="width: 200px" styleClass="inputStyle"></h:inputText>
+
+ <f:facet name="footer">
<h:outputText value="footer2"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
<h:outputText value="Assignee"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.assignee.name}"></h:outputText>
+
+ <h:inputText value="#{issues.assignee}" converter="#{jiraUserConverter}" styleClass="inputStyle"></h:inputText>
+
<f:facet name="footer">
<h:outputText value="footer3"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
- <h:outputText value="Status"></h:outputText>
+ <h:outputText value="Status"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.status.name}"></h:outputText>
- <f:facet name="footer">
+
+ <h:selectOneMenu id="select_status" value="#{issues.status}" converter="#{StatusConverter}" styleClass="inputStyle">
+ <f:selectItem itemValue="#{status_open}" itemLabel="Open"/>
+ <f:selectItem itemValue="#{status_closed}" itemLabel="Closed"/>
+ <f:selectItem itemValue="#{status_resolved}" itemLabel="Resolved"/>
+ <f:selectItem itemValue="#{status_inprogress}" itemLabel="In Progress"/>
+ <f:selectItem itemValue="#{status_reopened}" itemLabel="Reopened"/>
+ </h:selectOneMenu>
+
+ <f:facet name="footer">
<h:outputText value="footer4"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
<h:outputText value="Reporter"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.reporter.username}"></h:outputText>
+
+ <h:outputText value="#{issues.reporter.username}"></h:outputText>
+
<f:facet name="footer">
<h:outputText value="footer5"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
<h:outputText value="Priority"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.priority.name}"></h:outputText>
+
+ <h:selectOneMenu id="select_priority" value="#{issues.priority}" converter="#{PriorityConverter}" styleClass="inputStyle">
+ <f:selectItem itemValue="#{priority_blocker}" itemLabel="Blocker"/>
+ <f:selectItem itemValue="#{priority_critical}" itemLabel="Critical"/>
+ <f:selectItem itemValue="#{priority_major}" itemLabel="Major"/>
+ <f:selectItem itemValue="#{priority_minor}" itemLabel="Minor"/>
+ <f:selectItem itemValue="#{priority_cosmetic}" itemLabel="Cosmetic"/>
+ </h:selectOneMenu>
+
<f:facet name="footer">
<h:outputText value="footer6"></h:outputText>
</f:facet>
+
</sg:column>
<sg:column width="200px">
+
<f:facet name="header">
<h:outputText value="Resolution"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.resolution}"></h:outputText>
+
+ <h:inputText value="#{issues.resolution}" styleClass="inputStyle"></h:inputText>
+
<f:facet name="footer">
<h:outputText value="footer8"></h:outputText>
</f:facet>
+
</sg:column>
</sg:scrollable-grid>
+ <h:commandButton value="submit"></h:commandButton>
-
-
-
- </h:form>
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages showDetail="true"/>
+ </a4j:outputPanel>
</f:view>
</body>
</html>
\ No newline at end of file
17 years, 7 months
JBoss Rich Faces SVN: r1163 - trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/WEB-INF.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 12:27:48 -0400 (Wed, 13 Jun 2007)
New Revision: 1163
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/WEB-INF/faces-config.xml
Log:
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-06-13 16:07:14 UTC (rev 1162)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-06-13 16:27:48 UTC (rev 1163)
@@ -9,7 +9,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>1</value>
+ <value>0</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -23,7 +23,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>2</value>
+ <value>1</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -37,7 +37,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>3</value>
+ <value>2</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -51,7 +51,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>4</value>
+ <value>3</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -65,7 +65,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>5</value>
+ <value>4</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -79,7 +79,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>1</value>
+ <value>0</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -93,7 +93,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>3</value>
+ <value>1</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -107,7 +107,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>5</value>
+ <value>2</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -121,7 +121,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>4</value>
+ <value>3</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -135,7 +135,7 @@
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
- <value>6</value>
+ <value>4</value>
</managed-property>
<managed-property>
<property-name>name</property-name>
@@ -143,7 +143,6 @@
</managed-property>
</managed-bean>
-
<managed-bean>
<managed-bean-name>imageStore</managed-bean-name>
<managed-bean-class>org.richfaces.demo.datagrid.service.ImageStore</managed-bean-class>
@@ -228,7 +227,7 @@
<managed-bean-class>org.richfaces.demo.datagrid.bean.SelectionBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
- <property-name> dataModel</property-name>
+ <property-name>dataModel</property-name>
<property-class>org.richfaces.model.ScrollableGridDataModel</property-class>
<value>#{dataModel}</value>
</managed-property>
@@ -237,5 +236,62 @@
<value>#{jiraService.channel}</value>
</managed-property>
</managed-bean>
-
+
+ <managed-bean>
+ <managed-bean-name>jiraUserConverter</managed-bean-name>
+ <managed-bean-class>org.richfaces.demo.converters.JiraUserConverter</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>channel</property-name>
+ <value>#{jiraService.channel}</value>
+ </managed-property>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>StatusConverter</managed-bean-name>
+ <managed-bean-class>org.richfaces.demo.converters.StatusConverter</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>statusList</property-name>
+ <list-entries>
+ <value>#{status_open}</value>
+ <value>#{status_inprogress}</value>
+ <value>#{status_resolved}</value>
+ <value>#{status_reopened}</value>
+ <value>#{status_closed}</value>
+ </list-entries>
+ </managed-property>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>PriorityConverter</managed-bean-name>
+ <managed-bean-class>org.richfaces.demo.converters.PriorityConverter</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>prioritiesList</property-name>
+ <list-entries>
+ <value>#{priority_cosmetic}</value>
+ <value>#{priority_minor}</value>
+ <value>#{priority_major}</value>
+ <value>#{priority_critical}</value>
+ <value>#{priority_blocker}</value>
+ </list-entries>
+ </managed-property>
+ </managed-bean>
+
+ <!--
+
+ <converter>
+ <description>converter for issues status</description>
+ <converter-id>status_converter</converter-id>
+ <converter-class>org.richfaces.demo.converters.StatusConverter</converter-class>
+ </converter>
+
+ <converter>
+ <description>converter for issues priority</description>
+ <converter-id>priority_converter</converter-id>
+ <converter-class>org.richfaces.demo.converters.PriorityConverter</converter-class>
+ </converter>
+ -->
+
</faces-config>
17 years, 7 months
JBoss Rich Faces SVN: r1162 - in trunk/sandbox/panelmenu/src/main/java/org/richfaces: renderkit and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-06-13 12:07:14 -0400 (Wed, 13 Jun 2007)
New Revision: 1162
Added:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuGroupGradient.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuItemGradient.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconBasic.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevron.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronDown.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronUp.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconDisc.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconGrid.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconSpacer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangle.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleDown.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleUp.java
Removed:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuGroupGradient.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuItemGradient.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconBasic.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevron.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronDown.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronUp.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconDisc.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconGrid.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconSpacer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangle.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleDown.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleUp.java
Log:
packages structure fixing
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,109 @@
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+public abstract class UIPanelMenu extends UIComponentBase{
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panelMenu";
+
+ public abstract String getEvent();
+ public abstract void setEvent(String event);
+ public abstract String getMode();
+ public abstract void setMode(String mode);
+ public abstract String getWidth();
+ public abstract void setWidth(String width);
+ public abstract String getExpandMode();
+ public abstract void setExpandMode(String expandMode);
+ public abstract boolean isExpandSingle();
+ public abstract void setExpandSingle(boolean expandSingle);
+ public abstract String getIconItem();
+ public abstract void setIconItem(String iconItem);
+ public abstract String getIconDisabledItem();
+ public abstract void setIconDisabledItem(String iconDisabledItem);
+ public abstract String getIconTopItem();
+ public abstract void setIconTopItem(String iconTopItem);
+ public abstract String getIconTopDisabledItem();
+ public abstract void setIconTopDisabledItem(String iconTopDisabledItem);
+ public abstract String getIconExpandedGroup();
+ public abstract void setIconExpandedGroup(String iconExpandedGroup);
+ public abstract String getIconCollapsedGroup();
+ public abstract void setIconCollapsedGroup(String iconCollapsedGroup);
+ public abstract String getIconDisabledGroup();
+ public abstract void setIconDisabledGroup(String iconDisabledGroup);
+ public abstract String getIconExpandedTopGroup();
+ public abstract void setIconExpandedTopGroup(String iconExpandedTopGroup);
+ public abstract String getIconCollapsedTopGroup();
+ public abstract void setIconCollapsedTopGroup(String iconCollapsedTopGroup);
+ public abstract String getIconTopDisableGroup();
+ public abstract void setIconTopDisableGroup(String iconTopDisableGroup);
+ public abstract String getIconItemPosition();
+ public abstract void setIconItemPosition(String iconItemPosition);
+ public abstract String getIconItemTopPosition();
+ public abstract void setIconItemTopPosition(String iconItemTopPosition);
+ public abstract String getIconGroupPosition();
+ public abstract void setIconGroupPosition(String iconGroupPosition);
+ public abstract String getIconGroupTopPosition();
+ public abstract void setIconGroupTopPosition(String iconGroupTopPosition);
+ public abstract String getStyle();
+ public abstract void setStyle(String style);
+ public abstract String getStyleClass();
+ public abstract void setStyleClass(String styleClass);
+ public abstract String getGroupStyle();
+ public abstract void setGroupStyle(String groupStyle);
+ public abstract String getGroupClass();
+ public abstract void setGroupClass(String groupClass);
+ public abstract String getTopGroupStyle();
+ public abstract void setTopGroupStyle(String topGroupStyle);
+ public abstract String getTopGroupClass();
+ public abstract void setTopGroupClass(String topGroupClass);
+ public abstract String getItemStyle();
+ public abstract void setItemStyle(String itemStyle);
+ public abstract String getItemClass();
+ public abstract void setItemClass(String itemClass);
+ public abstract String getTopItemStyle();
+ public abstract void setTopItemStyle(String topItemStyle);
+ public abstract String getTopItemClass();
+ public abstract void setTopItemClass(String topItemClass);
+ public abstract String getDisabledItemClass();
+ public abstract void setDisabledItemClass(String disabledItemClass);
+ public abstract String getDisabledItemStyle();
+ public abstract void setDisabledItemStyle(String disabledItemStyle);
+ public abstract String getDisabledGroupClass();
+ public abstract void setDisabledGroupClass(String disabledGroupClass);
+ public abstract String getDisabledGroupStyle();
+ public abstract void setDisabledGroupStyle(String disabledGroupStyle);
+ public abstract String getHoveredItemClass();
+ public abstract void setHoveredItemClass(String hoveredItemClass);
+ public abstract String getHoveredItemStyle();
+ public abstract void setHoveredItemStyle(String hoveredItemStyle);
+ public abstract String getHoveredGroupStyle();
+ public abstract void setHoveredGroupStyle(String hoveredItemStyle);
+ public abstract String getHoveredGroupClass();
+ public abstract void setHoveredGroupClass(String hoveredGroupClass);
+ public abstract String getOnitemhover();
+ public abstract void setOnitemhover(String onitemhover);
+ public abstract String getOngroupcollapse();
+ public abstract void setOngroupcollapse(String ongroupcollapse);
+ public abstract String getOngroupexpand();
+ public abstract void setOngroupexpand(String ongroupexpand);
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
+
+ public abstract void setOnclick(String string);
+ public abstract String getOnclick();
+
+ public abstract void setOndblclick(String string);
+ public abstract String getOndblclick();
+
+ public abstract void setOnmouseout(String string);
+ public abstract String getOnmouseout();
+
+ public abstract void setOnmousemove(String string);
+ public abstract String getOnmousemove();
+
+ public abstract void setOnmouseover(String string);
+ public abstract String getOnmouseover();
+
+
+
+}
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,165 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.richfaces.conveter.UIPanelMenuGroupValueConverter;
+
+public abstract class UIPanelMenuGroup extends UIInput implements ActionSource{
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panelMenuGroup";
+
+ private MethodBinding actionListener = null;
+ private MethodBinding action = null;
+
+ public abstract String getStyleClass();
+ public abstract void setStyleClass(String styleClass);
+
+ public abstract String getMode();
+ public abstract void setMode(String mode);
+ public abstract String getIconExpanded();
+ public abstract void setIconExpanded(String expanded);
+
+ public abstract String getIconCollapsed();
+ public abstract void setIconCollapsed(String iconCollapsed);
+ public abstract String getIconDisabled();
+ public abstract void setIconDisabled(String iconDisabled);
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
+ public abstract String getTarget();
+ public abstract void setTarget(String target);
+ public abstract String getHoverClass();
+ public abstract void setHoverClass(String hoverClass);
+ public abstract String getHoverStyle();
+ public abstract void setHoverStyle(String hoverStyle);
+ public abstract String getDisabledClass();
+ public abstract void setDisabledClass(String disabledClass);
+ public abstract String getDisabledStyle();
+ public abstract void setDisabledStyle(String disabledStyle);
+ public abstract String getStyle();
+ public abstract void setStyle(String style);
+ public abstract String getIconClass();
+ public abstract void setIconClass(String iconClass);
+ public abstract String getIconStyle();
+ public abstract void setIconStyle(String iconStyle);
+ public abstract String getOncollapse();
+ public abstract void setOncollapse(String ongroupcollapse);
+ public abstract String getOnexpand();
+ public abstract void setOnexpand(String ongroupexpand);
+ public abstract String getLabel();
+ public abstract void setLabel(String label);
+
+ public abstract boolean isExpanded();
+ public abstract void setExpanded(boolean expanded);
+
+
+ public UIPanelMenuGroup(){
+ setConverter(new UIPanelMenuGroupValueConverter());
+ }
+
+ public void addActionListener(ActionListener listener) {
+ addFacesListener(listener);
+ }
+
+ public MethodBinding getAction() {
+ return action;
+ }
+
+ public MethodBinding getActionListener() {
+ return (this.actionListener);
+ }
+
+ public ActionListener[] getActionListeners() {
+ ActionListener al[] = (ActionListener [])
+ getFacesListeners(ActionListener.class);
+ return (al);
+
+ }
+
+ public void removeActionListener(ActionListener listener) {
+ removeFacesListener(listener);
+ }
+
+ public void setAction(MethodBinding action) {
+ this.action = action;
+ }
+
+ public void setActionListener(MethodBinding actionListener) {
+ this.actionListener = actionListener;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ action = (MethodBinding) restoreAttachedState(context, values[1]);
+ actionListener = (MethodBinding) restoreAttachedState(context,
+ values[2]);
+ }
+
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[3];
+ values[0] = super.saveState(context);
+ values[1] = saveAttachedState(context, action);
+ values[2] = saveAttachedState(context, actionListener);
+ return values;
+ }
+
+ public void queueEvent(FacesEvent event) {
+ if(event instanceof ActionEvent){
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+ super.queueEvent(event);
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ if(event instanceof ActionEvent){
+ FacesContext context = getFacesContext();
+ // Notify the specified action listener method (if any)
+ MethodBinding mb = getActionListener();
+ if (mb != null) {
+ mb.invoke(context, new Object[] { event });
+ }
+
+ // Invoke the default ActionListener
+ ActionListener listener =
+ context.getApplication().getActionListener();
+ if (listener != null) {
+ listener.processAction((ActionEvent) event);
+ }
+ }
+ }
+}
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+
+public abstract class UIPanelMenuItem extends UICommand {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panelMenuItem";
+
+ public abstract String getMode();
+ public abstract void setMode(String mode);
+ public abstract String getIcon();
+ public abstract void setIcon(String icon);
+ public abstract String getIconDisabled();
+ public abstract void setIconDisabled(String iconDisabled);
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
+ public abstract Object getValue();
+ public abstract void setValue(Object value);
+ public abstract String getHoverClass();
+ public abstract void setHoverClass(String hoverClass);
+ public abstract String getHoverStyle();
+ public abstract void setHoverStyle(String hoverStyle);
+ public abstract String getDisabledClass();
+ public abstract void setDisabledClass(String disabledClass);
+ public abstract String getDisabledStyle();
+ public abstract void setDisabledStyle(String disabledStyle);
+ public abstract String getStyleClass();
+ public abstract void setStyleClass(String styleClass);
+ public abstract String getStyle();
+ public abstract void setStyle(String style);
+ public abstract String getIconClass();
+ public abstract void setIconClass(String iconClass);
+ public abstract String getIconStyle();
+ public abstract void setIconStyle(String iconStyle);
+ public abstract String getTarget();
+ public abstract void setTarget(String target);
+
+}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,262 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.Map;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.ConverterException;
-import javax.faces.event.ActionEvent;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.richfaces.component.UISwitchablePanel;
-import org.richfaces.component.panelmenu.UIPanelMenu;
-import org.richfaces.component.panelmenu.UIPanelMenuGroup;
-
-public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
-
- protected Class getComponentClass() {
- return UIPanelMenuGroup.class;
- }
-
- protected void doDecode(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- Map requestMap =context.getExternalContext().getRequestParameterMap();
- UIPanelMenuGroup group = ((UIPanelMenuGroup)component);
-
- if(requestMap.containsKey("panelMenuState"+clientId)){
- Object property = requestMap.get("panelMenuState"+clientId);
- if (property.equals("opened")) {
- group.setSubmittedValue("true");
- } else if (property.equals("closed")) {
- group.setSubmittedValue("false");
- }
-
- }
- if(isSubmitted(context, component)){
- new ActionEvent(component).queue();
- if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
- new AjaxEvent(component).queue();
- }
- }
- }
-
- public void insertImage(FacesContext context, UIComponent component, Object data)
- throws IOException {
-
- String from = (String)data;
- String align = "";
-
- UIPanelMenu panelMenu = findMenu(component);
- boolean isTopLevel = isTopLevel(component);
-
- if (isTopLevel){
- align = panelMenu.getIconGroupTopPosition();
- } else {
- align = panelMenu.getIconGroupPosition();
- }
-
- if (align.equalsIgnoreCase(from)){
- image(context,component);
- } else {
- String iconType = PANEL_MENU_SPACER_ICON_NAME;
- String imageSrc = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
- }
- }
-
- private void image(FacesContext context, UIComponent component )throws IOException {
- ResponseWriter writer = context.getResponseWriter();
-
- UIPanelMenu panelMenu = findMenu(component);
- if(panelMenu == null){
- return;
- }
- UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup)component;
- boolean isTopLevel = isTopLevel(panelMenuGroup);
-
- boolean isOpened = isOpened(context,component);
-
-
- String defaultIconNodeClosed = null;
-
- if(isTopLevel){
- if(panelMenuGroup.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- }
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
- } else {
- if(panelMenuGroup.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
-
- String defaultIconNodeOpened = null;
-
- if(isTopLevel){
- defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
- if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
- } else {
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
-
- String iconExpanded = "";
- String iconCollapsed = "";
-
- iconExpanded = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconExpanded();
- iconCollapsed = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconCollapsed();
-
- String icon = null;
- if(isOpened){
- if(iconExpanded != null && !iconExpanded.equals("")){
- if(iconExpanded.equals("none")){
- return;
- } else {
- icon = iconExpanded;
- }
- } else {
- icon = defaultIconNodeOpened;
- }
- } else {
- if(iconCollapsed!= null && !iconCollapsed.equals("")){
- if(iconCollapsed.equals("none")){
- return;
- } else {
- icon = iconCollapsed;
- }
- } else {
- icon = defaultIconNodeClosed;
- }
- }
- String source = getIconByType(icon, isTopLevel, context, component);
- drawIcon(writer, icon, source, component);
- }
-
- public String getFullStyleClass(FacesContext context, UIComponent component) {
- StringBuffer classBuffer = new StringBuffer("");
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if (!parentMenu.isDisabled() && !group.isDisabled()) {
- if (calculateLevel(group) == 0)
- classBuffer.append(parentMenu.getTopGroupClass() + " ");
- else
- classBuffer.append(parentMenu.getGroupClass() + " ");
- classBuffer.append(group.getStyleClass());
- } else
- classBuffer.append(parentMenu.getDisabledGroupClass() + " ")
- .append(group.getDisabledClass());
- return classBuffer.toString();
- }
-
- public String getFullStyle(FacesContext context, UIComponent component) {
- StringBuffer styleBuffer = new StringBuffer("");
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if (!group.isDisabled()) {
- if (calculateLevel(group) == 0)
- styleBuffer.append(parentMenu.getTopGroupStyle() + "; ");
- else
- styleBuffer.append(parentMenu.getGroupStyle() + "; ");
- styleBuffer.append(group.getStyle());
- } else
- styleBuffer.append(parentMenu.getDisabledGroupStyle() + "; ")
- .append(group.getDisabledStyle());
- return styleBuffer.toString();
- }
-
- public void insertLabel(FacesContext context, UIComponent component) throws IOException {
- Object label = component.getAttributes().get("label");
- if (label!=null){
- context.getResponseWriter().write(label.toString());
- }
- }
-
- public Object getConvertedValue(FacesContext context,
- UIComponent component, Object submittedValue)
- throws ConverterException {
-
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- if(group.getConverter() != null){
- return group.getConverter().getAsObject(context, component, (String)submittedValue);
- } else {
- return submittedValue;
- }
-
- }
-
- public boolean isOpened(FacesContext context, UIComponent component)throws IOException {
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
-
- Boolean value = (Boolean)group.getValue();
- if (value != null) {
- return value.booleanValue();
- } else {
- boolean isParentDisabled = isParentDisabled(component);
- if(component instanceof UIPanelMenuGroup){
- if( ((UIPanelMenuGroup)component).isExpanded() && !((UIPanelMenuGroup)component).isDisabled() && !isParentDisabled ){
- return true;
- } else {
- //check expanded attributes in children groups, if exists
- boolean isChildrenExpanded = isChildrenExpanded(component);
- return isChildrenExpanded && !isParentDisabled && !((UIPanelMenuGroup)component).isDisabled();// ? "opened" : "closed";
- }
- }
- }
- return false;
- }
-
- public String getLabelClass(FacesContext context, UIComponent component) {
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if(!group.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-group-self-label rich-pmenu-top-group-self-label";
- } else return "rich-pmenu-group-self-label";
- }
- return "";
- }
-
- public String getIconClass(FacesContext context, UIComponent component) {
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- UIPanelMenu parentMenu = findMenu(group);
- if(!group.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-group-self-icon rich-pmenu-top-group-self-icon";
- } else return "rich-pmenu-group-self-icon";
- }
- return "";
- }
-
-
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,190 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.richfaces.component.UISwitchablePanel;
-import org.richfaces.component.panelmenu.UIPanelMenu;
-import org.richfaces.component.panelmenu.UIPanelMenuItem;
-
-public class PanelMenuItemRenderer extends PanelMenuRendererBase {
- protected Class getComponentClass() {
- return UIPanelMenuItem.class;
- }
-
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context,UIComponent component) throws IOException {
-
- }
- protected void doDecode(FacesContext context, UIComponent component) {
- if(isSubmitted(context, component)) {
- new ActionEvent(component).queue();
- if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
- new AjaxEvent(component).queue();
- } else {
-
- }
- }
- }
-
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
-
- }
-
- /*
- public String getOnClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- return ";PanelMenuStorage['" + clientId + "'].trigger(event);";
- }
- */
- public void insertImage(FacesContext context, UIComponent component, Object data) throws IOException {
- String from = (String)data;
- UIPanelMenu panelMenu = findMenu(component);
- if(panelMenu == null){
- return;
- }
- String align = "";
- UIPanelMenuItem panelMenuItem = (UIPanelMenuItem)component;
- boolean isTopLevel = isTopLevel(panelMenuItem);
-
- if (isTopLevel){
- align = panelMenu.getIconItemTopPosition();
- } else {
- align = panelMenu.getIconItemPosition();
- }
-
- if (align.equalsIgnoreCase(from)){
- image(context,component);
- } else {
- String iconType = PANEL_MENU_SPACER_ICON_NAME;
- String imageSrc = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
- }
- }
-
- private void image(FacesContext context, UIComponent component)
- throws IOException{
-
- UIPanelMenu panelMenu = findMenu(component);
- ResponseWriter writer = context.getResponseWriter();
- boolean isTopLevel = isTopLevel(component);
- String source = null;
- String iconType = null;
- UIPanelMenuItem item = (UIPanelMenuItem)component;
-
- String defaultItemIcon = null;
- String customItemIcon = null;
-
- if(isTopLevel){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconTopDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconTopItem();
- }
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- } else {
- //isTopLevel == false
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- }
-
- customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
-
- if(customItemIcon == null || customItemIcon.equals("")){
- iconType = defaultItemIcon;
- } else iconType = customItemIcon;
-
- source = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(writer, iconType, source, component);
- }
-
-
- public String getFullStyleClass(FacesContext context, UIComponent component) {
- StringBuffer classBuffer = new StringBuffer("");
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if (!parentMenu.isDisabled() && !item.isDisabled()) {
- if (calculateLevel(item) == 0) {
- classBuffer.append(parentMenu.getTopItemClass()).append(" ");
- classBuffer.append("rich-pmenu-top-item ");
- } else
- classBuffer.append(parentMenu.getItemClass() + " ");
- classBuffer.append(item.getStyleClass());
- } else
- classBuffer.append(parentMenu.getDisabledItemClass() + " ")
- .append(item.getDisabledClass());
- return classBuffer.toString();
- }
-
- public String getFullStyle(FacesContext context, UIComponent component) {
- StringBuffer styleBuffer = new StringBuffer("");
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if (!item.isDisabled()) {
- if (calculateLevel(item) == 0)
- styleBuffer.append(parentMenu.getTopItemStyle() + "; ");
- else
- styleBuffer.append(parentMenu.getItemStyle() + "; ");
- styleBuffer.append(item.getStyle());
- } else
- styleBuffer.append(parentMenu.getDisabledItemStyle() + "; ")
- .append(item.getDisabledStyle());
- return styleBuffer.toString();
- }
-
- public String getLabelClass(FacesContext context, UIComponent component) {
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if(!item.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-item-label rich-pmenu-top-item-label";
- } else return "rich-pmenu-item-label";
- }
- return "";
- }
-
- public String getIconClass(FacesContext context, UIComponent component) {
- UIPanelMenuItem item = (UIPanelMenuItem)component;
- UIPanelMenu parentMenu = findMenu(item);
- if(!item.isDisabled() && !parentMenu.isDisabled()){
- if(isTopLevel(component)){
- return "rich-pmenu-item-icon rich-pmenu-top-item-icon";
- } else return "rich-pmenu-item-icon";
- }
- return "";
- }
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,436 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.richfaces.component.panelmenu.UIPanelMenu;
-import org.richfaces.component.panelmenu.UIPanelMenuGroup;
-import org.richfaces.component.panelmenu.UIPanelMenuItem;
-
-public class PanelMenuRenderer extends PanelMenuRendererBase {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- return UIComponent.class;
- }
-
- public void insertScript(FacesContext context, UIComponent component)
- throws IOException {
-
- StringBuffer buffer = new StringBuffer();
- StringBuffer panelMenu = new StringBuffer();
- List flatList = new LinkedList();
- Map levels = new HashMap();
-
- boolean expandSingle = ((UIPanelMenu)component).isExpandSingle();
-
- flatten(component.getChildren(), flatList, levels, 0);
-
- panelMenu
- .append("new PanelMenu('")
- .append(component.getClientId(context).toString())
- .append("',")
- .append(new Boolean(expandSingle).toString())
- .append(");\n");
-
- for (Iterator iter = flatList.iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
- boolean childDisabled;
- if (!((UIPanelMenu)component).isDisabled())
- childDisabled = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
- else
- childDisabled = true;
- boolean childRendered = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
- boolean parentRendered = true;
- if (! (child.getParent() instanceof UIPanelMenu))
- parentRendered = child.getParent() instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child.getParent()).isRendered() : ((UIPanelMenuItem)child.getParent()).isRendered();
- if (!parentRendered){
- child.getAttributes().put("rendered",Boolean.FALSE);
- }
-
- UIPanelMenu parentMenu = findMenu(child);
-
- String event = parentMenu.getEvent();
- if ("".equals(event))
- event = "click";
- else if (event.startsWith("on"))
- event = event.substring(2);
-
- String onopen = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
- parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
- String onclose = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
- parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
- String hoveredStyle = (child instanceof UIPanelMenuGroup ?
- parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
- + ";" + (child instanceof UIPanelMenuGroup ?
- ((UIPanelMenuGroup)child).getHoverStyle() : ((UIPanelMenuItem)child).getHoverStyle());
- String hoveredClass = (child instanceof UIPanelMenuGroup ?
- parentMenu.getHoveredGroupClass() : parentMenu.getHoveredItemClass())
- + " " + (child instanceof UIPanelMenuGroup ?
- ((UIPanelMenuGroup)child).getHoverClass() : ((UIPanelMenuItem)child).getHoverClass());
- String [] hoveredStyles = hoveredStyle.split(";");
- String [] hoveredClasses = hoveredClass.split(" ");
-
- String mode = getItemMode(child);
- Object target = child.getAttributes().get("target");
- String targetString;
- if (null == target)
- targetString = "";
- else
- targetString = target.toString();
-
-
-
- if (childRendered && parentRendered){
- if ( !isParentDisabled(child) ){
- buffer
- .append("new PanelMenuItem({myId:'")
- .append((String) child.getClientId(context))
- .append("',parentId:'")
- .append((String) child.getParent().getClientId(context))
- .append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
- .append(",onopen:"+("".equals(onopen) ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+("".equals(onclose) ? "\"\"" : "\"" + onclose + "\""))
- .append(",event:\"" + event + "\"")
- .append(",mode:\"" + mode + "\"")
- .append(",target:\"" + targetString + "\"")
- .append(",disabled:" +
- new Boolean(childDisabled).toString())
- .append("},{");
-
-
- for (int i = 0; i < hoveredStyles.length; i++)
- if (!"".equals(hoveredStyles[i])) {
- String [] temp = hoveredStyles[i].split(":");
- String cssName = temp[0].trim();
- String cssValue = temp[1].trim();
- buffer.append("\"" + cssName + "\": \"" + cssValue + "\"");
- if (i != hoveredStyles.length - 1)
- buffer.append(",");
- }
-
- buffer.append("},");
- if (hoveredClasses.length > 0) {
- buffer.append("new Array(");
- for (int i = 0; i < hoveredClasses.length; i++)
- if (!"".equals(hoveredClasses[i])) {;
- buffer.append("\"" + hoveredClasses[i] + "\"");
- if (i != hoveredClasses.length - 1)
- buffer.append(",");
- }
- buffer.append("),");
- } else
- buffer.append("new Array(),");
-
- buffer.append(levels.get(child.getClientId(context)));
- switchOnImagesIfNeeded(context,child,buffer);
-
- addActionIfNeeded(context,child,buffer);
-
- setExpandedIfNeeded(context,child,buffer);
-
- addAjaxFunction(context,child,buffer);
-
- addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
-
- String iconPos = "left";
- boolean isTopLevel = isTopLevel(child);
- if(child instanceof UIPanelMenuGroup){
- iconPos = isTopLevel ? parentMenu.getIconGroupTopPosition() : parentMenu.getIconGroupPosition();
- } else {
- iconPos = isTopLevel ? parentMenu.getIconItemTopPosition() : parentMenu.getIconItemPosition();
- }
-
- buffer.append(","+'"'+iconPos+'"');
-
- addImages(buffer,context,child,component.getClientId(context).toString());
-
- buffer.append(");\n");
- }
- } else {
- continue;
- }
- }
- }
- StringBuffer ret = new StringBuffer();
- ret.append("<script ");
- ret.append("type=\"text/javascript\" ");
- ret.append("id =\"script" + component.getClientId(context)+"\">\n");
- ret.append(panelMenu);
- ret.append(buffer);
- ret.append("\n</script>");
-
- ResponseWriter writer = context.getResponseWriter();
- writer.write(ret.toString());
- }
-
- public void flatten(List children, List flatList, Map levels,int initialLevel) {
- FacesContext context = FacesContext.getCurrentInstance();
- if (children != null) {
- for (Iterator iter = children.iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof UIPanelMenu){
- continue;
- }
- flatList.add(child);
- levels.put(child.getClientId(context), new Integer(initialLevel));
- flatten(child.getChildren(), flatList, levels, initialLevel + 1);
- }
- }
- }
-
- private void switchOnImagesIfNeeded(FacesContext context, UIComponent child, StringBuffer buffer)throws IOException {
- boolean isToplevel = isTopLevel(child);
- String customIconOpened = "";
- String customIconClosed = "";
-
- UIPanelMenu panelMenu = findMenu(child);
- if(panelMenu == null){
- return;
- }
- String iconOpened = isToplevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
- String iconClosed = isToplevel ? panelMenu.getIconCollapsedTopGroup() : panelMenu.getIconCollapsedGroup();
-
- try {
- customIconOpened = (String)child.getAttributes().get("iconOpened");
- customIconClosed = (String)child.getAttributes().get("iconClosed");
- } catch (Exception e) {}
-
- if (child instanceof UIPanelMenuItem){
- buffer.append(",false");
- } else {
- if (iconClosed.equals("custom")&&iconOpened.equals("custom")){
- if (customIconClosed.equals("")&&customIconOpened.equals("")){
- buffer.append(",false");
- } else {
- buffer.append(",true");
- }
- } else {
- buffer.append(",true");
- }
- }
- }
-
- private void addActionIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
- //TODO by nick - dima - use CommandScriptBuilder
- if (child instanceof UIPanelMenuItem){
- if (((UIPanelMenuItem)child).getAction() == null){
- buffer.append(",false");
- } else {
- buffer.append(",true");
- }
- } else {
- if (((UIPanelMenuGroup)child).getAction()!=null&&!((UIPanelMenuGroup)child).getAction().equals("")){
- buffer.append(",'panelMenuNodeAction'");
- } else {
- buffer.append(",false");
- }
- }
- }
-
- private void setExpandedIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
- if(child instanceof UIPanelMenuItem){
- buffer.append(",false");
- } else {
- UIPanelMenuGroup group = (UIPanelMenuGroup)child;
- if(group.getValue() != null){
- buffer.append(",").append(group.getValue().toString());
- } else {
- PanelMenuGroupRenderer r = (PanelMenuGroupRenderer)context.getRenderKit().getRenderer(group.getFamily(), group.getRendererType());
- boolean isNodeOpened;
- try {
- isNodeOpened = r.isOpened(context, child);
- } catch (IOException e) {
- // TODO Auto-generated catch block
-// e.printStackTrace();
- isNodeOpened = false;
- }
- buffer.append(",").append(String.valueOf(isNodeOpened));
- }
- }
- }
-
- private void addImages(StringBuffer buffer,FacesContext context,UIComponent component,String id){
- UIPanelMenu panelMenu = findMenu(component);
- if(panelMenu == null){
- return;
- }
- boolean isTopLevel = isTopLevel(component);
-
- final String PANEL_MENU_SPACER_ICON = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel,context, component);
-
- if(component instanceof UIPanelMenuItem){
- UIPanelMenuItem item = (UIPanelMenuItem)component;
-
- String defaultItemIcon = null;
- String defaultItemIconSrc = null;
- String customItemIcon = null;
- String customIconSource = null;
-
- if(isTopLevel){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconTopDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconTopItem();
- }
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- } else {
- //isTopLevel == false
- if(defaultItemIcon == null || defaultItemIcon.equals("")){
- if(item.isDisabled()){
- defaultItemIcon = panelMenu.getIconDisabledItem();
- } else {
- defaultItemIcon = panelMenu.getIconItem();
- }
- }
- }
-
- if(defaultItemIcon != null && defaultItemIcon.equals("none")){
- defaultItemIconSrc = PANEL_MENU_SPACER_ICON;
- } else {
- defaultItemIconSrc = getIconByType(defaultItemIcon, isTopLevel,context, component);
- }
-
-
- customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
- if(customItemIcon != null && customItemIcon.equals("none")){
- customIconSource = PANEL_MENU_SPACER_ICON;
- } else {
- customIconSource = getIconByType(customItemIcon, isTopLevel,context, component);
- }
-
- if(customItemIcon != null && !customItemIcon.equals("")){
- buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+" ");
- } else if (defaultItemIcon != null && !defaultItemIcon.equals("")){
- buffer.append(","+'"'+defaultItemIconSrc+'"').append(","+'"'+defaultItemIconSrc+'"'+" ");
- } else {
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+" ");
- }
- buffer.append(",\"\" ");
-
- } else if(component instanceof UIPanelMenuGroup){
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
-
- String defaultIconNodeClosed = isTopLevel ? (group.isDisabled() ? panelMenu.getIconTopDisableGroup() : panelMenu.getIconCollapsedTopGroup()) : (group.isDisabled() ? panelMenu.getIconDisabledGroup() : panelMenu.getIconCollapsedGroup());
-
- if(isTopLevel){
- if(group.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- }
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
- if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
- } else {
- if(group.isDisabled()){
- defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
- } else {
- defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
- }
- }
-
- String defaultIconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
-
- if(isTopLevel){
- defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
- if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
- } else {
- defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
- }
-
- String defaultIconNodeClosedSrc = getIconByType(defaultIconNodeClosed, isTopLevel,context, component);
- String defaultIconNodeOpenedSrc = getIconByType(defaultIconNodeOpened, isTopLevel,context, component);
-
- String iconExpanded = "";
- String iconCollapsed = "";
- String iconExpandedSource = "";
- String iconCollapsedSource = "";
-
- iconExpanded = group.isDisabled() ? group.getIconDisabled() : group.getIconExpanded();
- iconCollapsed = group.isDisabled() ? group.getIconDisabled() : group.getIconCollapsed();
- iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
- iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
-
- if(iconExpanded != null && !iconExpanded.equals("")){
- buffer.append(","+'"'+ iconExpandedSource + '"');
- } else if(defaultIconNodeOpened != null && !defaultIconNodeOpened.equals("")){
- buffer.append(","+'"'+defaultIconNodeOpenedSrc + '"');
- } else {
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
- }
-
- if(iconCollapsed != null && !iconCollapsed.equals("")){
- buffer.append(","+'"'+iconCollapsedSource+'"');
- } else if(defaultIconNodeClosed != null && !defaultIconNodeClosed.equals("")){
- buffer.append(","+'"'+defaultIconNodeClosedSrc+'"');
- } else {
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
- }
- }
- buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
- }
-
- protected void addAjaxFunction(FacesContext context, UIComponent child, StringBuffer buffer) {
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(child,
- context);
- Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
- child);
- function.addParameter(eventOptions);
-
- buffer.append(",\"");
- function.appendScript(buffer);
- buffer.append("\"");
- }
-
- protected void addOnItemHover(String menuOnItemHover, UIComponent child, StringBuffer buffer) {
- buffer.append(",\"");
- if(child instanceof UIPanelMenuItem){
- if(menuOnItemHover != null && !menuOnItemHover.equals("")) buffer.append(menuOnItemHover);
- }
- buffer.append("\"");
- }
-
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,293 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-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.component.panelmenu.UIPanelMenuGroup;
-import org.richfaces.component.panelmenu.UIPanelMenuItem;
-import org.richfaces.renderkit.iconImages.PanelMenuIconTriangle;
-import org.richfaces.renderkit.iconImages.PanelMenuIconTriangleDown;
-import org.richfaces.renderkit.iconImages.PanelMenuIconTriangleUp;
-import org.richfaces.renderkit.iconImages.PanelMenuIconDisc;
-import org.richfaces.renderkit.iconImages.PanelMenuIconGrid;
-import org.richfaces.renderkit.iconImages.PanelMenuIconChevron;
-import org.richfaces.renderkit.iconImages.PanelMenuIconChevronDown;
-import org.richfaces.renderkit.iconImages.PanelMenuIconChevronUp;
-import org.richfaces.renderkit.iconImages.PanelMenuIconSpacer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-
-/**
- * @author hans
- *
- */
-public abstract class PanelMenuRendererBase extends HeaderResourcesRendererBase {
-
- final static String PANEL_MENU_SPACER_ICON_NAME = "spacer";
-
- public void insertTDs(FacesContext context , UIComponent component) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- int level = calculateLevel(component);
- //StringBuffer buffer = new StringBuffer();
- String src = getIconByType("custom",false,context,component);
- int w = 16; //width(context);
-
- for (int i=0;i<level;i++){
- writer.startElement(HTML.td_ELEM, component);
- writer.startElement("img", component);
- writer.writeAttribute("src", src, null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("hspace", "0", null);
- writer.writeAttribute("vspace", "0", null);
- writer.writeAttribute("height", String.valueOf(w), null);
- writer.writeAttribute("width", String.valueOf(w), null);
- writer.writeAttribute("style", "display:block; ", null);
- writer.endElement("img");
- writer.endElement(HTML.td_ELEM);
- }
- }
-
- protected int calculateLevel (UIComponent component){
- int level = 0;
- UIComponent parent = component.getParent();
- while(parent != null){
- if(parent instanceof UIPanelMenu){
- return level;
- } else if(parent instanceof UIPanelMenuGroup){
- level++;
- }
- parent = parent.getParent();
- }
- return level;
- }
-
- /**
- * If icon type is a pre-defined value, return corresponding image, otherwise
- * otherwise
- * @param iconType
- * @param context
- * @param component
- * @return URI of requested image
- */
- protected String getIconByType(String iconType, boolean isTopLevel, FacesContext context,
- UIComponent component){
-
- String source = "";
- String color = "";
- Skin skin = getSkin(context);
-
- if (isTopLevel){
- color = (String) skin.getParameter(context,"panelmenu.headerBulletColor");
- } else {
- color = (String) skin.getParameter(context,"panelmenu.itemBulletColor");
- }
- if(iconType != null && !iconType.equals("none")){
- if (iconType.equals("custom")){
- source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
- } else if (iconType.equals("spacer")){
- source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
- } else if (iconType.equals("triangle")) {
- source = getResource(PanelMenuIconTriangle.class.getName()).getUri(context, color);
- } else if (iconType.equals("triangleDown")) {
- source = getResource(PanelMenuIconTriangleDown.class.getName()).getUri(context, color);
- } else if (iconType.equals("triangleUp")) {
- source = getResource(PanelMenuIconTriangleUp.class.getName()).getUri(context, color);
- } else if (iconType.equals("chevron")) {
- source = getResource(PanelMenuIconChevron.class.getName()).getUri(context, color);
- } else if (iconType.equals("chevronUp")) {
- source = getResource(PanelMenuIconChevronUp.class.getName()).getUri(context, color);
- } else if (iconType.equals("chevronDown")) {
- source = getResource(PanelMenuIconChevronDown.class.getName()).getUri(context, color);
-// } else if (iconType.equals("square")) {
-// source = getResource(PanelMenuIconSquare.class.getName()).getUri(context, color);
- } else if (iconType.equals("disc")) {
- source = getResource(PanelMenuIconDisc.class.getName()).getUri(context, color);
- } else if (iconType.equals("grid")) {
- source = getResource(PanelMenuIconGrid.class.getName()).getUri(context, color);
- } else {
- //TODO by nick - dima - TemplateContext is deprecated and shouldn't be used
- source = (String)getUtils().encodeResourceURL(new TemplateContext(this,context,component),iconType);
- }
- }
- return source;
- }
-
- protected UIPanelMenu findMenu (UIComponent component){
- if (component instanceof UIPanelMenu) return (UIPanelMenu)component;
- UIComponent parent = component;
- while(parent != null){
- if(parent instanceof UIPanelMenu){
- return (UIPanelMenu) parent;
- }
- parent = parent.getParent();
- }
- return (UIPanelMenu) parent;
- }
-
- public String getHideStyle(FacesContext context, UIComponent component) {
- 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) ){
- return "";
- } else
- return format.toString();
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else return format.toString();
- }
- return "";
- }
-
- public void insertValue(FacesContext context, UIComponent component) throws IOException {
- Object value = component.getAttributes().get("value");
- if (value!=null){
- context.getResponseWriter().write(value.toString());
- }
- }
-
- protected boolean isChildrenExpanded(UIComponent component){
- if (component.getChildren() != null){
- Iterator itr = component.getChildren().iterator();
- while(itr.hasNext()){
- UIComponent child = (UIComponent)itr.next();
- if(child instanceof UIPanelMenuGroup){
- if( ((UIPanelMenuGroup)child).isExpanded() ){
- return true;
- } else {
- return isChildrenExpanded(child);
- }
- }
- }
- }
- return false;
- }
-
- protected boolean isParentDisabled(UIComponent component){
- boolean returnValue = false;
- UIComponent parent = component.getParent();
- if(parent instanceof UIPanelMenuGroup){
- UIPanelMenuGroup parentGroup = (UIPanelMenuGroup)parent;
- if(parentGroup.isDisabled()){
- returnValue = true;
- } else {
- returnValue = isParentDisabled(parentGroup);
- }
- }
- return returnValue;
- }
-
- protected boolean isSubmitted(FacesContext context, UIComponent component){
- boolean submitted = false;
- String clientId = component.getClientId(context);
- Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
-
- Object value = requestParameterMap.get("panelMenuAction"+clientId);
- if (clientId!=null&&value!=null){
- if (value.equals(clientId)) {
- submitted = true;
- }
- }
- return submitted;
- }
-
- protected String getItemMode(UIComponent component) {
- String parentExpandMode = findMenu(component).getExpandMode();
- String parentMode = findMenu(component).getMode();
- if (null == parentMode || "".equals(parentMode))
- parentMode = "server";
- if (null == parentExpandMode || "".equals(parentExpandMode))
- parentExpandMode = "none";
- String mode = "none";
- if (component instanceof UIPanelMenuGroup) {
- UIPanelMenuGroup group = (UIPanelMenuGroup) component;
- if (null != group.getMode() && ! "".equals(group.getMode()))
- mode = group.getMode();
- else
- mode = parentExpandMode;
- } else if (component instanceof UIPanelMenuItem) {
- UIPanelMenuItem item = (UIPanelMenuItem) component;
- if (null != item.getMode() && ! "".equals(item.getMode()))
- mode = item.getMode();
- else
- mode = parentMode;
- }
- return mode;
- }
-
- /**
- *
- * @param component
- * @return
- */
- public boolean isTopLevel(UIComponent component){
- UIComponent parent = component.getParent();
- while( !(parent instanceof UIPanelMenu) && !(parent instanceof UIPanelMenuGroup)) {
- parent = parent.getParent();
- }
- if(parent instanceof UIPanelMenu){
- return true;
- } else {
- return false;
- }
- }
-
- /**
- *
- * @param writer
- * @param iconType
- * @param imageSrc
- * @param component
- * @throws IOException
- */
- public void drawIcon(ResponseWriter writer, String iconType, String imageSrc, UIComponent component) throws IOException{
- if (iconType != null && !iconType.equals("") && !iconType.equals("none")){
- int h = 16; //width(context);
- writer.startElement("img", component);
- writer.writeAttribute("src", imageSrc, null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("vspace", "0", null);
- writer.writeAttribute("hspace", "0", null);
- writer.writeAttribute("style", "display:block; ", null);
- writer.writeAttribute("width", String.valueOf(h), null);
- writer.writeAttribute("height", String.valueOf(h), null);
- writer.endElement("img");
- }
-
- }
-
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuGroupGradient.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuGroupGradient.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuGroupGradient.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,32 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.gradientImages;
-
-import org.ajax4jsf.framework.skin.Skin;
-import org.richfaces.renderkit.html.BaseGradient;
-
-public class PanelMenuGroupGradient extends BaseGradient {
- public PanelMenuGroupGradient() {
- super(10, 40, 14, "headerGradientColor", Skin.headerBackgroundColor);
- }
-
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuItemGradient.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuItemGradient.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuItemGradient.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,31 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.gradientImages;
-
-import org.ajax4jsf.framework.skin.Skin;
-import org.richfaces.renderkit.html.BaseGradient;
-
-public class PanelMenuItemGradient extends BaseGradient {
- public PanelMenuItemGradient() {
- super(10, 40, 14, "controlBackgroundColor", Skin.generalBackgroundColor);
- }
-}
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,262 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.ActionEvent;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.richfaces.component.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuGroup;
+import org.richfaces.component.UISwitchablePanel;
+
+public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
+
+ protected Class getComponentClass() {
+ return UIPanelMenuGroup.class;
+ }
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map requestMap =context.getExternalContext().getRequestParameterMap();
+ UIPanelMenuGroup group = ((UIPanelMenuGroup)component);
+
+ if(requestMap.containsKey("panelMenuState"+clientId)){
+ Object property = requestMap.get("panelMenuState"+clientId);
+ if (property.equals("opened")) {
+ group.setSubmittedValue("true");
+ } else if (property.equals("closed")) {
+ group.setSubmittedValue("false");
+ }
+
+ }
+ if(isSubmitted(context, component)){
+ new ActionEvent(component).queue();
+ if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
+ new AjaxEvent(component).queue();
+ }
+ }
+ }
+
+ public void insertImage(FacesContext context, UIComponent component, Object data)
+ throws IOException {
+
+ String from = (String)data;
+ String align = "";
+
+ UIPanelMenu panelMenu = findMenu(component);
+ boolean isTopLevel = isTopLevel(component);
+
+ if (isTopLevel){
+ align = panelMenu.getIconGroupTopPosition();
+ } else {
+ align = panelMenu.getIconGroupPosition();
+ }
+
+ if (align.equalsIgnoreCase(from)){
+ image(context,component);
+ } else {
+ String iconType = PANEL_MENU_SPACER_ICON_NAME;
+ String imageSrc = getIconByType(iconType, isTopLevel, context, component);
+ drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
+ }
+ }
+
+ private void image(FacesContext context, UIComponent component )throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ UIPanelMenu panelMenu = findMenu(component);
+ if(panelMenu == null){
+ return;
+ }
+ UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup)component;
+ boolean isTopLevel = isTopLevel(panelMenuGroup);
+
+ boolean isOpened = isOpened(context,component);
+
+
+ String defaultIconNodeClosed = null;
+
+ if(isTopLevel){
+ if(panelMenuGroup.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ }
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+ } else {
+ if(panelMenuGroup.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+
+ String defaultIconNodeOpened = null;
+
+ if(isTopLevel){
+ defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
+ if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+ } else {
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+
+ String iconExpanded = "";
+ String iconCollapsed = "";
+
+ iconExpanded = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconExpanded();
+ iconCollapsed = panelMenuGroup.isDisabled() ? panelMenuGroup.getIconDisabled() : panelMenuGroup.getIconCollapsed();
+
+ String icon = null;
+ if(isOpened){
+ if(iconExpanded != null && !iconExpanded.equals("")){
+ if(iconExpanded.equals("none")){
+ return;
+ } else {
+ icon = iconExpanded;
+ }
+ } else {
+ icon = defaultIconNodeOpened;
+ }
+ } else {
+ if(iconCollapsed!= null && !iconCollapsed.equals("")){
+ if(iconCollapsed.equals("none")){
+ return;
+ } else {
+ icon = iconCollapsed;
+ }
+ } else {
+ icon = defaultIconNodeClosed;
+ }
+ }
+ String source = getIconByType(icon, isTopLevel, context, component);
+ drawIcon(writer, icon, source, component);
+ }
+
+ public String getFullStyleClass(FacesContext context, UIComponent component) {
+ StringBuffer classBuffer = new StringBuffer("");
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if (!parentMenu.isDisabled() && !group.isDisabled()) {
+ if (calculateLevel(group) == 0)
+ classBuffer.append(parentMenu.getTopGroupClass() + " ");
+ else
+ classBuffer.append(parentMenu.getGroupClass() + " ");
+ classBuffer.append(group.getStyleClass());
+ } else
+ classBuffer.append(parentMenu.getDisabledGroupClass() + " ")
+ .append(group.getDisabledClass());
+ return classBuffer.toString();
+ }
+
+ public String getFullStyle(FacesContext context, UIComponent component) {
+ StringBuffer styleBuffer = new StringBuffer("");
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if (!group.isDisabled()) {
+ if (calculateLevel(group) == 0)
+ styleBuffer.append(parentMenu.getTopGroupStyle() + "; ");
+ else
+ styleBuffer.append(parentMenu.getGroupStyle() + "; ");
+ styleBuffer.append(group.getStyle());
+ } else
+ styleBuffer.append(parentMenu.getDisabledGroupStyle() + "; ")
+ .append(group.getDisabledStyle());
+ return styleBuffer.toString();
+ }
+
+ public void insertLabel(FacesContext context, UIComponent component) throws IOException {
+ Object label = component.getAttributes().get("label");
+ if (label!=null){
+ context.getResponseWriter().write(label.toString());
+ }
+ }
+
+ public Object getConvertedValue(FacesContext context,
+ UIComponent component, Object submittedValue)
+ throws ConverterException {
+
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ if(group.getConverter() != null){
+ return group.getConverter().getAsObject(context, component, (String)submittedValue);
+ } else {
+ return submittedValue;
+ }
+
+ }
+
+ public boolean isOpened(FacesContext context, UIComponent component)throws IOException {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+
+ Boolean value = (Boolean)group.getValue();
+ if (value != null) {
+ return value.booleanValue();
+ } else {
+ boolean isParentDisabled = isParentDisabled(component);
+ if(component instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)component).isExpanded() && !((UIPanelMenuGroup)component).isDisabled() && !isParentDisabled ){
+ return true;
+ } else {
+ //check expanded attributes in children groups, if exists
+ boolean isChildrenExpanded = isChildrenExpanded(component);
+ return isChildrenExpanded && !isParentDisabled && !((UIPanelMenuGroup)component).isDisabled();// ? "opened" : "closed";
+ }
+ }
+ }
+ return false;
+ }
+
+ public String getLabelClass(FacesContext context, UIComponent component) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if(!group.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-group-self-label rich-pmenu-top-group-self-label";
+ } else return "rich-pmenu-group-self-label";
+ }
+ return "";
+ }
+
+ public String getIconClass(FacesContext context, UIComponent component) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ if(!group.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-group-self-icon rich-pmenu-top-group-self-icon";
+ } else return "rich-pmenu-group-self-icon";
+ }
+ return "";
+ }
+
+
+}
Property changes on: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,190 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.richfaces.component.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuItem;
+import org.richfaces.component.UISwitchablePanel;
+
+public class PanelMenuItemRenderer extends PanelMenuRendererBase {
+ protected Class getComponentClass() {
+ return UIPanelMenuItem.class;
+ }
+
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,UIComponent component) throws IOException {
+
+ }
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if(isSubmitted(context, component)) {
+ new ActionEvent(component).queue();
+ if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
+ new AjaxEvent(component).queue();
+ } else {
+
+ }
+ }
+ }
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ }
+
+ /*
+ public String getOnClick(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ return ";PanelMenuStorage['" + clientId + "'].trigger(event);";
+ }
+ */
+ public void insertImage(FacesContext context, UIComponent component, Object data) throws IOException {
+ String from = (String)data;
+ UIPanelMenu panelMenu = findMenu(component);
+ if(panelMenu == null){
+ return;
+ }
+ String align = "";
+ UIPanelMenuItem panelMenuItem = (UIPanelMenuItem)component;
+ boolean isTopLevel = isTopLevel(panelMenuItem);
+
+ if (isTopLevel){
+ align = panelMenu.getIconItemTopPosition();
+ } else {
+ align = panelMenu.getIconItemPosition();
+ }
+
+ if (align.equalsIgnoreCase(from)){
+ image(context,component);
+ } else {
+ String iconType = PANEL_MENU_SPACER_ICON_NAME;
+ String imageSrc = getIconByType(iconType, isTopLevel, context, component);
+ drawIcon(context.getResponseWriter(), iconType, imageSrc, component);
+ }
+ }
+
+ private void image(FacesContext context, UIComponent component)
+ throws IOException{
+
+ UIPanelMenu panelMenu = findMenu(component);
+ ResponseWriter writer = context.getResponseWriter();
+ boolean isTopLevel = isTopLevel(component);
+ String source = null;
+ String iconType = null;
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+
+ String defaultItemIcon = null;
+ String customItemIcon = null;
+
+ if(isTopLevel){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconTopDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconTopItem();
+ }
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ } else {
+ //isTopLevel == false
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ }
+
+ customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
+
+ if(customItemIcon == null || customItemIcon.equals("")){
+ iconType = defaultItemIcon;
+ } else iconType = customItemIcon;
+
+ source = getIconByType(iconType, isTopLevel, context, component);
+ drawIcon(writer, iconType, source, component);
+ }
+
+
+ public String getFullStyleClass(FacesContext context, UIComponent component) {
+ StringBuffer classBuffer = new StringBuffer("");
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if (!parentMenu.isDisabled() && !item.isDisabled()) {
+ if (calculateLevel(item) == 0) {
+ classBuffer.append(parentMenu.getTopItemClass()).append(" ");
+ classBuffer.append("rich-pmenu-top-item ");
+ } else
+ classBuffer.append(parentMenu.getItemClass() + " ");
+ classBuffer.append(item.getStyleClass());
+ } else
+ classBuffer.append(parentMenu.getDisabledItemClass() + " ")
+ .append(item.getDisabledClass());
+ return classBuffer.toString();
+ }
+
+ public String getFullStyle(FacesContext context, UIComponent component) {
+ StringBuffer styleBuffer = new StringBuffer("");
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if (!item.isDisabled()) {
+ if (calculateLevel(item) == 0)
+ styleBuffer.append(parentMenu.getTopItemStyle() + "; ");
+ else
+ styleBuffer.append(parentMenu.getItemStyle() + "; ");
+ styleBuffer.append(item.getStyle());
+ } else
+ styleBuffer.append(parentMenu.getDisabledItemStyle() + "; ")
+ .append(item.getDisabledStyle());
+ return styleBuffer.toString();
+ }
+
+ public String getLabelClass(FacesContext context, UIComponent component) {
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if(!item.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-item-label rich-pmenu-top-item-label";
+ } else return "rich-pmenu-item-label";
+ }
+ return "";
+ }
+
+ public String getIconClass(FacesContext context, UIComponent component) {
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ if(!item.isDisabled() && !parentMenu.isDisabled()){
+ if(isTopLevel(component)){
+ return "rich-pmenu-item-icon rich-pmenu-top-item-icon";
+ } else return "rich-pmenu-item-icon";
+ }
+ return "";
+ }
+}
Property changes on: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,436 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.richfaces.component.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuGroup;
+import org.richfaces.component.UIPanelMenuItem;
+
+public class PanelMenuRenderer extends PanelMenuRendererBase {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ return UIComponent.class;
+ }
+
+ public void insertScript(FacesContext context, UIComponent component)
+ throws IOException {
+
+ StringBuffer buffer = new StringBuffer();
+ StringBuffer panelMenu = new StringBuffer();
+ List flatList = new LinkedList();
+ Map levels = new HashMap();
+
+ boolean expandSingle = ((UIPanelMenu)component).isExpandSingle();
+
+ flatten(component.getChildren(), flatList, levels, 0);
+
+ panelMenu
+ .append("new PanelMenu('")
+ .append(component.getClientId(context).toString())
+ .append("',")
+ .append(new Boolean(expandSingle).toString())
+ .append(");\n");
+
+ for (Iterator iter = flatList.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
+ boolean childDisabled;
+ if (!((UIPanelMenu)component).isDisabled())
+ childDisabled = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
+ else
+ childDisabled = true;
+ boolean childRendered = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
+ boolean parentRendered = true;
+ if (! (child.getParent() instanceof UIPanelMenu))
+ parentRendered = child.getParent() instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child.getParent()).isRendered() : ((UIPanelMenuItem)child.getParent()).isRendered();
+ if (!parentRendered){
+ child.getAttributes().put("rendered",Boolean.FALSE);
+ }
+
+ UIPanelMenu parentMenu = findMenu(child);
+
+ String event = parentMenu.getEvent();
+ if ("".equals(event))
+ event = "click";
+ else if (event.startsWith("on"))
+ event = event.substring(2);
+
+ String onopen = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
+ parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
+ String onclose = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
+ parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
+ String hoveredStyle = (child instanceof UIPanelMenuGroup ?
+ parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
+ + ";" + (child instanceof UIPanelMenuGroup ?
+ ((UIPanelMenuGroup)child).getHoverStyle() : ((UIPanelMenuItem)child).getHoverStyle());
+ String hoveredClass = (child instanceof UIPanelMenuGroup ?
+ parentMenu.getHoveredGroupClass() : parentMenu.getHoveredItemClass())
+ + " " + (child instanceof UIPanelMenuGroup ?
+ ((UIPanelMenuGroup)child).getHoverClass() : ((UIPanelMenuItem)child).getHoverClass());
+ String [] hoveredStyles = hoveredStyle.split(";");
+ String [] hoveredClasses = hoveredClass.split(" ");
+
+ String mode = getItemMode(child);
+ Object target = child.getAttributes().get("target");
+ String targetString;
+ if (null == target)
+ targetString = "";
+ else
+ targetString = target.toString();
+
+
+
+ if (childRendered && parentRendered){
+ if ( !isParentDisabled(child) ){
+ buffer
+ .append("new PanelMenuItem({myId:'")
+ .append((String) child.getClientId(context))
+ .append("',parentId:'")
+ .append((String) child.getParent().getClientId(context))
+ .append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
+ .append(",onopen:"+("".equals(onopen) ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+("".equals(onclose) ? "\"\"" : "\"" + onclose + "\""))
+ .append(",event:\"" + event + "\"")
+ .append(",mode:\"" + mode + "\"")
+ .append(",target:\"" + targetString + "\"")
+ .append(",disabled:" +
+ new Boolean(childDisabled).toString())
+ .append("},{");
+
+
+ for (int i = 0; i < hoveredStyles.length; i++)
+ if (!"".equals(hoveredStyles[i])) {
+ String [] temp = hoveredStyles[i].split(":");
+ String cssName = temp[0].trim();
+ String cssValue = temp[1].trim();
+ buffer.append("\"" + cssName + "\": \"" + cssValue + "\"");
+ if (i != hoveredStyles.length - 1)
+ buffer.append(",");
+ }
+
+ buffer.append("},");
+ if (hoveredClasses.length > 0) {
+ buffer.append("new Array(");
+ for (int i = 0; i < hoveredClasses.length; i++)
+ if (!"".equals(hoveredClasses[i])) {;
+ buffer.append("\"" + hoveredClasses[i] + "\"");
+ if (i != hoveredClasses.length - 1)
+ buffer.append(",");
+ }
+ buffer.append("),");
+ } else
+ buffer.append("new Array(),");
+
+ buffer.append(levels.get(child.getClientId(context)));
+ switchOnImagesIfNeeded(context,child,buffer);
+
+ addActionIfNeeded(context,child,buffer);
+
+ setExpandedIfNeeded(context,child,buffer);
+
+ addAjaxFunction(context,child,buffer);
+
+ addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
+
+ String iconPos = "left";
+ boolean isTopLevel = isTopLevel(child);
+ if(child instanceof UIPanelMenuGroup){
+ iconPos = isTopLevel ? parentMenu.getIconGroupTopPosition() : parentMenu.getIconGroupPosition();
+ } else {
+ iconPos = isTopLevel ? parentMenu.getIconItemTopPosition() : parentMenu.getIconItemPosition();
+ }
+
+ buffer.append(","+'"'+iconPos+'"');
+
+ addImages(buffer,context,child,component.getClientId(context).toString());
+
+ buffer.append(");\n");
+ }
+ } else {
+ continue;
+ }
+ }
+ }
+ StringBuffer ret = new StringBuffer();
+ ret.append("<script ");
+ ret.append("type=\"text/javascript\" ");
+ ret.append("id =\"script" + component.getClientId(context)+"\">\n");
+ ret.append(panelMenu);
+ ret.append(buffer);
+ ret.append("\n</script>");
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.write(ret.toString());
+ }
+
+ public void flatten(List children, List flatList, Map levels,int initialLevel) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (children != null) {
+ for (Iterator iter = children.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof UIPanelMenu){
+ continue;
+ }
+ flatList.add(child);
+ levels.put(child.getClientId(context), new Integer(initialLevel));
+ flatten(child.getChildren(), flatList, levels, initialLevel + 1);
+ }
+ }
+ }
+
+ private void switchOnImagesIfNeeded(FacesContext context, UIComponent child, StringBuffer buffer)throws IOException {
+ boolean isToplevel = isTopLevel(child);
+ String customIconOpened = "";
+ String customIconClosed = "";
+
+ UIPanelMenu panelMenu = findMenu(child);
+ if(panelMenu == null){
+ return;
+ }
+ String iconOpened = isToplevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
+ String iconClosed = isToplevel ? panelMenu.getIconCollapsedTopGroup() : panelMenu.getIconCollapsedGroup();
+
+ try {
+ customIconOpened = (String)child.getAttributes().get("iconOpened");
+ customIconClosed = (String)child.getAttributes().get("iconClosed");
+ } catch (Exception e) {}
+
+ if (child instanceof UIPanelMenuItem){
+ buffer.append(",false");
+ } else {
+ if (iconClosed.equals("custom")&&iconOpened.equals("custom")){
+ if (customIconClosed.equals("")&&customIconOpened.equals("")){
+ buffer.append(",false");
+ } else {
+ buffer.append(",true");
+ }
+ } else {
+ buffer.append(",true");
+ }
+ }
+ }
+
+ private void addActionIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
+ //TODO by nick - dima - use CommandScriptBuilder
+ if (child instanceof UIPanelMenuItem){
+ if (((UIPanelMenuItem)child).getAction() == null){
+ buffer.append(",false");
+ } else {
+ buffer.append(",true");
+ }
+ } else {
+ if (((UIPanelMenuGroup)child).getAction()!=null&&!((UIPanelMenuGroup)child).getAction().equals("")){
+ buffer.append(",'panelMenuNodeAction'");
+ } else {
+ buffer.append(",false");
+ }
+ }
+ }
+
+ private void setExpandedIfNeeded(FacesContext context,UIComponent child,StringBuffer buffer){
+ if(child instanceof UIPanelMenuItem){
+ buffer.append(",false");
+ } else {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)child;
+ if(group.getValue() != null){
+ buffer.append(",").append(group.getValue().toString());
+ } else {
+ PanelMenuGroupRenderer r = (PanelMenuGroupRenderer)context.getRenderKit().getRenderer(group.getFamily(), group.getRendererType());
+ boolean isNodeOpened;
+ try {
+ isNodeOpened = r.isOpened(context, child);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+// e.printStackTrace();
+ isNodeOpened = false;
+ }
+ buffer.append(",").append(String.valueOf(isNodeOpened));
+ }
+ }
+ }
+
+ private void addImages(StringBuffer buffer,FacesContext context,UIComponent component,String id){
+ UIPanelMenu panelMenu = findMenu(component);
+ if(panelMenu == null){
+ return;
+ }
+ boolean isTopLevel = isTopLevel(component);
+
+ final String PANEL_MENU_SPACER_ICON = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel,context, component);
+
+ if(component instanceof UIPanelMenuItem){
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+
+ String defaultItemIcon = null;
+ String defaultItemIconSrc = null;
+ String customItemIcon = null;
+ String customIconSource = null;
+
+ if(isTopLevel){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconTopDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconTopItem();
+ }
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ } else {
+ //isTopLevel == false
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
+ }
+
+ if(defaultItemIcon != null && defaultItemIcon.equals("none")){
+ defaultItemIconSrc = PANEL_MENU_SPACER_ICON;
+ } else {
+ defaultItemIconSrc = getIconByType(defaultItemIcon, isTopLevel,context, component);
+ }
+
+
+ customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
+ if(customItemIcon != null && customItemIcon.equals("none")){
+ customIconSource = PANEL_MENU_SPACER_ICON;
+ } else {
+ customIconSource = getIconByType(customItemIcon, isTopLevel,context, component);
+ }
+
+ if(customItemIcon != null && !customItemIcon.equals("")){
+ buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+" ");
+ } else if (defaultItemIcon != null && !defaultItemIcon.equals("")){
+ buffer.append(","+'"'+defaultItemIconSrc+'"').append(","+'"'+defaultItemIconSrc+'"'+" ");
+ } else {
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+" ");
+ }
+ buffer.append(",\"\" ");
+
+ } else if(component instanceof UIPanelMenuGroup){
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+
+ String defaultIconNodeClosed = isTopLevel ? (group.isDisabled() ? panelMenu.getIconTopDisableGroup() : panelMenu.getIconCollapsedTopGroup()) : (group.isDisabled() ? panelMenu.getIconDisabledGroup() : panelMenu.getIconCollapsedGroup());
+
+ if(isTopLevel){
+ if(group.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ }
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
+ if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+ } else {
+ if(group.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
+ } else {
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
+ }
+ }
+
+ String defaultIconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
+
+ if(isTopLevel){
+ defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
+ if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+ } else {
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+
+ String defaultIconNodeClosedSrc = getIconByType(defaultIconNodeClosed, isTopLevel,context, component);
+ String defaultIconNodeOpenedSrc = getIconByType(defaultIconNodeOpened, isTopLevel,context, component);
+
+ String iconExpanded = "";
+ String iconCollapsed = "";
+ String iconExpandedSource = "";
+ String iconCollapsedSource = "";
+
+ iconExpanded = group.isDisabled() ? group.getIconDisabled() : group.getIconExpanded();
+ iconCollapsed = group.isDisabled() ? group.getIconDisabled() : group.getIconCollapsed();
+ iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
+ iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
+
+ if(iconExpanded != null && !iconExpanded.equals("")){
+ buffer.append(","+'"'+ iconExpandedSource + '"');
+ } else if(defaultIconNodeOpened != null && !defaultIconNodeOpened.equals("")){
+ buffer.append(","+'"'+defaultIconNodeOpenedSrc + '"');
+ } else {
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
+ }
+
+ if(iconCollapsed != null && !iconCollapsed.equals("")){
+ buffer.append(","+'"'+iconCollapsedSource+'"');
+ } else if(defaultIconNodeClosed != null && !defaultIconNodeClosed.equals("")){
+ buffer.append(","+'"'+defaultIconNodeClosedSrc+'"');
+ } else {
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON + '"');
+ }
+ }
+ buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
+ }
+
+ protected void addAjaxFunction(FacesContext context, UIComponent child, StringBuffer buffer) {
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(child,
+ context);
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
+ child);
+ function.addParameter(eventOptions);
+
+ buffer.append(",\"");
+ function.appendScript(buffer);
+ buffer.append("\"");
+ }
+
+ protected void addOnItemHover(String menuOnItemHover, UIComponent child, StringBuffer buffer) {
+ buffer.append(",\"");
+ if(child instanceof UIPanelMenuItem){
+ if(menuOnItemHover != null && !menuOnItemHover.equals("")) buffer.append(menuOnItemHover);
+ }
+ buffer.append("\"");
+ }
+
+}
Property changes on: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,293 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+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.UIPanelMenu;
+import org.richfaces.component.UIPanelMenuGroup;
+import org.richfaces.component.UIPanelMenuItem;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevron;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevronDown;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconChevronUp;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconDisc;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconGrid;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconSpacer;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangle;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleDown;
+import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleUp;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+
+/**
+ * @author hans
+ *
+ */
+public abstract class PanelMenuRendererBase extends HeaderResourcesRendererBase {
+
+ final static String PANEL_MENU_SPACER_ICON_NAME = "spacer";
+
+ public void insertTDs(FacesContext context , UIComponent component) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ int level = calculateLevel(component);
+ //StringBuffer buffer = new StringBuffer();
+ String src = getIconByType("custom",false,context,component);
+ int w = 16; //width(context);
+
+ for (int i=0;i<level;i++){
+ writer.startElement(HTML.td_ELEM, component);
+ writer.startElement("img", component);
+ writer.writeAttribute("src", src, null);
+ writer.writeAttribute("alt", "", null);
+ writer.writeAttribute("hspace", "0", null);
+ writer.writeAttribute("vspace", "0", null);
+ writer.writeAttribute("height", String.valueOf(w), null);
+ writer.writeAttribute("width", String.valueOf(w), null);
+ writer.writeAttribute("style", "display:block; ", null);
+ writer.endElement("img");
+ writer.endElement(HTML.td_ELEM);
+ }
+ }
+
+ protected int calculateLevel (UIComponent component){
+ int level = 0;
+ UIComponent parent = component.getParent();
+ while(parent != null){
+ if(parent instanceof UIPanelMenu){
+ return level;
+ } else if(parent instanceof UIPanelMenuGroup){
+ level++;
+ }
+ parent = parent.getParent();
+ }
+ return level;
+ }
+
+ /**
+ * If icon type is a pre-defined value, return corresponding image, otherwise
+ * otherwise
+ * @param iconType
+ * @param context
+ * @param component
+ * @return URI of requested image
+ */
+ protected String getIconByType(String iconType, boolean isTopLevel, FacesContext context,
+ UIComponent component){
+
+ String source = "";
+ String color = "";
+ Skin skin = getSkin(context);
+
+ if (isTopLevel){
+ color = (String) skin.getParameter(context,"panelmenu.headerBulletColor");
+ } else {
+ color = (String) skin.getParameter(context,"panelmenu.itemBulletColor");
+ }
+ if(iconType != null && !iconType.equals("none")){
+ if (iconType.equals("custom")){
+ source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
+ } else if (iconType.equals("spacer")){
+ source = getResource(PanelMenuIconSpacer.class.getName()).getUri(context, color);
+ } else if (iconType.equals("triangle")) {
+ source = getResource(PanelMenuIconTriangle.class.getName()).getUri(context, color);
+ } else if (iconType.equals("triangleDown")) {
+ source = getResource(PanelMenuIconTriangleDown.class.getName()).getUri(context, color);
+ } else if (iconType.equals("triangleUp")) {
+ source = getResource(PanelMenuIconTriangleUp.class.getName()).getUri(context, color);
+ } else if (iconType.equals("chevron")) {
+ source = getResource(PanelMenuIconChevron.class.getName()).getUri(context, color);
+ } else if (iconType.equals("chevronUp")) {
+ source = getResource(PanelMenuIconChevronUp.class.getName()).getUri(context, color);
+ } else if (iconType.equals("chevronDown")) {
+ source = getResource(PanelMenuIconChevronDown.class.getName()).getUri(context, color);
+// } else if (iconType.equals("square")) {
+// source = getResource(PanelMenuIconSquare.class.getName()).getUri(context, color);
+ } else if (iconType.equals("disc")) {
+ source = getResource(PanelMenuIconDisc.class.getName()).getUri(context, color);
+ } else if (iconType.equals("grid")) {
+ source = getResource(PanelMenuIconGrid.class.getName()).getUri(context, color);
+ } else {
+ //TODO by nick - dima - TemplateContext is deprecated and shouldn't be used
+ source = (String)getUtils().encodeResourceURL(new TemplateContext(this,context,component),iconType);
+ }
+ }
+ return source;
+ }
+
+ protected UIPanelMenu findMenu (UIComponent component){
+ if (component instanceof UIPanelMenu) return (UIPanelMenu)component;
+ UIComponent parent = component;
+ while(parent != null){
+ if(parent instanceof UIPanelMenu){
+ return (UIPanelMenu) parent;
+ }
+ parent = parent.getParent();
+ }
+ return (UIPanelMenu) parent;
+ }
+
+ public String getHideStyle(FacesContext context, UIComponent component) {
+ 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) ){
+ return "";
+ } else
+ return format.toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else return format.toString();
+ }
+ return "";
+ }
+
+ public void insertValue(FacesContext context, UIComponent component) throws IOException {
+ Object value = component.getAttributes().get("value");
+ if (value!=null){
+ context.getResponseWriter().write(value.toString());
+ }
+ }
+
+ protected boolean isChildrenExpanded(UIComponent component){
+ if (component.getChildren() != null){
+ Iterator itr = component.getChildren().iterator();
+ while(itr.hasNext()){
+ UIComponent child = (UIComponent)itr.next();
+ if(child instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)child).isExpanded() ){
+ return true;
+ } else {
+ return isChildrenExpanded(child);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ protected boolean isParentDisabled(UIComponent component){
+ boolean returnValue = false;
+ UIComponent parent = component.getParent();
+ if(parent instanceof UIPanelMenuGroup){
+ UIPanelMenuGroup parentGroup = (UIPanelMenuGroup)parent;
+ if(parentGroup.isDisabled()){
+ returnValue = true;
+ } else {
+ returnValue = isParentDisabled(parentGroup);
+ }
+ }
+ return returnValue;
+ }
+
+ protected boolean isSubmitted(FacesContext context, UIComponent component){
+ boolean submitted = false;
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+
+ Object value = requestParameterMap.get("panelMenuAction"+clientId);
+ if (clientId!=null&&value!=null){
+ if (value.equals(clientId)) {
+ submitted = true;
+ }
+ }
+ return submitted;
+ }
+
+ protected String getItemMode(UIComponent component) {
+ String parentExpandMode = findMenu(component).getExpandMode();
+ String parentMode = findMenu(component).getMode();
+ if (null == parentMode || "".equals(parentMode))
+ parentMode = "server";
+ if (null == parentExpandMode || "".equals(parentExpandMode))
+ parentExpandMode = "none";
+ String mode = "none";
+ if (component instanceof UIPanelMenuGroup) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup) component;
+ if (null != group.getMode() && ! "".equals(group.getMode()))
+ mode = group.getMode();
+ else
+ mode = parentExpandMode;
+ } else if (component instanceof UIPanelMenuItem) {
+ UIPanelMenuItem item = (UIPanelMenuItem) component;
+ if (null != item.getMode() && ! "".equals(item.getMode()))
+ mode = item.getMode();
+ else
+ mode = parentMode;
+ }
+ return mode;
+ }
+
+ /**
+ *
+ * @param component
+ * @return
+ */
+ public boolean isTopLevel(UIComponent component){
+ UIComponent parent = component.getParent();
+ while( !(parent instanceof UIPanelMenu) && !(parent instanceof UIPanelMenuGroup)) {
+ parent = parent.getParent();
+ }
+ if(parent instanceof UIPanelMenu){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param writer
+ * @param iconType
+ * @param imageSrc
+ * @param component
+ * @throws IOException
+ */
+ public void drawIcon(ResponseWriter writer, String iconType, String imageSrc, UIComponent component) throws IOException{
+ if (iconType != null && !iconType.equals("") && !iconType.equals("none")){
+ int h = 16; //width(context);
+ writer.startElement("img", component);
+ writer.writeAttribute("src", imageSrc, null);
+ writer.writeAttribute("alt", "", null);
+ writer.writeAttribute("vspace", "0", null);
+ writer.writeAttribute("hspace", "0", null);
+ writer.writeAttribute("style", "display:block; ", null);
+ writer.writeAttribute("width", String.valueOf(h), null);
+ writer.writeAttribute("height", String.valueOf(h), null);
+ writer.endElement("img");
+ }
+
+ }
+
+}
Property changes on: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRendererBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuGroupGradient.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuGroupGradient.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuGroupGradient.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuGroupGradient.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,32 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.gradientimages;
+
+import org.ajax4jsf.framework.skin.Skin;
+import org.richfaces.renderkit.html.BaseGradient;
+
+public class PanelMenuGroupGradient extends BaseGradient {
+ public PanelMenuGroupGradient() {
+ super(10, 40, 14, "headerGradientColor", Skin.headerBackgroundColor);
+ }
+
+}
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuItemGradient.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/gradientImages/PanelMenuItemGradient.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuItemGradient.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/gradientimages/PanelMenuItemGradient.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,31 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.gradientimages;
+
+import org.ajax4jsf.framework.skin.Skin;
+import org.richfaces.renderkit.html.BaseGradient;
+
+public class PanelMenuItemGradient extends BaseGradient {
+ public PanelMenuItemGradient() {
+ super(10, 40, 14, "controlBackgroundColor", Skin.generalBackgroundColor);
+ }
+}
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconBasic.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconBasic.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconBasic.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconBasic.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,95 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.resource.GifRenderer;
+import org.ajax4jsf.framework.resource.InternetResourceBuilder;
+import org.ajax4jsf.framework.resource.Java2Dresource;
+import org.ajax4jsf.framework.resource.ResourceContext;
+import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.skin.SkinFactory;
+import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.framework.util.HtmlDimensions;
+
+
+/**
+ * @author Pavel Kotikov
+ *
+ */
+public class PanelMenuIconBasic extends Java2Dresource {
+
+ public PanelMenuIconBasic() {
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return calculateDimensions(getDataToStore(facesContext, data));
+ }
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return calculateDimensions(restoreData(resourceContext));
+ }
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+
+ }
+
+ protected Dimension calculateDimensions(Object data){
+ Object [] stored = (Object []) data;
+ int h = ((Integer) stored[0]).intValue();
+ return new Dimension(h,h);
+ }
+
+
+ /**
+ * @param data - pass icon color there
+ */
+ protected Object getDataToStore(FacesContext context, Object data) {
+ Object[] stored = new Object[5];
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+
+ stored[0] = new Integer(HtmlDimensions.decode("16px").intValue());
+
+ Color col = null;
+
+ if (data!=null){
+ col = HtmlColor.decode(data.toString());
+ } else {
+ col = HtmlColor.decode(skin.getParameter(context, "headerTextColor").toString());
+ }
+ stored[1]= col;
+ return stored;
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+}
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevron.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevron.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevron.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevron.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,81 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconChevron extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D graphics2d) {
+
+ BufferedImage bufferedImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bufferedImage.createGraphics();
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ Dimension dimension = getDimensions(context);
+ GeneralPath path = new GeneralPath();
+ g2d.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
+ g2d.translate(28,28);
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ g2d.setColor(col);
+
+ path.moveTo(1,1);
+ path.lineTo(17,1);
+ path.lineTo(47,31);
+ path.lineTo(17,61);
+ path.lineTo(1,61);
+ path.lineTo(31,31);
+ path.closePath();
+ g2d.fill(path);
+
+ g2d.translate(24,0);
+
+ g2d.fill(path);
+
+ AffineTransform transform = AffineTransform.getScaleInstance(dimension.getHeight()/128, dimension.getHeight()/128);
+ AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
+
+ graphics2d.drawImage(bufferedImage,transformOp, 0, 0);
+
+ g2d.dispose();
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronDown.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronDown.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronDown.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronDown.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconChevronDown extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D graphics2D) {
+ BufferedImage bufferedImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bufferedImage.createGraphics();
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ Dimension dimension = getDimensions(context);
+ GeneralPath path = new GeneralPath();
+ g2d.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
+ g2d.translate(28,28);
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ g2d.setColor(col);
+
+ path.moveTo(1,0);
+ path.lineTo(31,30);
+ path.lineTo(61,0);
+ path.lineTo(61,16);
+ path.lineTo(31,46);
+ path.lineTo(1,16);
+ path.closePath();
+ g2d.fill(path);
+
+ g2d.translate(0,24);
+
+ g2d.fill(path);
+
+ AffineTransform transform = AffineTransform.getScaleInstance(dimension.getHeight()/128, dimension.getHeight()/128);
+ AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
+
+ graphics2D.drawImage(bufferedImage,transformOp, 0, 0);
+
+ g2d.dispose();
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronUp.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronUp.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronUp.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconChevronUp.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconChevronUp extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D graphics2D) {
+ BufferedImage bufferedImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bufferedImage.createGraphics();
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ Dimension dimension = getDimensions(context);
+ GeneralPath path = new GeneralPath();
+ g2d.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
+ g2d.translate(28,28);
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ g2d.setColor(col);
+
+ path.moveTo(0,46);
+ path.lineTo(0,31);
+ path.lineTo(30,1);
+ path.lineTo(61,31);
+ path.lineTo(61,46);
+ path.lineTo(30,16);
+ path.closePath();
+ g2d.fill(path);
+
+ g2d.translate(0,24);
+
+ g2d.fill(path);
+
+ AffineTransform transform = AffineTransform.getScaleInstance(dimension.getHeight()/128, dimension.getHeight()/128);
+ AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
+
+ graphics2D.drawImage(bufferedImage,transformOp, 0, 0);
+
+ g2d.dispose();
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconDisc.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconDisc.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconDisc.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconDisc.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Ellipse2D;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconDisc extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+
+ Dimension dimension = getDimensions(context);
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ int dim = (int) Math.round(dimension.getWidth() / 3);
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setColor(col);
+ g2d.translate(dim,dim);
+ Ellipse2D dot = new Ellipse2D.Double(0, 0, dim, dim);
+ g2d.fill(dot);
+
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconGrid.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconGrid.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconGrid.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconGrid.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,63 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconGrid extends PanelMenuIconBasic {
+
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ Rectangle2D.Float path = new Rectangle2D.Float();
+ Dimension dimension = getDimensions(context);
+ g2d.setStroke(new BasicStroke(16,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_BEVEL));
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+
+ g2d.translate(40,40);
+
+ path.setRect(0,0,40,40);
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ g2d.setColor(col);
+ Color bcolor = new Color(1f,1f,1f,0f);
+ g2d.setBackground(bcolor);
+ g2d.fill(path);
+ g2d.clearRect(16,0,8,40);
+ g2d.clearRect(0,16,40,8);
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconSpacer.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconSpacer.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconSpacer.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconSpacer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.Graphics2D;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+public class PanelMenuIconSpacer extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangle.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangle.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangle.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangle.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+public class PanelMenuIconTriangle extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+ g2d.translate(47,30);
+ path.moveTo(0,0);
+ path.lineTo(33,33);
+ path.lineTo(33,34);
+ path.lineTo(0,67);
+ path.closePath();
+ g2d.setColor((Color)(((Object[]) restoreData(context))[1]));
+ g2d.fill(path);
+ }
+}
\ No newline at end of file
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleDown.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleDown.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleDown.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleDown.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,57 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconTriangleDown extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+ g2d.translate(31,54);
+
+ path.moveTo(0,0);
+ path.lineTo(33,33);
+ path.lineTo(34,33);
+ path.lineTo(67,0);
+ path.closePath();
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ g2d.setColor(col);
+ g2d.fill(path);
+ }
+}
Copied: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleUp.java (from rev 1128, trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleUp.java)
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleUp.java (rev 0)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/iconimages/PanelMenuIconTriangleUp.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -0,0 +1,56 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.iconimages;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+import org.ajax4jsf.framework.resource.ResourceContext;
+
+
+
+public class PanelMenuIconTriangleUp extends PanelMenuIconBasic {
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+ g2d.translate(31,47);
+ path.moveTo(0,33);
+ path.lineTo(33,0);
+ path.lineTo(34,0);
+ path.lineTo(67,33);
+ path.closePath();
+ Object [] data = (Object[]) restoreData(context);
+ Color col = (Color)data[1];
+
+ g2d.setColor(col);
+ g2d.fill(path);
+ }
+}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconBasic.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconBasic.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconBasic.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,95 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.InternetResourceBuilder;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceContext;
-import org.ajax4jsf.framework.skin.Skin;
-import org.ajax4jsf.framework.skin.SkinFactory;
-import org.ajax4jsf.framework.util.HtmlColor;
-import org.ajax4jsf.framework.util.HtmlDimensions;
-
-
-/**
- * @author Pavel Kotikov
- *
- */
-public class PanelMenuIconBasic extends Java2Dresource {
-
- public PanelMenuIconBasic() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return calculateDimensions(getDataToStore(facesContext, data));
- }
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return calculateDimensions(restoreData(resourceContext));
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
-
- }
-
- protected Dimension calculateDimensions(Object data){
- Object [] stored = (Object []) data;
- int h = ((Integer) stored[0]).intValue();
- return new Dimension(h,h);
- }
-
-
- /**
- * @param data - pass icon color there
- */
- protected Object getDataToStore(FacesContext context, Object data) {
- Object[] stored = new Object[5];
- Skin skin = SkinFactory.getInstance().getSkin(context);
-
- stored[0] = new Integer(HtmlDimensions.decode("16px").intValue());
-
- Color col = null;
-
- if (data!=null){
- col = HtmlColor.decode(data.toString());
- } else {
- col = HtmlColor.decode(skin.getParameter(context, "headerTextColor").toString());
- }
- stored[1]= col;
- return stored;
- }
-
- public boolean isCacheable() {
- return true;
- }
-
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevron.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevron.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevron.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,81 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconChevron extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D graphics2d) {
-
- BufferedImage bufferedImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = bufferedImage.createGraphics();
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- Dimension dimension = getDimensions(context);
- GeneralPath path = new GeneralPath();
- g2d.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
- g2d.translate(28,28);
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- g2d.setColor(col);
-
- path.moveTo(1,1);
- path.lineTo(17,1);
- path.lineTo(47,31);
- path.lineTo(17,61);
- path.lineTo(1,61);
- path.lineTo(31,31);
- path.closePath();
- g2d.fill(path);
-
- g2d.translate(24,0);
-
- g2d.fill(path);
-
- AffineTransform transform = AffineTransform.getScaleInstance(dimension.getHeight()/128, dimension.getHeight()/128);
- AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
-
- graphics2d.drawImage(bufferedImage,transformOp, 0, 0);
-
- g2d.dispose();
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronDown.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronDown.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronDown.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,80 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconChevronDown extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D graphics2D) {
- BufferedImage bufferedImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = bufferedImage.createGraphics();
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- Dimension dimension = getDimensions(context);
- GeneralPath path = new GeneralPath();
- g2d.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
- g2d.translate(28,28);
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- g2d.setColor(col);
-
- path.moveTo(1,0);
- path.lineTo(31,30);
- path.lineTo(61,0);
- path.lineTo(61,16);
- path.lineTo(31,46);
- path.lineTo(1,16);
- path.closePath();
- g2d.fill(path);
-
- g2d.translate(0,24);
-
- g2d.fill(path);
-
- AffineTransform transform = AffineTransform.getScaleInstance(dimension.getHeight()/128, dimension.getHeight()/128);
- AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
-
- graphics2D.drawImage(bufferedImage,transformOp, 0, 0);
-
- g2d.dispose();
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronUp.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronUp.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconChevronUp.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,80 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconChevronUp extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D graphics2D) {
- BufferedImage bufferedImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = bufferedImage.createGraphics();
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- Dimension dimension = getDimensions(context);
- GeneralPath path = new GeneralPath();
- g2d.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
- g2d.translate(28,28);
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- g2d.setColor(col);
-
- path.moveTo(0,46);
- path.lineTo(0,31);
- path.lineTo(30,1);
- path.lineTo(61,31);
- path.lineTo(61,46);
- path.lineTo(30,16);
- path.closePath();
- g2d.fill(path);
-
- g2d.translate(0,24);
-
- g2d.fill(path);
-
- AffineTransform transform = AffineTransform.getScaleInstance(dimension.getHeight()/128, dimension.getHeight()/128);
- AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
-
- graphics2D.drawImage(bufferedImage,transformOp, 0, 0);
-
- g2d.dispose();
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconDisc.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconDisc.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconDisc.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.Ellipse2D;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconDisc extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
-
- Dimension dimension = getDimensions(context);
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- int dim = (int) Math.round(dimension.getWidth() / 3);
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setColor(col);
- g2d.translate(dim,dim);
- Ellipse2D dot = new Ellipse2D.Double(0, 0, dim, dim);
- g2d.fill(dot);
-
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconGrid.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconGrid.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconGrid.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,63 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.Rectangle2D;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconGrid extends PanelMenuIconBasic {
-
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- Rectangle2D.Float path = new Rectangle2D.Float();
- Dimension dimension = getDimensions(context);
- g2d.setStroke(new BasicStroke(16,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_BEVEL));
- g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
-
- g2d.translate(40,40);
-
- path.setRect(0,0,40,40);
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- g2d.setColor(col);
- Color bcolor = new Color(1f,1f,1f,0f);
- g2d.setBackground(bcolor);
- g2d.fill(path);
- g2d.clearRect(16,0,8,40);
- g2d.clearRect(0,16,40,8);
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconSpacer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconSpacer.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconSpacer.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.Graphics2D;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-public class PanelMenuIconSpacer extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
-
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangle.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangle.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangle.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,51 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.GeneralPath;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-public class PanelMenuIconTriangle extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- GeneralPath path = new GeneralPath();
-
- Dimension dimension = getDimensions(context);
- g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
- g2d.translate(47,30);
- path.moveTo(0,0);
- path.lineTo(33,33);
- path.lineTo(33,34);
- path.lineTo(0,67);
- path.closePath();
- g2d.setColor((Color)(((Object[]) restoreData(context))[1]));
- g2d.fill(path);
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleDown.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleDown.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleDown.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,57 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.GeneralPath;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconTriangleDown extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- GeneralPath path = new GeneralPath();
-
- Dimension dimension = getDimensions(context);
-
- g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
- g2d.translate(31,54);
-
- path.moveTo(0,0);
- path.lineTo(33,33);
- path.lineTo(34,33);
- path.lineTo(67,0);
- path.closePath();
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- g2d.setColor(col);
- g2d.fill(path);
- }
-}
Deleted: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleUp.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleUp.java 2007-06-13 15:37:49 UTC (rev 1161)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/iconImages/PanelMenuIconTriangleUp.java 2007-06-13 16:07:14 UTC (rev 1162)
@@ -1,56 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.iconImages;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.GeneralPath;
-import org.ajax4jsf.framework.resource.ResourceContext;
-
-
-
-public class PanelMenuIconTriangleUp extends PanelMenuIconBasic {
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- GeneralPath path = new GeneralPath();
-
- Dimension dimension = getDimensions(context);
-
- g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
- g2d.translate(31,47);
- path.moveTo(0,33);
- path.lineTo(33,0);
- path.lineTo(34,0);
- path.lineTo(67,33);
- path.closePath();
- Object [] data = (Object[]) restoreData(context);
- Color col = (Color)data[1];
-
- g2d.setColor(col);
- g2d.fill(path);
- }
-}
17 years, 7 months
JBoss Rich Faces SVN: r1160 - trunk/sandbox/calendar/design/calendar-js.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-13 11:29:09 -0400 (Wed, 13 Jun 2007)
New Revision: 1160
Added:
trunk/sandbox/calendar/design/calendar-js/calendar-prototype.js
Modified:
trunk/sandbox/calendar/design/calendar-js/calendar-xhtml.html
Log:
Calendar prototype updated
Added: trunk/sandbox/calendar/design/calendar-js/calendar-prototype.js
===================================================================
--- trunk/sandbox/calendar/design/calendar-js/calendar-prototype.js (rev 0)
+++ trunk/sandbox/calendar/design/calendar-js/calendar-prototype.js 2007-06-13 15:29:09 UTC (rev 1160)
@@ -0,0 +1,220 @@
+if(!LOG){
+ var LOG = {warn:function(){}};
+}
+
+if(!Richfaces) var Richfaces={};
+
+Richfaces.evalMacro = function(template, object)
+{
+ var value="";
+ try { with (object) value=eval(template) } catch (e) { LOG.warn("Exception: "+e.Message + "\n[" + template + "]"); }
+ return value;
+}
+
+function isLeapYear(year) {
+ return new Date(year, 1, 29).getDate()==29;
+}
+
+function daysInMonth(year,month) {
+ return 32 - new Date(year, month, 32).getDate();
+}
+
+function daysInMonthByDate(date) {
+ return 32 - new Date(date.getYear(), date.getMonth(), 32).getDate();
+}
+
+function y2k(number) { return (number < 1000) ? number + 1900 : number; }
+
+function getDay(date, firstWeekDay ) {
+ var value = date.getDay() - firstWeekDay;
+ if (value < 0) value = 7 + value;
+ return value;
+}
+
+function weekNumber(year, month, mdifw, fdow) {
+ year = y2k(year);
+ var tfdow = fdow;
+ var firstDay = new Date(year,0,1);
+ var fDay = firstDay.getDay();
+ var daynum = ((Date.UTC(y2k(year),month,1,0,0,0) - Date.UTC(y2k(year),0,1,0,0,0)) /1000/60/60/24)+1 ;
+ var weeknum = Math.round((daynum+7)/7);
+ if(fDay == 0) fDay = 7;
+ if(tfdow == 0) tfdow = 7;
+ var delta = Math.abs(fDay-tfdow);
+ if(delta == 0)return weeknum;
+ if(tfdow < fDay) delta = 7 - delta;
+ if(delta < mdifw) weeknum--;
+ return weeknum;
+}
+
+Calendar = Class.create();
+Object.extend(Calendar.prototype, {
+ initialize: function(id,parameters) {
+
+ // dayListTableId, weekNumberBarId, weekDayBarId - 3 tables ids',
+ // dayListMarkupArray - array [0..41] of day cell markup
+ // weekNumberMarkup - week number cell markup
+ // weekDayMarkup - week day cell markup
+
+ // currentDate - date to show month (day not used) (mm/yyyy)
+ // selectedDate - selected date (mm/dd/yyyy)
+ // weekDayLabels - collection of week day labels keyed by week day numbers
+ // minDaysInFirstWeek - locale-specific constant defining number of days in the first week
+ // firstWeekDay - (0..6) locale-specific constant defining number of the first week day
+
+ this.id = id;
+ this.dayListTableId = parameters.dayListTableId;
+ this.weekNumberBarId = parameters.weekNumberBarId;
+ this.weekDayBarId = parameters.weekDayBarId;
+
+ this.weekNumberMarkup = parameters.weekNumberMarkup;
+ this.weekDayMarkup = parameters.weekDayMarkup;
+ this.dayListMarkupArray = parameters.dayListMarkupArray;
+ this.currentDate = parameters.currentDate;
+ this.todayDate = new Date(); /// May be not needed
+ this.selectedDate = parameters.SelectedDate;
+ this.weekDayLabels = parameters.weekDayLabels;
+ this.firstWeekDay = parameters.firstWeekDay;
+ this.minDaysInFirstWeek = parameters.minDaysInFirstWeek;
+
+ this.daysData = {startDate:null, days:[]};
+
+ var htmlTextHeader = '<div id="div_'+parameters.dayListTableId+'"></div><table border="1" id="'+parameters.dayListTableId+'">\n';
+ var htmlTextFooter = '</table>\n';
+
+ // days bar creation
+ var htmlTextWeekDayBar = '<tr id="'+parameters.weekDayBarId+'"><td></td>';
+ var weekDayCounter = this.firstWeekDay;
+ for (var i=0;i<7;i++)
+ {
+ var weekDayHtml = this.weekDayMarkup( {weekDay: this.weekDayLabels[weekDayCounter]} );
+ if (weekDayCounter==6) weekDayCounter=0; else weekDayCounter++;
+
+ htmlTextWeekDayBar+='<td id="'+parameters.weekDayBarId+i+'">'+weekDayHtml+'</td>';
+ }
+ htmlTextWeekDayBar+='</tr>\n';
+
+ // week & weekNumber creation
+ var htmlTextWeek="";
+ var p=0;
+
+ for (k=1;k<7;k++)
+ {
+
+ var weekNumberHtml = this.weekNumberMarkup( {weekNumber: k} );
+
+ htmlTextWeek+='<tr><td id="'+parameters.weekNumberBarId+k+'">'+weekNumberHtml+'</td>';
+ for (var i=0;i<7;i++)
+ {
+ htmlTextWeek+='<td style="vertical-align:top"></td>';
+ }
+ htmlTextWeek+='</tr>';
+ }
+
+ // set content
+ var obj=document.getElementById(id);
+ obj.innerHTML = htmlTextHeader+htmlTextWeekDayBar+htmlTextWeek+htmlTextFooter;
+ },
+
+ load:function(daysData) {
+ // startDate,
+ // days:array[]
+ // {
+ // data
+ // enabled
+ // isEnabled function
+ // text1: 'Meeting...',
+ // text2: 'Meeting...'
+ // tooltip
+ // hasTooltip
+ // dayStyleClass
+ // }
+
+ this.daysData = this.indexData(daysData);
+ this.update();
+ },
+
+ indexData:function(daysData) {
+ var dateYear = y2k(daysData.startDate.getYear());
+ var dateMonth = daysData.startDate.getMonth();
+
+ daysData.index = [];
+ daysData.index[dateYear+'-'+dateMonth] = 0;
+ var idx = daysInMonthByDate(daysData.startDate)-daysData.startDate.getDate()+1;
+
+ while (daysData.days[idx])
+ {
+ if (dateMonth==11) {dateYear++; dateMonth=0;} else dateMonth++;
+ daysData.index[dateYear+'-'+dateMonth] = idx;
+ idx+= (32 - new Date(dateYear, dateMonth, 32).getDate());
+ }
+ return daysData;
+ },
+
+ update:function() {
+
+ //this.currentDate = daysData.startDate;
+ var currentYear = y2k(this.currentDate.getYear());
+ var currentMonth = this.currentDate.getMonth();
+
+ var dateDiv = document.getElementById("div_"+this.dayListTableId);
+ dateDiv.innerHTML = currentYear + "/" + (currentMonth+1);
+
+
+ var wd = getDay(this.currentDate, this.firstWeekDay);
+ var currentMonthDays = daysInMonthByDate(this.currentDate);
+ var previousMonthDays = daysInMonth(currentYear, currentMonth-1);
+ var wn = weekNumber(currentYear, currentMonth, this.minDaysInFirstWeek, this.firstWeekDay) /// fix it
+
+ var p=0;
+ var days = [];
+ var dayCounter = previousMonthDays - wd + 1;
+ // previuos month days
+ if (wd>0) while (dayCounter<=previousMonthDays) {days.push({day:dayCounter++}); p++; }
+ dayCounter = 1;
+
+ // current month days
+ if (this.daysData.index[currentYear+'-'+currentMonth]!=undefined)
+ {
+ var idx = this.daysData.index[currentYear+'-'+currentMonth];
+ var firstDay = this.daysData.days[idx].day;
+ while (dayCounter<firstDay) { days.push({day:dayCounter++}); p++; }
+
+ var len = this.daysData.days.length;
+ while (idx<len && dayCounter<=currentMonthDays) { days.push(this.daysData.days[idx]); idx++; dayCounter++; p++;}
+
+ while (dayCounter<=currentMonthDays) { days.push({day:dayCounter++}); p++; }
+
+ } else while (dayCounter<=currentMonthDays) { days.push({day:dayCounter++}); p++; }
+ dayCounter = 1;
+
+ // next month days
+ var ld = 7-p%7;
+ while (dayCounter<=ld) { days.push({day:dayCounter++}); }
+
+ // render
+ p=0;
+ for (var k=1;k<7;k++)
+ {
+ //
+ var obj = document.getElementById(this.weekNumberBarId+k).parentNode;
+
+ obj.childNodes[0].innerHTML = (days[p]) ? this.weekNumberMarkup( {weekNumber: wn++} ) : "";
+
+ for (var i=1;i<obj.childNodes.length;i++)
+ {
+ obj.childNodes[i].innerHTML = (days[p]) ? this.dayListMarkupArray[p]( days[p++] ) : "";
+ }
+ }
+ },
+ nextMonth: function() {
+ this.currentDate = new Date(y2k(this.currentDate.getYear()), this.currentDate.getMonth()+1,1);
+ this.update();
+ },
+
+ prevMonth: function() {
+ this.currentDate = new Date(y2k(this.currentDate.getYear()), this.currentDate.getMonth()-1,1);
+ this.update();
+ }
+
+});
\ No newline at end of file
Modified: trunk/sandbox/calendar/design/calendar-js/calendar-xhtml.html
===================================================================
--- trunk/sandbox/calendar/design/calendar-js/calendar-xhtml.html 2007-06-13 15:21:35 UTC (rev 1159)
+++ trunk/sandbox/calendar/design/calendar-js/calendar-xhtml.html 2007-06-13 15:29:09 UTC (rev 1160)
@@ -8,126 +8,80 @@
<meta http-equiv="Content-Type" content="text/xhtml" />
<script src="prototype-1.5.1.js" type="text/javascript"></script>
+<script src="calendar-prototype.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
-var DAYS = ["Mon","Tue","Wen","Thu","Fri","Sat","Sun"];
-
-Calendar = Class.create();
-Object.extend(Calendar.prototype, {
- initialize: function(id,parameters) {
- // dayListTableId, weekNumberBarId, weekDayBarId � 3 tables ids',
- // dayListMarkupArray � array [0..41] of day cell markup
- // weekNumberMarkup � week number cell markup
- // weekDayMarkup � week day cell markup
- this.id = id;
- this.dayListTableId = parameters.dayListTableId;
- this.weekNumberBarId = parameters.weekNumberBarId;
- this.weekDayBarId = parameters.weekDayBarId;
-
- this.weekNumberMarkup = parameters.weekNumberMarkup;
- this.weekDayMarkup = parameters.weekDayMarkup;
- this.dayListMarkupArray = parameters.dayListMarkupArray;
-
- var htmlTextHeader = '<table border="1" id="'+parameters.dayListTableId+'">\n';
- var htmlTextFooter = '</table>\n';
-
- // days bar creation
- var htmlTextWeekDayBar = '<tr id="'+parameters.weekDayBarId+'"><td></td>';
- for (var i=0;i<7;i++)
- {
- var weekDayParam = {
- weekDay: DAYS[i]
- };
- var weekDayHtml;
-
- with(weekDayParam) {
- weekDayHtml = eval(this.weekDayMarkup);
- };
-
- htmlTextWeekDayBar+='<td id="'+parameters.weekDayBarId+i+'">'+weekDayHtml+'</td>';
- }
- htmlTextWeekDayBar+='</tr>\n';
-
- // week & weekNumber creation
- var htmlTextWeek="";
- var p=0;
-
- for (k=1;k<7;k++)
- {
- var weekNumberParam = {
- weekNumber: k
- };
- var weekNumberHtml;
-
- with(weekNumberParam) {
- weekNumberHtml = eval(this.weekNumberMarkup);
- };
-
- htmlTextWeek+='<tr><td id="'+parameters.weekNumberBarId+k+'">'+weekNumberHtml+'</td>';
- for (var i=0;i<7;i++)
- {
- htmlTextWeek+='<td></td>';
- }
- htmlTextWeek+='</tr>';
- }
-
- // set content
- var obj=document.getElementById(id);
- obj.innerHTML = htmlTextHeader+htmlTextWeekDayBar+htmlTextWeek+htmlTextFooter;
- },
-
- load:function(daysData) {
- //��� ������ ������ load(daysData), ������� ��������� ��� ��������
- //daysData � array [0..41] of dayData instances, where dayData = {
- // day: (1..42),
- // text1: �Meeting�..�,
- // text2: �Meeting�..�
- //}
-
- var p=0;
- for (var k=1;k<7;k++)
- {
- var obj = document.getElementById(this.weekNumberBarId+k).parentNode;
-
- for (var i=1;i<obj.childNodes.length;i++)
- {
- with (daysData[p]) {
- obj.childNodes[i].innerHTML = eval(this.dayListMarkupArray[p]);
- }
- p++;
- }
- }
- }
-});
-
function createCalendar()
{
//var cellMarkup = '\'<div style="width:50%; float:left; disply:inline; border-bottom:1px solid #e0e0e0;"> </div><div style="width:50%; float:left; disply:inline; border-bottom:1px solid #e0e0e0;">\'+day+\'</div><div style="width:50%;float:left; disply:inline; border-bottom:1px solid #e0e0e0;"></div><div style="width:50%; float:left; disply:inline; border-bottom:1px solid #e0e0e0;"></div><div style="width:100%; border-bottom:1px solid #e0e0e0;">\'+text1+\'</div><div style="width:100%">\'+text2+\'</div>\'';
- var cellMarkup = '\'<table><tr><td> </td><td>\'+day+\'</td></tr><tr><td> </td><td> </td></tr><tr><td colspan="2">\'+text1+\'</td></tr><tr><td colspan="2">\'+text2+\'</td></tr></table>\'';
+ //var cellMarkup = '\'<table><tr><td> </td><td>\'+ev("day")+\'</td></tr><tr><td> </td><td> </td></tr><tr><td colspan="2">\'+ev("text1")+\'</td></tr><tr><td colspan="2">\'+ev("text2")+\'</td></tr></table>\'';
+ cellMarkup = function (obj) {
+ m1 = Richfaces.evalMacro('day',obj);
+ m2 = Richfaces.evalMacro('text1',obj);
+ m3 = Richfaces.evalMacro('text2',obj);
+ return '<table><tr><td> </td><td>'+m1+'</td></tr><tr><td> </td><td> </td></tr><tr><td colspan="2">'+m2+'</td></tr><tr><td colspan="2">'+m3+'</td></tr></table>';
+ };
var m = new Array();
for (var i = 0; i < 42; i++) {
m.push(cellMarkup);
}
- var weekDayMarkup = '"<i>"+weekDay+"</i>"';
- var weekNumberMarkup = '"<b style=\'padding: 10px;\'>"+weekNumber+"</b>"';
+ weekDayMarkup = function (obj) {
+ return '<i>'+Richfaces.evalMacro('weekDay', obj)+'</i>';
+ };
- window.testCalendar = new Calendar('calendar',{dayListTableId:'aaa',weekNumberBarId:'bbb',weekDayBarId:'ccc',dayListMarkupArray: m, weekDayMarkup: weekDayMarkup, weekNumberMarkup: weekNumberMarkup});
+ weekNumberMarkup = function (obj) {
+
+ return '<b style="padding: 10px;">'+Richfaces.evalMacro('weekNumber', obj)+'</b>';
+ };
+
+
+ window.testCalendar = new Calendar('calendar',{dayListTableId:'aaa',weekNumberBarId:'bbb',weekDayBarId:'ccc',dayListMarkupArray: m, weekDayMarkup: weekDayMarkup, weekNumberMarkup: weekNumberMarkup, currentDate: new Date(2007,6,1), selectedDate: new Date(2007,4,5), weekDayLabels:['Sun','Mon','Tue','Wen','Thu','Fri','Sat'], firstWeekDay: 1, minDaysInFirstWeek:4});
loadDataSet1();
}
function loadDataSet1()
{
- var a = new Array();
- for (var i=0; i<42; i++)
+ // startDate,
+ // array[]
+ // {
+ // dayData
+ // enabled
+ // isEnabled function
+ // text1: 'Meeting...',
+ // text2: 'Meeting...'
+ // tooltip
+ // hasTooltip
+ // dayStyleClass
+ // }
+ var data_obj = {startDate:new Date(2007,5,10), days: []};
+ for (var i=10; i<=daysInMonth(2007,5); i++)
{
- a.push({day:i,text1:"data set1 for day "+i,text2:"text2 for day "+i});
+ data_obj.days.push({day: i,
+ text1: "data set 1 for day "+i,
+ text2: "<span style='color: green; font-size: 10px;'>just text</span>"
+ });
}
+ for (var i=1; i<=daysInMonth(2007,6); i++)
+ {
+ data_obj.days.push({day: i,
+ text1: "data set 1 for day "+i,
+ text2: "<span style='color: green; font-size: 10px;'>just text</span>"
+ });
+ }
- window.testCalendar.load(a);
+ for (var i=1; i<=7; i++)
+ {
+ data_obj.days.push({day: i,
+ text1: "data set 1 for day "+i,
+ text2: "<span style='color: green; font-size: 10px;'>just text</span>"
+ });
+ }
+
+ window.testCalendar.load(data_obj);
}
function loadDataSet2()
@@ -137,6 +91,10 @@
{
a.push({day:i,text2:"data set 2 for day "+i,text1:"<span style='color: red; font-size: 20px;'>just text</span>"});
}
+ for (var i=0; i<42; i++)
+ {
+ a.push({day:i,text2:"data set 2 for day "+i,text1:"<span style='color: red; font-size: 20px;'>just text</span>"});
+ }
window.testCalendar.load(a);
}
@@ -156,6 +114,11 @@
eval('loadDataSet'+$F(Event.element(event))+'()');
}
+
+function changeMonth(v) {
+ if (v) window.testCalendar.nextMonth(); else window.testCalendar.prevMonth();
+}
+
//]]>
</script>
@@ -165,6 +128,7 @@
<input type="radio" name="dataSet" value="1" id="set1" onchange="selectDataSet(event)" onclick="selectDataSet(event)" checked="checked" /><label for="set1">Set 1</label><br />
<input type="radio" name="dataSet" value="2" id="set2" onchange="selectDataSet(event)" onclick="selectDataSet(event)" /><label for="set2">Set 2</label><br />
<input type="radio" name="dataSet" value="3" id="set3" onchange="selectDataSet(event)" onclick="selectDataSet(event)" /><label for="set3">Set 3</label><br />
+<button onclick="changeMonth(false)">prev month</button><button onclick="changeMonth(true)">next month</button><br />
<div id="calendar">Hello</div>
</body>
</html>
17 years, 7 months
JBoss Rich Faces SVN: r1159 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 11:21:35 -0400 (Wed, 13 Jun 2007)
New Revision: 1159
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-13 15:20:03 UTC (rev 1158)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-13 15:21:35 UTC (rev 1159)
@@ -303,7 +303,7 @@
public String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
String id = grid.getBaseClientId(context);
- return "Richfaces_ScrollableGrid_" + id.replaceAll("[^A-Za-z0-9_]", "_");
+ return "window.Richfaces_ScrollableGrid_" + id.replaceAll("[^A-Za-z0-9_]", "_");
}
public String createClientScrollableGrid(FacesContext context, UIScrollableGrid grid) {
17 years, 7 months
JBoss Rich Faces SVN: r1158 - trunk/sandbox/scrollable-grid/src/main/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2007-06-13 11:20:03 -0400 (Wed, 13 Jun 2007)
New Revision: 1158
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js
Log:
Fix multiple script inclusion collisions
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js 2007-06-13 15:19:25 UTC (rev 1157)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js 2007-06-13 15:20:03 UTC (rev 1158)
@@ -3,6 +3,8 @@
// TODO: Copyright (c) 2007, Denis Morozov (dmorozov(a)exadel.com)
// ...
+if(!ClientUILib) {
+
var ClientUILib = {
Version: '1.0.0',
Name: 'ClientUILib',
@@ -209,3 +211,12 @@
layouts: {}
};
+// Some helper functions\
+if(!ClientUILib.isIE){
+ HTMLElement.prototype.click = function() {
+ var evt = this.ownerDocument.createEvent('MouseEvents');
+ evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
+ this.dispatchEvent(evt);
+ }
+}
+};
17 years, 7 months