JBoss Rich Faces SVN: r1127 - trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-06-11 13:41:18 -0400 (Mon, 11 Jun 2007)
New Revision: 1127
Modified:
trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp
Log:
Modified: trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp 2007-06-11 17:35:08 UTC (rev 1126)
+++ trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp 2007-06-11 17:41:18 UTC (rev 1127)
@@ -3,10 +3,13 @@
<%@ taglib uri="http://richfaces.ajax4jsf.org/panelmenu" prefix="pm" %>
<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<html>
-
+ <head>
+ <style type="text/css">
+ </style>
+ </head>
<body>
<f:view>
- <pm:panelMenu iconItemTopPosition="right" iconItemPosition="right" iconGroupPosition="left" iconGroupTopPosition="left" expandSingle="false" iconExpandedGroup="grid" iconCollapsedGroup="chevron" iconItem="disc" iconTopItem="triangle" iconDisabledItem="grid" iconDisabledGroup="disc" iconTopDisableGroup="triangleDown" iconExpandedTopGroup="chevron">
+ <pm:panelMenu>
<pm:panelMenuGroup label="Group 1" iconExpanded="disc" iconCollapsed="chevron">
<pm:panelMenuItem value="Item 1" icon="chevronUp">
</pm:panelMenuItem>
17 years, 7 months
JBoss Rich Faces SVN: r1126 - in trunk/sandbox/panelmenu/src/main: java/org/richfaces/component/panelmenu and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-06-11 13:35:08 -0400 (Mon, 11 Jun 2007)
New Revision: 1126
Modified:
trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
Log:
itemHover&standart attributes added to PanelMenu
Modified: trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml 2007-06-11 17:20:51 UTC (rev 1125)
+++ trunk/sandbox/panelmenu/src/main/config/component/panelMenu.xml 2007-06-11 17:35:08 UTC (rev 1126)
@@ -123,25 +123,25 @@
<name>iconItemPosition</name>
<classname>java.lang.String</classname>
<description>Position of the icon (left, right none (default) ) for the item icon</description>
- <defaultvalue><![CDATA["none"]]></defaultvalue>
+ <defaultvalue><![CDATA["left"]]></defaultvalue>
</property>
<property>
<name>iconItemTopPosition</name>
<classname>java.lang.String</classname>
<description>Position of the icon (left, right none (default) ) for the top item icon</description>
- <defaultvalue><![CDATA["none"]]></defaultvalue>
+ <defaultvalue><![CDATA["left"]]></defaultvalue>
</property>
<property>
<name>iconGroupPosition</name>
<classname>java.lang.String</classname>
<description>Position of the icon (left, right none (default) ) for the group icon</description>
- <defaultvalue><![CDATA["none"]]></defaultvalue>
+ <defaultvalue><![CDATA["left"]]></defaultvalue>
</property>
<property>
<name>iconGroupTopPosition</name>
<classname>java.lang.String</classname>
<description>Position of the icon (left, right none (default) ) for the top group icon</description>
- <defaultvalue><![CDATA["none"]]></defaultvalue>
+ <defaultvalue><![CDATA["left"]]></defaultvalue>
</property>
<property>
<name>style</name>
@@ -207,7 +207,7 @@
<name>disabledItemClass</name>
<classname>java.lang.String</classname>
<description></description>
- <defaultvalue><![CDATA["dr-pmenu-disabled-element"]]></defaultvalue>
+ <defaultvalue><![CDATA["dr-pmenu-disabled-element rich-pmenu-disabled-element"]]></defaultvalue>
</property>
<property>
<name>disabledItemStyle</name>
@@ -219,7 +219,7 @@
<name>disabledGroupClass</name>
<classname>java.lang.String</classname>
<description></description>
- <defaultvalue><![CDATA["dr-pmenu-disabled-element"]]></defaultvalue>
+ <defaultvalue><![CDATA["dr-pmenu-disabled-element rich-pmenu-disabled-element"]]></defaultvalue>
</property>
<property>
<name>disabledGroupStyle</name>
@@ -231,7 +231,7 @@
<name>hoveredItemClass</name>
<classname>java.lang.String</classname>
<description></description>
- <defaultvalue><![CDATA["dr-pmenu-hovered-element"]]></defaultvalue>
+ <defaultvalue><![CDATA["dr-pmenu-hovered-element rich-pmenu-hovered-element"]]></defaultvalue>
</property>
<property>
<name>hoveredItemStyle</name>
@@ -249,10 +249,44 @@
<name>hoveredGroupClass</name>
<classname>java.lang.String</classname>
<description></description>
- <defaultvalue><![CDATA["dr-pmenu-hovered-element"]]></defaultvalue>
+ <defaultvalue><![CDATA["dr-pmenu-hovered-element rich-pmenu-hovered-element"]]></defaultvalue>
</property>
&ui_component_attributes;
- &html_events;
+ &html_events;
+
+ <property>
+ <name>onclick</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>ondblclick</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onmouseout</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onmousemove</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onmouseover</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
+
+
<property>
<name>onitemhover</name>
<classname>java.lang.String</classname>
@@ -275,7 +309,7 @@
<name>disabled</name>
<classname>boolean</classname>
<description>
- If “true” sets state of the item to disabled state. “false” is default.
+ If true sets state of the item to disabled state. false is default.
</description>
<defaultvalue>false</defaultvalue>
</property>
Modified: trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java 2007-06-11 17:20:51 UTC (rev 1125)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java 2007-06-11 17:35:08 UTC (rev 1126)
@@ -89,4 +89,21 @@
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();
+
+
+
}
Modified: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-11 17:20:51 UTC (rev 1125)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-11 17:35:08 UTC (rev 1126)
@@ -162,6 +162,8 @@
addAjaxFunction(context,child,buffer);
+ addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
+
String iconPos = "left";
boolean isTopLevel = isTopLevel(child);
if(child instanceof UIPanelMenuGroup){
@@ -423,4 +425,12 @@
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("\"");
+ }
+
}
Modified: trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
--- trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-06-11 17:20:51 UTC (rev 1125)
+++ trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-06-11 17:35:08 UTC (rev 1126)
@@ -24,7 +24,7 @@
PanelMenuItem = Class.create();
PanelMenuItem.prototype = {
- initialize: function(ids, options, hoveredStyles, hoveredClasses, level, haveDynamicIcon, action, opened, ajaxFunction, iconAlign, iconExpanded, iconCollapsed, iconSpacer){
+ initialize: function(ids, options, hoveredStyles, hoveredClasses, level, haveDynamicIcon, action, opened, ajaxFunction, onItemHover, iconAlign, iconExpanded, iconCollapsed, iconSpacer){
if (!ids.parentId){return};
this.type = options.type;
this.onopen = options.onopen;
@@ -37,6 +37,7 @@
this.mode = ("node" == this.type) ? "none" : "server";
this.ajaxSubmit = ajaxFunction;
+ this.onItemHover = onItemHover;
this.target = options.target;
this.hoveredStyles = hoveredStyles;
@@ -336,6 +337,12 @@
}
},
+ hoverItem: function (e){
+ if(this.onItemHover != ""){
+ eval(this.onItemHover);
+ }
+ },
+
_attachBehaviors: function() {
if (!this.disabled) {
if (this.event)
@@ -343,6 +350,8 @@
else
Event.observe(this.obj, "click", this.itemClicked.bindAsEventListener(this), false);
+ Event.observe(this.obj, "mouseover", this.hoverItem.bindAsEventListener(this), false);
+
Event.observe(this.obj, "mouseover", this.addHoverStyles.bindAsEventListener(this), false);
Event.observe(this.obj, "mouseout", this.removeHoverStyles.bindAsEventListener(this), false);
Modified: trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
===================================================================
--- trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-06-11 17:20:51 UTC (rev 1125)
+++ trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-06-11 17:35:08 UTC (rev 1126)
@@ -26,7 +26,12 @@
<f:call name="utils.encodeBeginFormIfNessesary"/>
<table cellpadding="0" cellspacing="0"
style="#{component.style};" class="#{component.styleClass}"
- id="#{clientId}" width="#{component.width}" >
+ id="#{clientId}" width="#{component.width}"
+ onclick="#{component.onclick}"
+ ondblclick="#{component.ondblclick}"
+ onmousemove="#{component.onmousemove}"
+ onmouseout="#{component.onmouseout}"
+ onmouseover="#{component.onmouseover}">
<tbody>
<vcp:body>
17 years, 7 months
JBoss Rich Faces SVN: r1125 - in trunk/sandbox/scrollable-grid/src/main: javascript and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-06-11 13:20:51 -0400 (Mon, 11 Jun 2007)
New Revision: 1125
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js
Log:
trying to fix IE incompatibility
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-11 17:17:50 UTC (rev 1124)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-11 17:20:51 UTC (rev 1125)
@@ -3,7 +3,6 @@
*/
package org.richfaces.model.selection;
-import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-11 17:17:50 UTC (rev 1124)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-11 17:20:51 UTC (rev 1125)
@@ -5,12 +5,15 @@
importNode: function(node, bKids) {
var nodeName = node.nodeName.toUpperCase();
+
+ //LOG.debug("Importing node " + Utils.DOM._formatNode(node));
switch(nodeName) {
case "TBODY":
case "TR":
case "TD":
{
+ //LOG.debug("Creating new node ");
var imported = document.createElement(nodeName);
this.copyAttributes(imported, node);
@@ -22,28 +25,37 @@
var importedKid = this.importNode(kid, true);
- imported.appendChild(importedKid);
+ imported.insertBefore(importedKid, null);
}
}
return imported;
}
- default:
- return (document.importNode(node, bKids));
+ default: {
+ var imported = document.createElement(nodeName);
+ imported.outerHTML = node.xml;
+ return imported;
+ }
}
},
- copyAttributes : function(target, source) {
-
+ copyAttributes : function(target, source, opts) {
+ //LOG.debug("Copying attributes from " + Utils.DOM._formatNode(source) + " to " + Utils.DOM._formatNode(target) );
var attrs = source.attributes;
+ var exclusions = (opts && opts.exclude) ? opts.exclude : [];
+
for(var i = 0 ; i < attrs.length; i++) {
var attributeNode = attrs[i];
+ var nodeName = attributeNode.nodeName;
+ var nodeValue = attributeNode.nodeValue;
- if(attributeNode.specified) {
+ if(attributeNode.specified && nodeValue && nodeValue.length > 0 && exclusions.indexOf(nodeName) < 0) {
+ //LOG.debug("Copying attribute " + attributeNode.nodeName + "=" + attributeNode.nodeValue);
+
var newAttributeNode =
- document.createAttribute(attributeNode.nodeName);
+ document.createAttribute(nodeName);
newAttributeNode.nodeValue = attributeNode.nodeValue;
target.setAttributeNode(newAttributeNode);
@@ -56,17 +68,138 @@
replaceNode : function(id, request) {
var target = document.getElementById(id);
var src = request.getElementById(id);
+
+ Utils.DOM.Event.removeListeners(target);
+
- var importProvider = ClientUILib.isIE ? this : document;
+ if (ClientUILib.isIE) {
+ var theDoc = document;
+ var createEl = theDoc.createElement;
+ var row = target.cloneNode(false);
+
+ this.copyAttributes(row, src);
+
+ for (var td = src.firstChild; td; td = td.nextSibling) {
+
+ var outer = td.xml;
+ var openTag = outer.indexOf('>');
+ var closeTag = outer.lastIndexOf('<');
+
+ var inner = outer.substring(openTag + 1, closeTag);
+
+ var cell = createEl(td.tagName.toUpperCase());
+
+ cell.innerHTML = inner;
+
+
+
+ this.copyAttributes(cell, td);
+ row.insertBefore(cell, null);
+ }
+
+ src = row;
+
+ } else {
+
+ src = document.importNode(src, true);
+
+ }
- src = importProvider.importNode(src, true);
+ //var importProvider = ClientUILib.isIE ? this : document;
+
+ //src = importProvider.importNode(src, true);
+
target.parentNode.replaceChild(src, target);
+
+
return src;
+ },
+
+ _formatNode : function(node) {
+
+ var sb = new StringBuilder();
+
+ sb.append("<").append(node.nodeName);
+ for (var i = 0; i < node.attributes.length; i++) {
+ var attr = node.attributes[i];
+ if (attr.specified) {
+ sb
+ .append(" ")
+ .append(attr.nodeName)
+ .append("=\"")
+ .append(attr.nodeValue)
+ .append("\" ");
+ }
+ }
+
+ sb.append("/>");
+
+ return sb.toString();
+
+ },
+
+ Event: {
+
+ /**
+ * cache listeners in element to kill them all on element ajax replace
+ * @param {Object} element
+ * @param {Object} event
+ * @param {Object} handler
+ * @param {Object} useCapture
+ */
+ observe : function (element, event, handler, useCapture) {
+ if (true) {
+ if (!element._listeners) {
+ element._listeners = [];
+ }
+
+ element._listeners[element._listeners.length] =
+ {
+ event: event,
+ handler: handler,
+ useCapture: useCapture
+ };
+ }
+ Event.observe(element, event, handler, useCapture);
+ },
+
+ stopObserving : function(element, event, handler, useCapture) {
+
+ if(element._listeners) {
+ element._listeners =
+ element._listeners.reject(
+ function(obj) {
+ return obj.event == event
+ && obj.handler == handler
+ && obj.useCapture == useCapture;
+ }
+ );
+ }
+
+ Event.stopObserving(element, event, handler, useCapture);
+
+ },
+
+ removeListeners : function(element) {
+ if (element._listeners) {
+ var l = element._listeners.length;
+ for(var i = 0; i < l; i++) {
+ var listener = element._listeners[i];
+ Event.stopObserving(
+ element,
+ listener.event,
+ listener.handler,
+ listener.useCapture);
+ }
+
+ element._listeners = null;
+ }
+ }
}
},
-
+
AJAX : {
updateRows: function(options,request,grid,clientid, callbacks){
var theDoc = document;
@@ -84,19 +217,20 @@
if(rowindex >= rowCount){
rowindex -= rowCount;
}
- var id = baseid + ":f:" + rowindex;
- var row = Utils.DOM.replaceNode(id, request);
- id = baseid + ":n:" + rowindex;
- row = Utils.DOM.replaceNode(id, request);
-
-
- [":f:", ":n:"].each(
+ //var id = baseid + ":f:" + rowindex;
+ //var row = Utils.DOM.replaceNode(id, request);
+ //id = baseid + ":n:" + rowindex;
+ //row = Utils.DOM.replaceNode(id, request);
+
+ //var suffixes =
+
+ [":f:", ":n:"].unbreakableEach(
function(suffix) {
var id = baseid + suffix + rowindex;
var row = Utils.DOM.replaceNode(id, request);
if (callbacks) {
- callbacks.each(
+ callbacks.unbreakableEach(
function(callback) {
callback.call(grid, {index : rowindex, row : row});
}
@@ -114,4 +248,10 @@
}
-}
\ No newline at end of file
+};
+
+Array.prototype.unbreakableEach = function(f) {
+ for (var i = 0; i < this.length; i++) {
+ f(this[i], i);
+ }
+};
\ No newline at end of file
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-11 17:17:50 UTC (rev 1124)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-11 17:20:51 UTC (rev 1125)
@@ -254,7 +254,7 @@
},
addListener: function(element, rowIndex) {
- Event.observe(element, "click", this.processClick.bindAsEventListener(this, rowIndex));
+ Utils.DOM.Event.observe(element, "click", this.processClick.bindAsEventListener(this, rowIndex));
},
/* getGridSelection: function() {
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js 2007-06-11 17:17:50 UTC (rev 1124)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js 2007-06-11 17:20:51 UTC (rev 1125)
@@ -10,7 +10,7 @@
packages: [],
load: function(showLog) {
// Check for Prototype JavaScript framework
- /*
+
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
@@ -28,11 +28,11 @@
}).each( function(s) {
LibraryPath = s.src.replace(/ClientUILib\.js(\?.*)?$/,'');
});
- */
- /*if(showLog) {
+
+ if(showLog) {
ClientUILogger.create("ClientUILogger");
this.startTime = (new Date()).getTime();
- }*/
+ }
this.initBrowser();
},
@@ -82,21 +82,8 @@
ClientUILib.log(ClientUILogger.INFO, "ClientUILib::declarePackage '" + libName + "'");
},
log: function(level, infoText) {
- //if(ClientUILogger.isCreated)
- //ClientUILogger.log(level, infoText);
- switch(level) {
- case ClientUILogger.INFO:
- LOG.info(infoText);
- break;
- case ClientUILogger.WARNING:
- LOG.warn(infoText);
- break;
- case ClientUILogger.ERROR:
- LOG.error(infoText);
- break;
- default:
- LOG.debug(infoText);
- }
+ if(ClientUILogger.isCreated)
+ ClientUILogger.log(level, infoText);
},
initBrowser: function() {
var ua = navigator.userAgent.toLowerCase();
17 years, 7 months
JBoss Rich Faces SVN: r1124 - in trunk/richfaces: common/src/main/java/org/richfaces/org and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-11 13:17:50 -0400 (Mon, 11 Jun 2007)
New Revision: 1124
Added:
trunk/richfaces/common/src/main/java/org/richfaces/org/
trunk/richfaces/common/src/main/java/org/richfaces/org/apache/
trunk/richfaces/common/src/main/java/org/richfaces/org/apache/commons/
trunk/richfaces/common/src/main/java/org/richfaces/org/apache/commons/lang/
trunk/richfaces/common/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java
Removed:
trunk/richfaces/drag-drop/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java
Log:
StringEscapeUtils.java moved to common
Added: trunk/richfaces/common/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java
===================================================================
--- trunk/richfaces/common/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java (rev 0)
+++ trunk/richfaces/common/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java 2007-06-11 17:17:50 UTC (rev 1124)
@@ -0,0 +1,219 @@
+/**
+ * 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
+ */
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.richfaces.org.apache.commons.lang;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+/**
+ * <p>Escapes and unescapes <code>String</code>s for
+ * Java, Java Script, HTML, XML, and SQL.</p>
+ *
+ * @author Apache Jakarta Turbine
+ * @author GenerationJavaCore library
+ * @author Purple Technology
+ * @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
+ * @author <a href="mailto:alex@purpletech.com">Alexander Day Chaffee</a>
+ * @author Antony Riley
+ * @author Helge Tesgaard
+ * @author <a href="sean(a)boohai.com">Sean Brown</a>
+ * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
+ * @author Phil Steitz
+ * @author Pete Gieser
+ * @since 2.0
+ * @version $Id: StringEscapeUtils.java,v 1.1 2007/02/09 19:37:06 nick_belaevski Exp $
+ */
+public class StringEscapeUtils {
+
+ /**
+ * <p>Escapes the characters in a <code>String</code> using JavaScript String rules.</p>
+ * <p>Escapes any values it finds into their JavaScript String form.
+ * Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.) </p>
+ *
+ * <p>So a tab becomes the characters <code>'\\'</code> and
+ * <code>'t'</code>.</p>
+ *
+ * <p>The only difference between Java strings and JavaScript strings
+ * is that in JavaScript, a single quote must be escaped.</p>
+ *
+ * <p>Example:
+ * <pre>
+ * input string: He didn't say, "Stop!"
+ * output string: He didn\'t say, \"Stop!\"
+ * </pre>
+ * </p>
+ *
+ * @param str String to escape values in, may be null
+ * @return String with escaped values, <code>null</code> if null string input
+ */
+ public static String escapeJavaScript(String str) {
+ return escapeJavaStyleString(str, true);
+ }
+
+ /**
+ * <p>Escapes the characters in a <code>String</code> using JavaScript String rules
+ * to a <code>Writer</code>.</p>
+ *
+ * <p>A <code>null</code> string input has no effect.</p>
+ *
+ * @see #escapeJavaScript(java.lang.String)
+ * @param out Writer to write escaped string into
+ * @param str String to escape values in, may be null
+ * @throws IllegalArgumentException if the Writer is <code>null</code>
+ * @throws IOException if error occurs on underlying Writer
+ **/
+ public static void escapeJavaScript(Writer out, String str) throws IOException {
+ escapeJavaStyleString(out, str, true);
+ }
+
+ /**
+ * <p>Worker method for the {@link #escapeJavaScript(String)} method.</p>
+ *
+ * @param str String to escape values in, may be null
+ * @param escapeSingleQuotes escapes single quotes if <code>true</code>
+ * @return the escaped string
+ */
+ private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes) {
+ if (str == null) {
+ return null;
+ }
+ try {
+ StringWriter writer = new StringWriter(str.length() * 2);
+ escapeJavaStyleString(writer, str, escapeSingleQuotes);
+ return writer.toString();
+ } catch (IOException ioe) {
+ // this should never ever happen while writing to a StringWriter
+ ioe.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * <p>Worker method for the {@link #escapeJavaScript(String)} method.</p>
+ *
+ * @param out write to receieve the escaped string
+ * @param str String to escape values in, may be null
+ * @param escapeSingleQuote escapes single quotes if <code>true</code>
+ * @throws IOException if an IOException occurs
+ */
+ private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {
+ if (out == null) {
+ throw new IllegalArgumentException("The Writer must not be null");
+ }
+ if (str == null) {
+ return;
+ }
+ int sz;
+ sz = str.length();
+ for (int i = 0; i < sz; i++) {
+ char ch = str.charAt(i);
+
+ // handle unicode
+ if (ch > 0xfff) {
+ out.write("\\u" + hex(ch));
+ } else if (ch > 0xff) {
+ out.write("\\u0" + hex(ch));
+ } else if (ch > 0x7f) {
+ out.write("\\u00" + hex(ch));
+ } else if (ch < 32) {
+ switch (ch) {
+ case '\b':
+ out.write('\\');
+ out.write('b');
+ break;
+ case '\n':
+ out.write('\\');
+ out.write('n');
+ break;
+ case '\t':
+ out.write('\\');
+ out.write('t');
+ break;
+ case '\f':
+ out.write('\\');
+ out.write('f');
+ break;
+ case '\r':
+ out.write('\\');
+ out.write('r');
+ break;
+ default :
+ if (ch > 0xf) {
+ out.write("\\u00" + hex(ch));
+ } else {
+ out.write("\\u000" + hex(ch));
+ }
+ break;
+ }
+ } else {
+ switch (ch) {
+ case '\'':
+ if (escapeSingleQuote) {
+ out.write('\\');
+ }
+ out.write('\'');
+ break;
+ case '"':
+ out.write('\\');
+ out.write('"');
+ break;
+ case '\\':
+ out.write('\\');
+ out.write('\\');
+ break;
+ default :
+ out.write(ch);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>Returns an upper case hexadecimal <code>String</code> for the given
+ * character.</p>
+ *
+ * @param ch The character to convert.
+ * @return An upper case hexadecimal <code>String</code>
+ */
+ private static String hex(char ch) {
+ return Integer.toHexString(ch).toUpperCase();
+ }
+
+}
Deleted: trunk/richfaces/drag-drop/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java
===================================================================
--- trunk/richfaces/drag-drop/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java 2007-06-11 16:35:39 UTC (rev 1123)
+++ trunk/richfaces/drag-drop/src/main/java/org/richfaces/org/apache/commons/lang/StringEscapeUtils.java 2007-06-11 17:17:50 UTC (rev 1124)
@@ -1,219 +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
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.richfaces.org.apache.commons.lang;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
-/**
- * <p>Escapes and unescapes <code>String</code>s for
- * Java, Java Script, HTML, XML, and SQL.</p>
- *
- * @author Apache Jakarta Turbine
- * @author GenerationJavaCore library
- * @author Purple Technology
- * @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
- * @author <a href="mailto:alex@purpletech.com">Alexander Day Chaffee</a>
- * @author Antony Riley
- * @author Helge Tesgaard
- * @author <a href="sean(a)boohai.com">Sean Brown</a>
- * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
- * @author Phil Steitz
- * @author Pete Gieser
- * @since 2.0
- * @version $Id: StringEscapeUtils.java,v 1.1 2007/02/09 19:37:06 nick_belaevski Exp $
- */
-public class StringEscapeUtils {
-
- /**
- * <p>Escapes the characters in a <code>String</code> using JavaScript String rules.</p>
- * <p>Escapes any values it finds into their JavaScript String form.
- * Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.) </p>
- *
- * <p>So a tab becomes the characters <code>'\\'</code> and
- * <code>'t'</code>.</p>
- *
- * <p>The only difference between Java strings and JavaScript strings
- * is that in JavaScript, a single quote must be escaped.</p>
- *
- * <p>Example:
- * <pre>
- * input string: He didn't say, "Stop!"
- * output string: He didn\'t say, \"Stop!\"
- * </pre>
- * </p>
- *
- * @param str String to escape values in, may be null
- * @return String with escaped values, <code>null</code> if null string input
- */
- public static String escapeJavaScript(String str) {
- return escapeJavaStyleString(str, true);
- }
-
- /**
- * <p>Escapes the characters in a <code>String</code> using JavaScript String rules
- * to a <code>Writer</code>.</p>
- *
- * <p>A <code>null</code> string input has no effect.</p>
- *
- * @see #escapeJavaScript(java.lang.String)
- * @param out Writer to write escaped string into
- * @param str String to escape values in, may be null
- * @throws IllegalArgumentException if the Writer is <code>null</code>
- * @throws IOException if error occurs on underlying Writer
- **/
- public static void escapeJavaScript(Writer out, String str) throws IOException {
- escapeJavaStyleString(out, str, true);
- }
-
- /**
- * <p>Worker method for the {@link #escapeJavaScript(String)} method.</p>
- *
- * @param str String to escape values in, may be null
- * @param escapeSingleQuotes escapes single quotes if <code>true</code>
- * @return the escaped string
- */
- private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes) {
- if (str == null) {
- return null;
- }
- try {
- StringWriter writer = new StringWriter(str.length() * 2);
- escapeJavaStyleString(writer, str, escapeSingleQuotes);
- return writer.toString();
- } catch (IOException ioe) {
- // this should never ever happen while writing to a StringWriter
- ioe.printStackTrace();
- return null;
- }
- }
-
- /**
- * <p>Worker method for the {@link #escapeJavaScript(String)} method.</p>
- *
- * @param out write to receieve the escaped string
- * @param str String to escape values in, may be null
- * @param escapeSingleQuote escapes single quotes if <code>true</code>
- * @throws IOException if an IOException occurs
- */
- private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {
- if (out == null) {
- throw new IllegalArgumentException("The Writer must not be null");
- }
- if (str == null) {
- return;
- }
- int sz;
- sz = str.length();
- for (int i = 0; i < sz; i++) {
- char ch = str.charAt(i);
-
- // handle unicode
- if (ch > 0xfff) {
- out.write("\\u" + hex(ch));
- } else if (ch > 0xff) {
- out.write("\\u0" + hex(ch));
- } else if (ch > 0x7f) {
- out.write("\\u00" + hex(ch));
- } else if (ch < 32) {
- switch (ch) {
- case '\b':
- out.write('\\');
- out.write('b');
- break;
- case '\n':
- out.write('\\');
- out.write('n');
- break;
- case '\t':
- out.write('\\');
- out.write('t');
- break;
- case '\f':
- out.write('\\');
- out.write('f');
- break;
- case '\r':
- out.write('\\');
- out.write('r');
- break;
- default :
- if (ch > 0xf) {
- out.write("\\u00" + hex(ch));
- } else {
- out.write("\\u000" + hex(ch));
- }
- break;
- }
- } else {
- switch (ch) {
- case '\'':
- if (escapeSingleQuote) {
- out.write('\\');
- }
- out.write('\'');
- break;
- case '"':
- out.write('\\');
- out.write('"');
- break;
- case '\\':
- out.write('\\');
- out.write('\\');
- break;
- default :
- out.write(ch);
- break;
- }
- }
- }
- }
-
- /**
- * <p>Returns an upper case hexadecimal <code>String</code> for the given
- * character.</p>
- *
- * @param ch The character to convert.
- * @return An upper case hexadecimal <code>String</code>
- */
- private static String hex(char ch) {
- return Integer.toHexString(ch).toUpperCase();
- }
-
-}
17 years, 7 months
JBoss Rich Faces SVN: r1123 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-06-11 12:35:39 -0400 (Mon, 11 Jun 2007)
New Revision: 1123
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
Log:
small fix
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-11 15:43:54 UTC (rev 1122)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-11 16:35:39 UTC (rev 1123)
@@ -365,8 +365,8 @@
this.shiftRow = this.activeRow;
}
this.startRow = this.shiftRow;
- if (((this.startRow <= rowIndex) && (this.firstIndex < this.startRow || rowIndex < this.firstIndex))
- || (this.startRow > rowIndex && this.firstIndex >= this.startRow && rowIndex >= this.firstIndex)) {
+ if (((this.startRow <= rowIndex) && (this.firstIndex <= this.startRow || rowIndex < this.firstIndex))
+ || (this.startRow > rowIndex && this.firstIndex > this.startRow && rowIndex >= this.firstIndex)) {
this.endRow = rowIndex;
} else {
this.endRow = this.startRow;
17 years, 7 months
JBoss Rich Faces SVN: r1122 - in trunk/sandbox-samples/panelmenu-sample/src/main: webapp/WEB-INF and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-06-11 11:43:54 -0400 (Mon, 11 Jun 2007)
New Revision: 1122
Modified:
trunk/sandbox-samples/panelmenu-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml
trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp
Log:
Modified: trunk/sandbox-samples/panelmenu-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox-samples/panelmenu-sample/src/main/java/org/richfaces/Bean.java 2007-06-11 15:32:00 UTC (rev 1121)
+++ trunk/sandbox-samples/panelmenu-sample/src/main/java/org/richfaces/Bean.java 2007-06-11 15:43:54 UTC (rev 1122)
@@ -26,4 +26,34 @@
*/
public class Bean {
+ public String executeServer(){
+ System.out.println("executed server");
+ return null;
+ }
+
+ public String executeAjax(){
+ System.out.println("executed ajax");
+ return null;
+ }
+
+
+
+ public String executeItem1(){
+ System.out.println("item1 executed ");
+ return null;
+
+ }
+
+ public String executeItem2(){
+ System.out.println("item2 executed ");
+ return null;
+
+ }
+
+ public String executeItem3(){
+ System.out.println("item3 executed ");
+ return null;
+
+ }
+
}
\ No newline at end of file
Modified: trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/faces-config.xml 2007-06-11 15:32:00 UTC (rev 1121)
+++ trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/faces-config.xml 2007-06-11 15:43:54 UTC (rev 1122)
@@ -12,6 +12,7 @@
<managed-bean-class>org.richfaces.Bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+
</faces-config>
Modified: trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml 2007-06-11 15:32:00 UTC (rev 1121)
+++ trunk/sandbox-samples/panelmenu-sample/src/main/webapp/WEB-INF/web.xml 2007-06-11 15:43:54 UTC (rev 1122)
@@ -22,6 +22,11 @@
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
+ <init-param>
+ <param-name>forceparser</param-name>
+ <param-value>false</param-value>
+ </init-param>
+
</filter>
<filter-mapping>
<filter-name>ajax4jsf</filter-name>
Modified: trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp 2007-06-11 15:32:00 UTC (rev 1121)
+++ trunk/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp 2007-06-11 15:43:54 UTC (rev 1122)
@@ -1,33 +1,42 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.ajax4jsf.org/panelmenu" prefix="pm" %>
+<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<html>
- <head>
- <title></title>
- </head>
+
<body>
<f:view>
- <pm:panelMenu iconItemTopPosition="left" iconItemPosition="left">
- <pm:panelMenuGroup label="Group 1" iconExpanded="disc" iconCollapsed="disc">
+ <pm:panelMenu iconItemTopPosition="right" iconItemPosition="right" iconGroupPosition="left" iconGroupTopPosition="left" expandSingle="false" iconExpandedGroup="grid" iconCollapsedGroup="chevron" iconItem="disc" iconTopItem="triangle" iconDisabledItem="grid" iconDisabledGroup="disc" iconTopDisableGroup="triangleDown" iconExpandedTopGroup="chevron">
+ <pm:panelMenuGroup label="Group 1" iconExpanded="disc" iconCollapsed="chevron">
<pm:panelMenuItem value="Item 1" icon="chevronUp">
</pm:panelMenuItem>
- <pm:panelMenuItem value="Item 2" />
- <pm:panelMenuGroup label="Group 2" iconCollapsed="chevron" >
+ <pm:panelMenuItem value="Item "/>
+ <pm:panelMenuGroup label="Group 2" >
<pm:panelMenuItem icon="triangleDown">
- <h:outputText value="Item 3" />
+ <f:verbatim>Item 3</f:verbatim>
</pm:panelMenuItem>
+ <pm:panelMenuGroup label="Group 33" expanded="true">
+ <pm:panelMenuItem icon="triangleDown">
+ <f:verbatim>Item 3333</f:verbatim>
+ </pm:panelMenuItem>
+ </pm:panelMenuGroup>
</pm:panelMenuGroup>
</pm:panelMenuGroup>
- <pm:panelMenuGroup label="Group 3" iconExpanded="" iconCollapsed="">
- <pm:panelMenuItem value="Item 4">
+ <pm:panelMenuGroup label="Group 3">
+ <pm:panelMenuItem value="Item 4" >
</pm:panelMenuItem>
</pm:panelMenuGroup>
- <pm:panelMenuGroup label="Group 4" iconExpanded="triangleDown" iconCollapsed="triangle" expanded="true">
+ <pm:panelMenuGroup label="Group 4" disabled="true">
<pm:panelMenuItem value="Item 5" disabled="true"/>
- <pm:panelMenuItem value="Item 6"/>
+ <pm:panelMenuItem value="Item 66" mode="server" />
</pm:panelMenuGroup>
+ <pm:panelMenuItem value="Top item"/>
+ <pm:panelMenuItem value="Top item2" disabled="true"/>
</pm:panelMenu>
</f:view>
+
+
+
</body>
</html>
17 years, 7 months
JBoss Rich Faces SVN: r1121 - trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-06-11 11:32:00 -0400 (Mon, 11 Jun 2007)
New Revision: 1121
Modified:
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
Log:
Modified: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-06-11 15:31:11 UTC (rev 1120)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-06-11 15:32:00 UTC (rev 1121)
@@ -22,22 +22,16 @@
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 javax.faces.convert.ConverterException;
import javax.faces.event.ActionEvent;
-import javax.faces.event.ValueChangeEvent;
-
import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.component.panelmenu.UIPanelMenuGroup;
-import org.richfaces.component.panelmenu.UIPanelMenuItem;
-import org.richfaces.event.SwitchablePanelSwitchEvent;
public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
@@ -77,20 +71,21 @@
boolean isTopLevel = isTopLevel(component);
if (isTopLevel){
- align = panelMenu.getIconItemTopPosition();
+ align = panelMenu.getIconGroupTopPosition();
} else {
- align = panelMenu.getIconItemPosition();
+ align = panelMenu.getIconGroupPosition();
}
- if (align.equalsIgnoreCase(from)) {
- image(context, component, "");
- } else{
- image(context, component, "spacer");
+ 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, String data)throws IOException {
+ private void image(FacesContext context, UIComponent component )throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIPanelMenu panelMenu = findMenu(component);
@@ -102,32 +97,70 @@
boolean isOpened = isOpened(context,component);
- String source = "";
- String iconNode = "";
- Object iconCollapsed = panelMenuGroup.getIconCollapsed();
- Object iconExpanded = panelMenuGroup.getIconExpanded();
- String icon = (isOpened ? iconExpanded : iconCollapsed).toString();
- if ("".equals(icon)){
- source = getIconByType("custom", isTopLevel,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 (iconNode.equals("none")){
- return;
+ if(panelMenuGroup.isDisabled()){
+ defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
} else {
- source = getIconByType(data.equals("spacer") ? "custom" : icon, isTopLevel, context, component);
+ defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
}
}
+
+ String defaultIconNodeOpened = null;
+
+ if(isTopLevel){
+ defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
+ if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
+ } else {
+ defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
+ }
- int h = 16; //width(context);
- writer.startElement("img", component);
- writer.writeAttribute("src", source, 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");
+ 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) {
@@ -183,9 +216,6 @@
}
public boolean isOpened(FacesContext context, UIComponent component)throws IOException {
- //String clientId = component.getClientId(context);
- ///Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
-
UIPanelMenuGroup group = (UIPanelMenuGroup)component;
Boolean value = (Boolean)group.getValue();
Modified: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-06-11 15:31:11 UTC (rev 1120)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-06-11 15:32:00 UTC (rev 1121)
@@ -27,12 +27,9 @@
import javax.faces.context.ResponseWriter;
import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.panelmenu.UIPanelMenu;
-import org.richfaces.component.panelmenu.UIPanelMenuGroup;
import org.richfaces.component.panelmenu.UIPanelMenuItem;
-import org.richfaces.event.SwitchablePanelSwitchEvent;
public class PanelMenuItemRenderer extends PanelMenuRendererBase {
protected Class getComponentClass() {
@@ -79,57 +76,63 @@
align = panelMenu.getIconItemPosition();
}
- if (component.getChildCount()==0){
- if (align.equalsIgnoreCase(from)){
- image(context,component,"");
- } else{
- image(context,component,"spacer");
- }
+ if (align.equalsIgnoreCase(from)){
+ image(context,component);
} else {
- image(context,component,"spacer");
+ 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, String align)
+ private void image(FacesContext context, UIComponent component)
throws IOException{
UIPanelMenu panelMenu = findMenu(component);
ResponseWriter writer = context.getResponseWriter();
- String iconItemTopLevel = panelMenu.getIconTopItem();
- String iconItem = panelMenu.getIconItem();
boolean isTopLevel = isTopLevel(component);
- String source = "";
- String iconType = "";
- Object customIcon = ((UIPanelMenuItem)component).getIcon();
+ String source = null;
+ String iconType = null;
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
- if ("".equals(customIcon)){
- if (isTopLevel){
- source = getIconByType(align.equals("spacer") ? "custom" : iconItemTopLevel, isTopLevel, context, component);
+ String defaultItemIcon = null;
+ String customItemIcon = null;
+
+ if(isTopLevel){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconTopDisabledItem();
} else {
- source = getIconByType(align.equals("spacer") ? "custom" : iconItem, isTopLevel, context, component);
+ defaultItemIcon = panelMenu.getIconTopItem();
}
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
+ }
} else {
- if ((!isTopLevel&&iconItem.equals("none"))||(isTopLevel&&iconItemTopLevel.equals("none"))){
- iconType = "none";
- } else {
- source = getIconByType(align.equals("spacer") ? "custom" : customIcon.toString(),isTopLevel,context,component);
+ //isTopLevel == false
+ if(defaultItemIcon == null || defaultItemIcon.equals("")){
+ if(item.isDisabled()){
+ defaultItemIcon = panelMenu.getIconDisabledItem();
+ } else {
+ defaultItemIcon = panelMenu.getIconItem();
+ }
}
}
-
- if (!iconType.equals("none")){
- int h = 16; //width(context);
- writer.startElement("img", component);
- writer.writeAttribute("src", source, 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");
- }
+
+ 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;
Modified: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-11 15:31:11 UTC (rev 1120)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-11 15:32:00 UTC (rev 1121)
@@ -1,398 +1,426 @@
-/**
- * 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.application.ViewHandler;
-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.resource.InternetResourceBuilder;
-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;
-import org.richfaces.renderkit.iconImages.PanelMenuIconSpacer;
-
-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");
- String iconPosition = ((UIPanelMenu)component).getIconItemPosition();
- String iconPositionTopLevel = ((UIPanelMenu)component).getIconItemTopPosition();
-
- 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);
-
- String iconPos = child.getParent() instanceof UIPanelMenu ? iconPositionTopLevel.toLowerCase() : iconPosition.toLowerCase() ;
-
- 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 {
-// ViewHandler viewHandler = context.getApplication().getViewHandler();
-// String viewId = context.getViewRoot().getViewId();
-// String actionUrl = context.getExternalContext().encodeActionURL(viewHandler.getActionURL(context, viewId));
-// buffer.append(",'"+actionUrl+"'");
- 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;
- }
-
- final String PANEL_MENU_SPACER_ICON = InternetResourceBuilder.getInstance().createResource(null,PanelMenuIconSpacer.class.getName()).getUri(context, null);;
- boolean isTopLevel = component.getParent() instanceof UIPanelMenu;
-
- String iconItem = isTopLevel ? panelMenu.getIconTopItem() : panelMenu.getIconItem();
- String iconNodeClosed = isTopLevel ? panelMenu.getIconCollapsedTopGroup() : panelMenu.getIconCollapsedGroup();
- String iconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
-
- String sourceIconItem = getIconByType(iconItem, isTopLevel,context, component);
- String sourceIconNodeClosed = getIconByType(iconNodeClosed, isTopLevel,context, component);
- String sourceIconNodeOpened = getIconByType(iconNodeOpened, isTopLevel,context, component);
-
- String iconExpanded = "";
- String iconCollapsed = "";
- String iconExpandedSource = "";
- String iconCollapsedSource = "";
- String customIcon = "";
- String customIconSource = "";
-
- if (component instanceof UIPanelMenuGroup){
-
- iconExpanded = ((UIPanelMenuGroup)component).getIconExpanded();
- iconCollapsed = ((UIPanelMenuGroup)component).getIconCollapsed();
- iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
- iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
-
- } else if (component instanceof UIPanelMenuItem){
-
- customIcon = component.getAttributes().get("icon").toString();
- customIconSource = getIconByType(customIcon,isTopLevel,context,component);
-
- }
-
- if (component instanceof UIPanelMenuGroup){
- if (null != iconCollapsed && !"".equals(iconCollapsed))
- iconNodeClosed = iconCollapsed;
- if (null != iconExpanded && !"".equals(iconExpanded))
- iconNodeOpened = iconExpanded;
- if (!"".equals(iconNodeClosed)&&!"".equals(iconNodeOpened)){
- if (!iconNodeClosed.equals("custom")&&!iconNodeOpened.equals("custom")){
- if("".equals(iconExpanded)&&"".equals(iconCollapsed)){
- buffer.append(","+'"'+ ("".equals(sourceIconNodeOpened)?iconExpandedSource:sourceIconNodeOpened) + '"').append(","+
- '"'+("".equals(sourceIconNodeClosed)?iconCollapsedSource:sourceIconNodeClosed)+'"'+";");
- } else if("".equals(iconExpanded)){
- buffer.append(","+'"'+iconCollapsedSource+'"')
- .append(","+'"'+iconCollapsedSource+'"');
- } else if ("".equals(iconCollapsed)) {
- buffer.append(","+'"'+iconExpandedSource+'"')
- .append(","+'"'+iconExpandedSource+'"');
- } else {
- buffer.append(","+'"'+iconExpandedSource+'"')
- .append(","+'"'+iconCollapsedSource+'"');
- }
- } else if (iconNodeClosed.equals("custom")){
- buffer.append(",\"" + ("".equals(iconExpanded)? sourceIconNodeOpened : iconExpandedSource) + '"').
- append(",\"" + ("".equals(iconCollapsed)? PANEL_MENU_SPACER_ICON : iconCollapsedSource)+"\";");
- } else if (iconNodeOpened.equals("custom")){
- buffer.append(",\"" + ("".equals(iconExpanded)? PANEL_MENU_SPACER_ICON : iconExpandedSource) + '"').
- append(",\"" + ("".equals(iconCollapsed)? sourceIconNodeClosed : iconCollapsedSource)+"\";");
- } else{
- buffer.append(",\"" + ("".equals(iconExpanded)? PANEL_MENU_SPACER_ICON : iconExpandedSource) + '"')
- .append(",\"" + ("".equals(iconCollapsed)? PANEL_MENU_SPACER_ICON : iconCollapsedSource)+"\";");
- }
- } else {
- String iconCollapsedScript = ("".equals(iconNodeClosed)) ? "null" : "\"" + iconCollapsedSource + "\"";
- String iconExpandedScript = ("".equals(iconNodeOpened)) ? "null" : "\"" + iconExpandedSource + "\"";
- buffer.append("," + iconExpandedScript + "," + iconCollapsedScript);
- }
- buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
- } else {
- if (!"".equals(iconItem)){
- if (!iconItem.equals("custom")){
- if(component.getAttributes().get("icon").equals("")){
- buffer.append(","+'"'+sourceIconItem+'"')
- .append(","+'"'+sourceIconItem+'"'+" ");
- } else {
- buffer.append(","+'"'+customIconSource+'"')
- .append(","+'"'+customIconSource+'"'+" ");
- }
- } else {
- if(component.getAttributes().get("icon").equals("")){
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"')
- .append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+" ");
- } else {
- buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+" ");
- }
- }
- } else {
- buffer.append(",\"\" ");
- }
- buffer.append(",\"\" ");
- }
- }
-
- 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("\"");
- }
-
-}
+/**
+ * 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);
+
+ 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("\"");
+ }
+
+}
Modified: trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
--- trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-11 15:31:11 UTC (rev 1120)
+++ trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-11 15:32:00 UTC (rev 1121)
@@ -51,6 +51,9 @@
*
*/
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);
@@ -110,6 +113,8 @@
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")) {
@@ -260,5 +265,29 @@
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");
+ }
+
+ }
}
17 years, 7 months
JBoss Rich Faces SVN: r1120 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-06-11 11:31:11 -0400 (Mon, 11 Jun 2007)
New Revision: 1120
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
Log:
Updated a client part of selection.
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-11 14:38:30 UTC (rev 1119)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-11 15:31:11 UTC (rev 1120)
@@ -187,6 +187,8 @@
Object.extend(ClientUI.controls.grid.SelectionManager.prototype, {
initialize: function(grid) {
+ this.selectionFlag;
+ this.firstIndex;
var gridElement = grid.getElement();
this.prefix = gridElement.id;
this.selection = new ClientUI.controls.grid.Selection();
@@ -194,17 +196,9 @@
this.inputElement = grid.options.selectionInput;
this.restoreState();
+ this.setListeners();
this.eventKeyPress = this.processKeyDown.bindAsEventListener(this);
Event.observe(document, "keypress", this.eventKeyPress);
- var frows = $(this.prefix + ":f").rows;
- var nrows = $(this.prefix + ":n").rows;
- this.rowCount = frows.length;
- var rowIndex;
- for(var i = 0; i < this.rowCount; i++) {
- rowIndex = Number(frows[i].id.split(this.prefix)[1].split(":")[2]);
- this.addListener(frows[i], rowIndex);
- this.addListener(nrows[i], rowIndex);
- }
if (document.selection) {
Event.observe(gridElement, "click", this.resetSelection.bindAsEventListener(this));
}
@@ -229,7 +223,9 @@
},
restoreState: function() {
+ this.selectionFlag = null;
this.selection.initRanges($(this.inputElement).value);
+ this.firstIndex = Number($(this.prefix + ":f").rows[0].id.split(this.prefix)[1].split(":")[2]);;
var i = 0;
var j;
while(i < this.selection.ranges.length) {
@@ -245,6 +241,18 @@
}
},
+ setListeners: function() {
+ var frows = $(this.prefix + ":f").rows;
+ var nrows = $(this.prefix + ":n").rows;
+ this.rowCount = frows.length;
+ var rowIndex;
+ for(var i = 0; i < this.rowCount; i++) {
+ rowIndex = Number(frows[i].id.split(this.prefix)[1].split(":")[2]);
+ this.addListener(frows[i], rowIndex);
+ this.addListener(nrows[i], rowIndex);
+ }
+ },
+
addListener: function(element, rowIndex) {
Event.observe(element, "click", this.processClick.bindAsEventListener(this, rowIndex));
},
@@ -279,13 +287,14 @@
var noDefault = false;
switch (event.keyCode || event.charCode) {
case Event.KEY_UP:
- if (this.inFocus && activeRow && activeRow > 0) {
+ if (this.inFocus && activeRow) {
if(activeRow) {
- rowIndex = this.rowCount - 1;
+ rowIndex = activeRow - 1;
} else {
- rowIndex = activeRow - 1;
+ rowIndex = this.rowCount - 1;
}
if (!event.ctrlKey && !event.shiftKey) {
+ this.selectionFlag = "x";
range = [rowIndex, rowIndex];
this.setSelection(range);
} else if (!event.ctrlKey && event.shiftKey) {
@@ -303,13 +312,14 @@
}
break;
case Event.KEY_DOWN:
- if (this.inFocus && activeRow) {
+ if (this.inFocus && activeRow != null) {
if(activeRow == this.rowCount - 1) {
rowIndex = 0;
} else {
rowIndex = activeRow + 1;
}
if (!event.ctrlKey && !event.shiftKey) {
+ this.selectionFlag = "x";
range = [rowIndex, rowIndex];
this.setSelection(range);
} else if (!event.ctrlKey && event.shiftKey) {
@@ -328,6 +338,7 @@
break;
case 65: case 97: // Ctrl-A
if (this.inFocus && event.ctrlKey) {
+ this.selectionFlag = "a";
range = [0, this.rowCount];
this.setSelection(range);
noDefault = true;
@@ -337,7 +348,7 @@
this.lostFocus();
}
if (noDefault) {
- $(this.prefix+":s").value = this.selection.inspectRanges();
+ $(this.inputElement).value = this.selection.inspectRanges() + this.selectionFlag;
if (event.preventBubble) event.preventBubble();
Event.stop(event);
}
@@ -349,11 +360,13 @@
}
var range;
if ( event.shiftKey && !event.ctrlKey && !event.altKey) {
+ this.selectionFlag = "x";
if(!this.shiftRow) {
this.shiftRow = this.activeRow;
}
this.startRow = this.shiftRow;
- if (this.startRow <= rowIndex) {
+ if (((this.startRow <= rowIndex) && (this.firstIndex < this.startRow || rowIndex < this.firstIndex))
+ || (this.startRow > rowIndex && this.firstIndex >= this.startRow && rowIndex >= this.firstIndex)) {
this.endRow = rowIndex;
} else {
this.endRow = this.startRow;
@@ -368,6 +381,7 @@
this.addRowToSelection(rowIndex);
}
} else if (!event.shiftKey && !event.ctrlKey && !event.altKey) {
+ this.selectionFlag = "x";
range = [rowIndex, rowIndex];
this.setSelection(range);
}
@@ -377,7 +391,7 @@
} else if (document.selection) {
document.selection.empty();
}
- $(this.prefix+":s").value = this.selection.inspectRanges();
+ $(this.inputElement).value = this.selection.inspectRanges()+ this.selectionFlag;
},
setShiftRow: function(event) {
@@ -391,15 +405,15 @@
},
setSelection: function(range) {
- var i = 0;
- for (; i < range[0]; i++) {
- this.removeRowFromSelection(i);
- }
- for (; i <= range[1]; i++) {
+ var i = range[0];
+ range[1] = (range[1] + 1) % this.rowCount;
+ while (i != range[1]) {
this.addRowToSelection(i);
+ i = (i + 1) % this.rowCount;
}
- for (; i < this.rowCount; i++) {
+ while (i != range[0]) {
this.removeRowFromSelection(i);
+ i = (i + 1) % this.rowCount;
}
},
@@ -427,7 +441,7 @@
setActiveRow: function(rowIndex) {
var fElement, nElement;
- if(this.activeRow) {
+ if(this.activeRow != null) {
fElement = $(this.prefix + ":f:" + this.activeRow);
nElement = $(this.prefix + ":n:" + this.activeRow);
fElement.style.color = "#000000";
17 years, 7 months
JBoss Rich Faces SVN: r1119 - trunk/docs/userguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-06-11 10:38:30 -0400 (Mon, 11 Jun 2007)
New Revision: 1119
Modified:
trunk/docs/userguide/en/src/main/docbook/modules/RFClinks.xml
Log:
link
Modified: trunk/docs/userguide/en/src/main/docbook/modules/RFClinks.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/modules/RFClinks.xml 2007-06-11 13:54:23 UTC (rev 1118)
+++ trunk/docs/userguide/en/src/main/docbook/modules/RFClinks.xml 2007-06-11 14:38:30 UTC (rev 1119)
@@ -33,7 +33,7 @@
<row>
<entry>Rich Faces Wiki</entry>
<entry>
- <para><ulink url="http://support.exadel.com/index.php/ExadelVCP">Rich Faces Wiki</ulink></para>
+ <para><ulink url="http://labs.jboss.com/wiki/RichFaces">Rich Faces Wiki</ulink></para>
</entry>
</row>
<row>
17 years, 7 months
JBoss Rich Faces SVN: r1118 - in trunk/richfaces/tabPanel/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-06-11 09:54:23 -0400 (Mon, 11 Jun 2007)
New Revision: 1118
Modified:
trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js
trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-49 fixed
Modified: trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml
===================================================================
--- trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml 2007-06-11 13:33:51 UTC (rev 1117)
+++ trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml 2007-06-11 13:54:23 UTC (rev 1118)
@@ -203,6 +203,22 @@
<name>active</name>
<classname>boolean</classname>
</property>
+ <property>
+ <name>ontableave</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Event must occurs on the tab which has been left
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>ontabenter</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Event must occurs on the tab which has been entered
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
</component>
<renderer generate="true">
<template>tabHeader.jspx</template>
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-06-11 13:33:51 UTC (rev 1117)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-06-11 13:54:23 UTC (rev 1118)
@@ -69,10 +69,11 @@
if (!disabled) {
if (clientSide) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, "RichFaces.switchTab('" + pane.getClientId(context) + "','" + clientId + "','" + getUtils().formatValue(context, pane, tab.getName()) + "');", "switchScript");
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, "if (RichFaces.onTabChange('"+pane.getClientId(context)+"','"+clientId+"')) RichFaces.switchTab('" + pane.getClientId(context) + "','" + clientId + "','" + getUtils().formatValue(context, pane, tab.getName()) + "');", "switchScript");
} else {
String activeCheck = "if (RichFaces.isTabActive('" + clientId + LABEL_SUFFIX + "')) return false;";
-
+ String eventCheck = " if (!RichFaces.onTabChange('"+pane.getClientId(context)+"','"+clientId+"')) return false;";
+
if (ajax) {
JSFunction function = AjaxRendererUtils.buildAjaxFunction(tab,
context);
@@ -84,14 +85,14 @@
function.appendScript(buffer);
buffer.append("; return false; this.onclick = null;");
String script = buffer.toString();
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script, null);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + eventCheck + script, null);
} else {
StringBuffer script = new StringBuffer("var _formName = A4J.findForm(this).id; var _paramName = '" + clientId + "_server_submit'; var _params = new Object(); _params[_paramName] = _paramName; _JSFFormSubmit('");
script.append(clientId);
script.append("', _formName, null, _params);");
script.append("this.onclick = null; _clearJSFFormParameters(_formName, null, [_paramName]);");
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script.toString()
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + eventCheck + script.toString()
/* "RichFaces.submitTab(this,'"+clientId + "_inp" +"','"+pane.getClientId(context)+"');"*/, null);
}
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-06-11 13:33:51 UTC (rev 1117)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-06-11 13:54:23 UTC (rev 1118)
@@ -109,7 +109,10 @@
private final JSReference JSR_CELL_ACTIVE_CLASS = new JSReference("cellActiveClass");
private final JSReference JSR_CELL_INACTIVE_CLASS = new JSReference("cellInactiveClass");
-
+ private final JSReference JSR_NAME = new JSReference("name");
+ private final JSReference JSR_ONTABLEAVE = new JSReference("ontableave");
+ private final JSReference JSR_ONTABENTER = new JSReference("ontabenter");
+
public Object collectTabInfo(FacesContext context, UITab tab) {
Map info = new HashMap();
info.put(JSR_ID, tab.getClientId(context));
@@ -119,6 +122,10 @@
info.put(JSR_CELL_ACTIVE_CLASS, ACTIVE_CELL_CLASSES);
info.put(JSR_CELL_INACTIVE_CLASS, INACTIVE_CELL_CLASSES);
+ info.put(JSR_NAME, tab.getName());
+ info.put(JSR_ONTABLEAVE, tab.getAttributes().get("ontableave"));
+ info.put(JSR_ONTABENTER, tab.getAttributes().get("ontabenter"));
+
return info;
}
};
Modified: trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js
===================================================================
--- trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js 2007-06-11 13:33:51 UTC (rev 1117)
+++ trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js 2007-06-11 13:54:23 UTC (rev 1118)
@@ -135,3 +135,31 @@
RichFaces._shouldHoverTab = function(tab) {
return (tab.className.indexOf('dr-tbpnl-tb-act') < 0);
}
+
+RichFaces.onTabChange = function(pane,tab) {
+ var labelSuffix = "_lbl";
+ var tabs = RichFaces.panelTabs[pane];
+ var lastActive, newActive;
+ if (tabs) {
+ for( var i=0; i<tabs.length; i++){
+ if (lastActive && newActive) break;
+ var tabId = tabs[i].id;
+ if (tabId == tab)
+ newActive = tabs[i];
+ if (RichFaces.isTabActive(tabId +labelSuffix))
+ lastActive = tabs[i];
+ }
+ }
+ if (lastActive && newActive) {
+ if (lastActive.ontableave && lastActive.ontableave != "") {
+ var func = new Function("leftTabName","enteredTabName",lastActive.ontableave);
+ if (!func(lastActive.name,newActive.name)) return false;
+ }
+ if (newActive.ontabenter && newActive.ontabenter != "") {
+ var func = new Function("leftTabName","enteredTabName",newActive.ontabenter);
+ return func(lastActive.name,newActive.name);
+ }
+ }
+ return true;
+}
+
Modified: trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx
===================================================================
--- trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx 2007-06-11 13:33:51 UTC (rev 1117)
+++ trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx 2007-06-11 13:54:23 UTC (rev 1118)
@@ -45,15 +45,15 @@
<f:call name="encodeTabs" />
</tr>
</table>
- <c:if test="#{clientSide}">
- <div style="display: none;">
+ <div style="display: none;">
+ <c:if test="#{clientSide}">
<input type="hidden"
id="#{clientId}_input"
name="#{clientId}"
value="#{this:getValueAsString(context, component)}" />
- <f:call name="encodeTabsScript" />
- </div>
- </c:if>
+ </c:if>
+ <f:call name="encodeTabsScript" />
+ </div>
<f:call name="utils.encodeEndFormIfNessesary" />
</td>
</tr>
17 years, 7 months