JBoss Rich Faces SVN: r16097 - branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-12-08 09:42:15 -0500 (Tue, 08 Dec 2009)
New Revision: 16097
Modified:
branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
RF-8169 IE6 Script error in the contextMenu
Modified: branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2009-12-08 13:19:19 UTC (rev 16096)
+++ branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2009-12-08 14:42:15 UTC (rev 16097)
@@ -1347,29 +1347,31 @@
this.id = id;
this.menu = menu;
this.mouseOver = false;
-
- this.getElement().oncontextmenu = this.getIcon().oncontextmenu
- = this.getLabel().oncontextmenu = function(event) {Event.stop(event); return false;};
- var binding;
- binding = new RichFaces.Menu.Layer.Binding (
- id,
- "mouseover",
+ var oncontextmenu = function(event) {
+ if (event) {
+ Event.stop(event);
+ }
+
+ return false;
+ };
+
+ this.getElement().oncontextmenu = oncontextmenu;
+ this.getIcon().oncontextmenu = oncontextmenu;
+ this.getLabel().oncontextmenu = oncontextmenu;
+
+ var binding = new RichFaces.Menu.Layer.Binding(id, "mouseover",
this.onmouseover.bindAsEventListener(this));
menu.bindings.push(binding);
binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (
- id,
- "mouseout",
+ binding = new RichFaces.Menu.Layer.Binding(id, "mouseout",
this.onmouseout.bindAsEventListener(this));
menu.bindings.push(binding);
binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (
- id,
- "click",
+ binding = new RichFaces.Menu.Layer.Binding(id, "click",
this.onclick.bindAsEventListener(this));
menu.bindings.push(binding);
binding.refresh();
14 years, 6 months
JBoss Rich Faces SVN: r16096 - root/framework/trunk/impl/src/main/resources/META-INF/resources.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2009-12-08 08:19:19 -0500 (Tue, 08 Dec 2009)
New Revision: 16096
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
Log:
richfaces.queue code fixes & improvements
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2009-12-08 12:12:29 UTC (rev 16095)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2009-12-08 13:19:19 UTC (rev 16096)
@@ -13,9 +13,9 @@
richfaces.queue = function(opts){
- //TODO: naming - class should be called QueueEntry, and first argument is "source", not query
- var queueEntry = function(query, event, options) {
- this.query = query;
+ var QueueEntry = function(queue, source, event, options) {
+ this.queue = queue;
+ this.source = source;
this.options = options || {};
this.event = event;
@@ -24,77 +24,86 @@
this.eventsCount = 1;
};
- //TODO: fix bad indentation of code
- jQuery.extend(queueEntry.prototype, {
-
- isIgnoreDupResponses: function() {
- return this.options.ignoreDupResponses;
- },
-
- getSimilarityGroupingId: function() {
- return this.similarityGroupingId;
- },
-
- setSimilarityGroupingId: function(id) {
- this.similarityGroupingId = id;
- },
-
- ondrop: function() {
- var callback = this.options.onqueuerequestdrop;
- if (callback) {
- callback.call(this.queue, this.query, this.options, this.event);
- }
- },
-
- onRequestDelayPassed: function() {
- this.readyToSubmit = true;
- //TODO: should be this.queue.submitFirst
- submitFirst();
- },
-
- startTimer: function() {
- var delay = this.options.requestDelay || queueRequestDelay || 0;
+ jQuery.extend(QueueEntry.prototype, {
- log.debug("Queue will wait " + (delay || 0) + "ms before submit");
-
- if (delay) {
- var _this = this;
- this.timer = setTimeout(function() {
- try {
- _this.onRequestDelayPassed();
- } finally {
- _this.timer = undefined;
- _this = undefined;
- }
- }, delay);
- } else {
- this.onRequestDelayPassed();
- }
- },
-
- stopTimer: function() {
- if (this.timer) {
- clearTimeout(this.timer);
- this.timer = undefined;
- }
- },
-
- clearEntry: function() { //???
- this.stopTimer();
- if (this.request) {
- this.request.shouldNotifyQueue = false;
- this.request = undefined;
- }
- },
-
- getEventsCount: function() {
- return this.eventsCount;
- },
-
- setEventsCount: function(newCount) {
- this.eventsCount = newCount;
- },
-
+ isIgnoreDupResponses: function() {
+ return this.options.ignoreDupResponses;
+ },
+
+ getSimilarityGroupingId: function() {
+ return this.similarityGroupingId;
+ },
+
+ setSimilarityGroupingId: function(id) {
+ this.similarityGroupingId = id;
+ },
+
+ resetSimilarityGroupingId: function() {
+ this.similarityGroupingId = undefined;
+ },
+
+ setReadyToSubmit: function(isReady) {
+ this.readyToSubmit = isReady;
+ },
+
+ getReadyToSubmit: function() {
+ return this.readyToSubmit;
+ },
+
+ ondrop: function() {
+ var callback = this.options.onqueuerequestdrop;
+ if (callback) {
+ callback.call(this.queue, this.source, this.options, this.event);
+ }
+ },
+
+ onRequestDelayPassed: function() {
+ this.readyToSubmit = true;
+ this.queue.submitFirst();
+ },
+
+ startTimer: function() {
+ var delay = this.options.requestDelay || queueOptions.requestDelay || 0;
+
+ log.debug("Queue will wait " + (delay || 0) + "ms before submit");
+
+ if (delay) {
+ var _this = this;
+ this.timer = setTimeout(function() {
+ try {
+ _this.onRequestDelayPassed();
+ } finally {
+ _this.timer = undefined;
+ _this = undefined;
+ }
+ }, delay);
+ } else {
+ this.onRequestDelayPassed();
+ }
+ },
+
+ stopTimer: function() {
+ if (this.timer) {
+ clearTimeout(this.timer);
+ this.timer = undefined;
+ }
+ },
+
+ clearEntry: function() { //???
+ this.stopTimer();
+ if (this.request) {
+ this.request.shouldNotifyQueue = false;
+ this.request = undefined;
+ }
+ },
+
+ getEventsCount: function() {
+ return this.eventsCount;
+ },
+
+ setEventsCount: function(newCount) {
+ this.eventsCount = newCount;
+ }
});
// TODO: add this two variables to richfaces and report bug to jsf about constants
@@ -105,18 +114,12 @@
var log = richfaces.log;
var items = [];
var queueOptions = opts || {};
- //TODO: that's not last, but first
- var last;
+ var lastRequestedEntry;
- //TODO: inline this variable
- var queueMode = queueOptions.mode;
- //TODO: inline this variable
- var queueRequestDelay = queueOptions.requestDelay;
-
//TODO: instance of this function will be created for each queue
var onError = function (data) {
log.debug("richfaces.queue: ajax submit error");
- last = null;
+ lastRequestedEntry = null;
//TODO: what if somebody is going to clear queue on error?
submitFirst();
};
@@ -124,7 +127,7 @@
var onComplete = function (data) {
if (jsfDataTypes[data.type]=='event' && jsfEventNames[data.status]=='success') {
log.debug("richfaces.queue: ajax submit successfull");
- last = null;
+ lastRequestedEntry = null;
submitFirst();
}
};
@@ -133,7 +136,7 @@
jsf.ajax.addOnError(onError);
var submitFirst = function() {
- if (queueMode == QUEUE_MODE_PULL && last) {
+ if (queueOptions.mode == QUEUE_MODE_PULL && lastRequestedEntry) {
log.debug("richfaces.queue: Waiting for previous submit results");
return;
}
@@ -141,20 +144,17 @@
log.debug("richfaces.queue: Nothing to submit");
return;
}
- if (items[0].readyToSubmit) {
- last = items.shift();
- //TODO: unnecessary check
- if (last.readyToSubmit) {
- log.debug("richfaces.queue: will submit request NOW");
- //TODO: events counter should be submitted
- //last.query.appendParameter("AJAX:EVENTS_COUNT", last.eventsCount);
- var params = richfaces.processRequestParams(last.query, last.options);
- //TODO: jsf.ajax.request should be used
- //TODO: copy of event should be created otherwise IE will fail
- richfaces.ajax.request(last.query, last.event, params);
- if (last.options.queueonsubmit) {
- last.options.queueonsubmit.call(last);
- }
+ if (items[0].getReadyToSubmit()) {
+ lastRequestedEntry = items.shift();
+ log.debug("richfaces.queue: will submit request NOW");
+ //TODO: events counter should be submitted
+ //lastRequestedEntry.source.appendParameter("AJAX:EVENTS_COUNT", lastRequestedEntry.eventsCount);
+ var params = richfaces.processRequestParams(lastRequestedEntry.source, lastRequestedEntry.options);
+ //TODO: copy of event should be created otherwise IE will fail
+ //richfaces.ajax.request = jsf.ajax.request
+ richfaces.ajax.request(lastRequestedEntry.source, lastRequestedEntry.event, params);
+ if (lastRequestedEntry.options.queueonsubmit) {
+ lastRequestedEntry.options.queueonsubmit.call(lastRequestedEntry);
}
}
};
@@ -180,9 +180,10 @@
getSize: getSize,
isEmpty: isEmpty,
+ submitFirst: submitFirst,
push: function (source, event, options) {
- var entry = new queueEntry(source, event, options);
+ var entry = new QueueEntry(this, source, event, options);
var similarityGroupingId = entry.getSimilarityGroupingId();
var lastEntry = getLastEntry();
@@ -201,10 +202,8 @@
log.debug("Last queue entry is not the last anymore. Stopping requestDelay timer and marking entry as ready for submission")
lastEntry.stopTimer();
- //TODO: create method resetSimilarityGroupingId()
- lastEntry.setSimilarityGroupingId(undefined);
- //TODO: create method setReadyToSubmit()
- lastEntry.readyToSubmit = true;
+ lastEntry.resetSimilarityGroupingId();
+ lastEntry.setReadyToSubmit(true);
items.push(entry);
log.debug("New request added to queue. Queue similarityGroupingId changed to " + similarityGroupingId);
@@ -218,11 +217,8 @@
},
- //TODO: remove empty functions
- pop: function () {
- },
-
clear: function () {
+ //TODO: clear queue
}
}
}(jQuery.extend({},defaultQueueOptions));
14 years, 6 months
JBoss Rich Faces SVN: r16095 - root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-12-08 07:12:29 -0500 (Tue, 08 Dec 2009)
New Revision: 16095
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
Log:
format corrections
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2009-12-08 09:47:38 UTC (rev 16094)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2009-12-08 12:12:29 UTC (rev 16095)
@@ -105,7 +105,8 @@
}
@Override
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component)
+ throws IOException {
writer.startElement(HTML.DIV_ELEM, component);
writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context), null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, HtmlUtil.concatClasses("rich-extable", (String) component
@@ -159,7 +160,7 @@
}
String width = getColumnWidth(column);
writer.writeText(".rich-extable-cell-width-" + id + " {", "width"); // TODO getNormalizedId(context,
- // state.getGrid())
+ // state.getGrid())
writer.writeText("width: " + width + ";", "width");
writer.writeText("}", "width");
}
14 years, 6 months
JBoss Rich Faces SVN: r16094 - root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-12-08 04:47:38 -0500 (Tue, 08 Dec 2009)
New Revision: 16094
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
Log:
remove StringBuffer
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 19:36:23 UTC (rev 16093)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-08 09:47:38 UTC (rev 16094)
@@ -185,21 +185,18 @@
public String getScript(UIToggleControl toggleControl, String switchType, boolean isExpanded) {
- StringBuffer pattern = new StringBuffer();
-
+ String pattern = null;
+
if (switchType.equals(UISubTable.SWITCH_TYPE_CLIENT)) {
- pattern.append(CLIENT_TOGGLE_SCRIPT);
+ pattern = CLIENT_TOGGLE_SCRIPT;
} else if (switchType.equals(UISubTable.SWITCH_TYPE_AJAX)) {
- pattern.append(AJAX_TOGGLE_SCRIPT);
+ pattern = AJAX_TOGGLE_SCRIPT;
} else {
- pattern.append(SERVER_TOGGLE_SCRIPT);
+ pattern = SERVER_TOGGLE_SCRIPT;
}
-
String toggleId = toggleControl.getClientId();
- String script = (pattern.length() > 0) ? MessageFormat.format(pattern.toString(), toggleId, isExpanded) : null;
-
- return script;
+ return MessageFormat.format(pattern, toggleId, isExpanded);
}
protected String getState(boolean expand) {
14 years, 6 months
JBoss Rich Faces SVN: r16093 - in root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el: node and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-12-07 14:36:23 -0500 (Mon, 07 Dec 2009)
New Revision: 16093
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java
Log:
https://jira.jboss.org/jira/browse/RF-77732
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java 2009-12-07 15:36:38 UTC (rev 16092)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java 2009-12-07 19:36:23 UTC (rev 16093)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.parser.el;
import java.beans.BeanInfo;
@@ -33,6 +35,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -97,8 +100,8 @@
/**
* Class, that encapsulate all functionality, related to Reflection calls, such as loading classes, get property
* descriptors etc...
+ * @author amarkhel
*
- * @author amarkhel
*/
public final class ELParserUtils {
@@ -151,8 +154,7 @@
private static Map<Class<?>, ClassDataHolder> classDataCache =
new WeakHashMap<Class<?>, ClassDataHolder>();
- private ELParserUtils() {
- }
+ private ELParserUtils() { }
public static void verifyClassPropertiesAndMethods(Class<?> initialClass) throws ParsingException {
resolveClassPropertiesAndMethods(initialClass);
@@ -172,10 +174,9 @@
/**
* This method determine type of parsed node and create wrapper for them, that extends AbstractTreeNode.
* If node type is not recognized - throws ParsingException.
- *
* @param child - parsed node
+ * @throws ParsingException - if node type is not recognized.
* @return wrapper for parsed node(if node type is recognized), that implement ITreeNode interface.
- * @throws ParsingException - if node type is not recognized.
*/
public static ITreeNode determineNodeType(Node child) throws ParsingException {
ITreeNode treeNode = null;
@@ -255,14 +256,14 @@
/**
* This method return PropertyDescriptor by specified propertyName and clazz.
- *
- * @param clazz - class to search
+ * @param clazz - class to search
* @param propertyName - propertyName to search
* @return property descriptor if found.
* @throws ParsingException if error occured.
*/
- public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName)
+ public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName)
throws ParsingException {
+
if (clazz == null) {
return null;
}
@@ -273,9 +274,9 @@
/**
* Returns wrapper classes for passed-in class. If type is primitive, then corresponding
- * wrapper class is returned (e.g. boolean -> Boolean), otherwise does nothing and returns
+ * wrapper class is returned (e.g. boolean -> Boolean), otherwise does nothing and returns
* passed-in class.
- *
+ *
* @return wrapper for primitive types, or passed-in class
*/
private static Class<?> getWrapperClass(Class<?> inClazz) {
@@ -294,13 +295,14 @@
* <p>Retrieve the property descriptors for the specified class,
* introspecting and caching them the first time a particular bean class
* is encountered.</p>
- * <p/>
+ *
* <p><strong>FIXME</strong> - Does not work with DynaBeans.</p>
*
* @param beanClass Bean class for which property descriptors are requested
* @return the property descriptors
- * @throws ParsingException if error occured.
- * @throws IllegalArgumentException if <code>beanClass</code> is null
+ * @throws ParsingException if error occured.
+ *
+ * @exception IllegalArgumentException if <code>beanClass</code> is null
*/
private static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass) throws ParsingException {
if (beanClass == null) {
@@ -337,26 +339,26 @@
* the given parameters.
* In other words, it finds a method with the given name
* that will take the parameters given.<p>
- * <p/>
+ *
* <p>This method is slightly undeterminstic since it loops
* through methods names and return the first matching method.</p>
- * <p/>
+ *
* <p>This method is used by
* {@link
* #invokeMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}.
- * <p/>
+ *
* <p>This method can match primitive parameter by passing in wrapper classes.
* For example, a <code>Boolean</code> will match a primitive <code>boolean</code>
* parameter.
*
- * @param clazz find method in this class
- * @param methodName find method with this name
+ * @param clazz find method in this class
+ * @param methodName find method with this name
* @param parameterTypes find method with compatible parameters
* @return The accessible method
* @throws ParsingException if error occured.
*/
- public static Type getMatchingVisibleMethodReturnType(Class<?> clazz, final String methodName,
- Type[] parameterTypes) throws ParsingException {
+ public static Type getMatchingVisibleMethodReturnType(Class<?> clazz, final String methodName,
+ Type[] parameterTypes) throws ParsingException {
if (clazz == null) {
return Object.class;
@@ -371,7 +373,7 @@
float bestMatchCost = Float.MAX_VALUE;
float myCost = Float.MAX_VALUE;
- for (Method resolvedMethod : resolvedMethods) {
+ for (Method resolvedMethod: resolvedMethods) {
if (!isMethodVisible(resolvedMethod)) {
continue;
}
@@ -416,8 +418,7 @@
/**
* Returns the sum of the object transformation cost for each class in the source
* argument list.
- *
- * @param srcArgs The source arguments
+ * @param srcArgs The source arguments
* @param destArgs The destination arguments
* @return The total transformation cost
*/
@@ -434,48 +435,78 @@
return totalCost;
}
+ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) throws ParsingException {
+ final Set<Class<?>> result = new LinkedHashSet<Class<?>>();
+
+ new ClassWalkingLogic(clazz).walk(new ClassVisitor() {
+
+ @Override
+ public void visit(Class<?> clazz) throws ParsingException {
+ if (clazz.isInterface()) {
+ result.add(clazz);
+ }
+ }
+
+ });
+
+ return result;
+ }
+
/**
* Gets the number of steps required needed to turn the source class into the
* destination class. This represents the number of steps in the object hierarchy
* graph.
- *
- * @param srcClass The source class
+ * @param srcClass The source class
* @param destClass The destination class
* @return The cost of transforming an object
*/
private static float getObjectTransformationCost(Type destType, Type srcType) {
float cost = 0.0f;
- if (ELParserUtils.isNullType(srcType)) {
+ //no need to check if destType is primitive because the check has already been done
+ //by isAssignmentCompatible() method
+ if (isNullType(srcType)) {
return cost;
}
- Class<?> srcClass = ELParserUtils.getRawType(srcType);
- Class<?> destClass = ELParserUtils.getRawType(destType);
+ Class<?> srcClass = getWrapperClass(getRawType(srcType));
+ Class<?> destClass = getWrapperClass(getRawType(destType));
+ if (srcClass != null && !srcClass.equals(destClass)) {
+ boolean interfaceMatched = false;
+ try {
+ Set<Class<?>> interfaces = getAllInterfaces(srcClass);
+ for (Class<?> iface : interfaces) {
+ if (isAssignmentCompatible(destClass, iface)) {
+ // slight penalty for interface match.
+ // we still want an exact match to override an interface match, but
+ // an interface match should override anything where we have to get a
+ // superclass.
+ cost += 0.25f;
+ interfaceMatched = true;
- while (srcClass != null && !getWrapperClass(destClass).equals(getWrapperClass(srcClass))) {
- if (destClass.isInterface() && isAssignmentCompatible(destClass, srcClass)) {
+ break;
+ }
+ }
+ } catch (ParsingException e) {
+ // TODO: handle exception
+ }
- // slight penalty for interface match.
- // we still want an exact match to override an interface match, but
- // an interface match should override anything where we have to get a
- // superclass.
- cost += 0.25f;
+ if (!interfaceMatched) {
+ while (srcClass != null && !srcClass.equals(destClass)) {
+ cost++;
+ srcClass = srcClass.getSuperclass();
+ }
- break;
+ /*
+ * If the destination class is null, we've travelled all the way up to
+ * an Object match. We'll penalize this by adding 1.5 to the cost.
+ */
+ if (srcClass == null) {
+ cost += 1.5f;
+ }
}
-
- cost++;
- srcClass = srcClass.getSuperclass();
}
- /*
- * If the destination class is null, we've travelled all the way up to
- * an Object match. We'll penalize this by adding 1.5 to the cost.
- */
- if (srcClass == null) {
- cost += 1.5f;
- }
return cost;
}
@@ -483,7 +514,7 @@
/**
* <p>Determine whether a type can be used as a parameter in a method invocation.
* This method handles primitive conversions correctly.</p>
- * <p/>
+ *
* <p>In order words, it will match a <code>Boolean</code> to a <code>boolean</code>,
* a <code>Long</code> to a <code>long</code>,
* a <code>Float</code> to a <code>float</code>,
@@ -492,19 +523,20 @@
* Now logic widening matches are allowed.
* For example, a <code>Long</code> will not match a <code>int</code>.
*
- * @param parameterType the type of parameter accepted by the method
+ * @param parameterType the type of parameter accepted by the method
* @param parameterization the type of parameter being tested
+ *
* @return true if the assignement is compatible.
*/
public static boolean isAssignmentCompatible(Type parameterType, Type parameterization) {
- Class<?> parameterClass = ELParserUtils.getRawType(parameterType);
+ Class<?> parameterClass = getRawType(parameterType);
- if (ELParserUtils.isNullType(parameterization)) {
+ if (isNullType(parameterization)) {
//null value can be assigned to any class except primitive
return !parameterClass.isPrimitive();
} else {
Class<?> parameterWrappedClass = getWrapperClass(parameterClass);
- Class<?> parameterizationWrappedClass = getWrapperClass(ELParserUtils.getRawType(parameterization));
+ Class<?> parameterizationWrappedClass = getWrapperClass(getRawType(parameterization));
return parameterWrappedClass.isAssignableFrom(parameterizationWrappedClass);
}
}
@@ -512,10 +544,9 @@
/**
* Gets the wrapper object class for the given primitive type class.
* For example, passing <code>boolean.class</code> returns <code>Boolean.class</code>
- *
* @param primitiveType the primitive type class for which a match is to be found
* @return the wrapper type associated with the given primitive
- * or null if no match is found
+ * or null if no match is found
*/
private static Class<?> getPrimitiveWrapper(Class<?> primitiveType) {
@@ -547,6 +578,7 @@
}
static class ClassWalkingLogic {
+
private Queue<Class<?>> classesList = new LinkedList<Class<?>>();
private Set<Class<?>> visitedClasses = new HashSet<Class<?>>();
@@ -562,29 +594,36 @@
while (!classesList.isEmpty()) {
Class<?> clazz = classesList.remove();
- visitor.visit(clazz);
+ if (visitedClasses.add(clazz)) {
+ visitor.visit(clazz);
- Class<?> superclass = clazz.getSuperclass();
- if (superclass != null) {
- if (visitedClasses.add(superclass)) {
- classesList.add(superclass);
+ Class<?> superclass = clazz.getSuperclass();
+ if (superclass != null) {
+ if (!visitedClasses.contains(superclass)) {
+ classesList.add(superclass);
+ }
}
- }
- Class<?>[] interfaces = clazz.getInterfaces();
- if (interfaces != null) {
- for (Class<?> iface : interfaces) {
- if (visitedClasses.add(superclass)) {
- classesList.add(iface);
+ Class<?>[] interfaces = clazz.getInterfaces();
+ if (interfaces != null) {
+ for (Class<?> iface : interfaces) {
+ if (!visitedClasses.contains(iface)) {
+ classesList.add(iface);
+ }
}
}
}
}
- //this is for the case when we started just from interface, not class
+ //While interfaces do not have Object.class in their hierarchy directly,
+ //implementations of interface are always inherited from Object.
+ //As methods in this class are primarily designed to work with implementations (beans),
+ //we are adding Object.class explicitly if it hasn't been visited yet.
if (visitedClasses.add(Object.class)) {
visitor.visit(Object.class);
}
+
+ visitedClasses.clear();
}
}
@@ -593,6 +632,7 @@
}
public static Type getLastTypeArgument(Type type) {
+ //TODO: generic arrays support
Type[] actualTypeArguments = null;
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
@@ -607,6 +647,7 @@
}
public static Class<?> getRawType(Type type) {
+ //TODO: generic arrays support
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
return (Class<?>) parameterizedType.getRawType();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2009-12-07 15:36:38 UTC (rev 16092)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2009-12-07 19:36:23 UTC (rev 16093)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.parser.el.node;
import java.lang.reflect.Type;
@@ -35,6 +37,7 @@
* This class extend AbstractTreeNode and wrap AstFunction node.
*
* @author amarkhel
+ *
*/
public class AstFunctionTreeNode extends AbstractTreeNode {
public AstFunctionTreeNode(Node node) {
@@ -47,13 +50,18 @@
String functionPrefix = functionNode.getPrefix();
String functionName = functionNode.getLocalName();
+ String variableName;
if (functionPrefix != null && functionPrefix.length() != 0) {
//TODO: this should be a property getter, not property name
//TODO: support "super" keyword
- sb.append(functionPrefix);
+ variableName = functionPrefix;
} else {
- sb.append(ELNodeConstants.THIS_PREFIX);
+ variableName = ELNodeConstants.THIS_PREFIX;
}
+
+ sb.append(variableName);
+ visitor.setVariableType(context.get(variableName));
+
sb.append(ELNodeConstants.DOT);
sb.append(functionName);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java 2009-12-07 15:36:38 UTC (rev 16092)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java 2009-12-07 19:36:23 UTC (rev 16093)
@@ -31,18 +31,19 @@
/**
* @author Nick Belaevski
+ *
*/
public final class ConstantValueTreeNode extends AbstractTreeNode {
- //XXX what class to use for null object: Void.class or null - null will be used
- public static final ConstantValueTreeNode NULL_NODE =
- new ConstantValueTreeNode(ELNodeConstants.NULL_VALUE, NullType.INSTANCE);
+ // XXX what class to use for null object: Void.class or null - special NullType be used
+ public static final ConstantValueTreeNode NULL_NODE = new ConstantValueTreeNode(ELNodeConstants.NULL_VALUE,
+ NullType.INSTANCE);
- public static final ConstantValueTreeNode TRUE_NODE =
- new ConstantValueTreeNode(ELNodeConstants.TRUE_VALUE, Boolean.TYPE);
+ public static final ConstantValueTreeNode TRUE_NODE = new ConstantValueTreeNode(ELNodeConstants.TRUE_VALUE,
+ Boolean.TYPE);
- public static final ConstantValueTreeNode FALSE_NODE =
- new ConstantValueTreeNode(ELNodeConstants.FALSE_VALUE, Boolean.TYPE);
+ public static final ConstantValueTreeNode FALSE_NODE = new ConstantValueTreeNode(ELNodeConstants.FALSE_VALUE,
+ Boolean.TYPE);
private final String value;
@@ -55,13 +56,14 @@
this.type = type;
}
- /* (non-Javadoc)
- * @see org.richfaces.cdk.parser.el.node.AbstractTreeNode#visit(java.lang.StringBuilder, java.util.Map,
- * org.richfaces.cdk.parser.el.ELVisitor)
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.parser.el.node.AbstractTreeNode#visit(java.lang.StringBuilder, java.util.Map,
+ * org.richfaces.cdk.parser.el.ELVisitor)
+ */
@Override
- public void visit(StringBuilder sb, Map<String, Type> context,
- ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
sb.append(value);
visitor.setVariableType(type);
14 years, 6 months
JBoss Rich Faces SVN: r16092 - root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-12-07 10:36:38 -0500 (Mon, 07 Dec 2009)
New Revision: 16092
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
Log:
cs format
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 15:21:45 UTC (rev 16091)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 15:36:38 UTC (rev 16092)
@@ -81,10 +81,10 @@
String toggleId = toggleControl.getClientId(context);
String options = encodeOptions(context, toggleControl, subTable);
-
+
writer.startElement(HTML.SCRIPT_ELEM, subTable);
String registerScript = MessageFormat.format(MANAGER_SCRIPT, toggleId, options);
- writer.writeText(registerScript,null);
+ writer.writeText(registerScript, null);
writer.endElement(HTML.SCRIPT_ELEM);
String switchType = subTable.getSwichType();
@@ -145,7 +145,7 @@
HashMap<String, Object> options = new HashMap<String, Object>();
options.put("formId", formId);
options.put("forId", forId);
- options.put("initialState", (Boolean)subTable.isExpanded());
+ options.put("initialState", (Boolean) subTable.isExpanded());
return ScriptUtils.toScript(options);
}
@@ -204,6 +204,6 @@
protected String getState(boolean expand) {
return expand ? EXPAND_STATE : COLLAPSE_STATE;
- }
+ }
}
14 years, 6 months
JBoss Rich Faces SVN: r16091 - root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-12-07 10:21:45 -0500 (Mon, 07 Dec 2009)
New Revision: 16091
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
Log:
encode script element via writer.start/end element; script via writeText
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 15:01:18 UTC (rev 16090)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 15:21:45 UTC (rev 16091)
@@ -27,7 +27,7 @@
@ResourceDependencies( { @ResourceDependency(name = "toggler.js") })
public abstract class ToggleControlRendererBase extends RendererBase {
- private static final String MANAGER_SCRIPT = "<script type=\"text/javascript\">ToggleManager.add(new Toggle(\"{0}\", {1}));</script>";
+ private static final String MANAGER_SCRIPT = "ToggleManager.add(new Toggle(''{0}'', {1}));";
private static final String CLIENT_TOGGLE_SCRIPT = "ToggleManager.clientToggle(''{0}'', {1});";
@@ -81,9 +81,11 @@
String toggleId = toggleControl.getClientId(context);
String options = encodeOptions(context, toggleControl, subTable);
-
+
+ writer.startElement(HTML.SCRIPT_ELEM, subTable);
String registerScript = MessageFormat.format(MANAGER_SCRIPT, toggleId, options);
- writer.write(registerScript);
+ writer.writeText(registerScript,null);
+ writer.endElement(HTML.SCRIPT_ELEM);
String switchType = subTable.getSwichType();
boolean expanded = subTable.isExpanded();
14 years, 6 months
JBoss Rich Faces SVN: r16090 - in root/ui-sandbox/trunk/components/tables/ui/src/main: resources/META-INF/resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-12-07 10:01:18 -0500 (Mon, 07 Dec 2009)
New Revision: 16090
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
Log:
refactor toggler control client/server API
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 15:00:46 UTC (rev 16089)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07 15:01:18 UTC (rev 16090)
@@ -29,11 +29,11 @@
private static final String MANAGER_SCRIPT = "<script type=\"text/javascript\">ToggleManager.add(new Toggle(\"{0}\", {1}));</script>";
- private static final String CLIENT_TOGGLE_SCRIPT = "ToggleManager.clientToggle(''{0}'', ''{1}'');";
+ private static final String CLIENT_TOGGLE_SCRIPT = "ToggleManager.clientToggle(''{0}'', {1});";
- private static final String SERVER_TOGGLE_SCRIPT = "ToggleManager.serverToggle(''{0}'', ''{1}'');";
+ private static final String SERVER_TOGGLE_SCRIPT = "ToggleManager.serverToggle(''{0}'', {1});";
- private static final String AJAX_TOGGLE_SCRIPT = "ToggleManager.ajaxToggle(''{0}'', ''{1}'');";
+ private static final String AJAX_TOGGLE_SCRIPT = "ToggleManager.ajaxToggle(''{0}'', {1});";
private static final String DISPLAY_NONE = "display: none;";
@@ -57,13 +57,13 @@
String state = params.get(hiddenId);
if (state != null && state.trim().length() > 0) {
-
+ boolean newState = Boolean.valueOf(state).booleanValue();
UIComponent processed = findComponent(context, toggle);
if (processed instanceof Expandable) {
- String prevState = getState(((Expandable) processed).isExpanded());
- if (!state.equals(prevState)) {
- new ToggleEvent(processed, isExpanded(state)).queue();
+ boolean prevState = ((Expandable) processed).isExpanded();
+ if (newState != prevState) {
+ new ToggleEvent(processed, newState).queue();
}
}
}
@@ -104,7 +104,7 @@
String image = expanded ? control.getExpandControl() : control.getCollapseControl();
- String script = getScript(control, switchType, state);
+ String script = getScript(control, switchType, expanded);
String style = getStyle(context, control);
String styleClass = getStyleClass(context, control);
@@ -139,12 +139,11 @@
String formId = nestingForm.getClientId(context);
String forId = subTable.getClientId(context);
- String state = getState(subTable.isExpanded());
- HashMap<String, String> options = new HashMap<String, String>();
+ HashMap<String, Object> options = new HashMap<String, Object>();
options.put("formId", formId);
options.put("forId", forId);
- options.put("initialState", state);
+ options.put("initialState", (Boolean)subTable.isExpanded());
return ScriptUtils.toScript(options);
}
@@ -182,7 +181,7 @@
return null;
}
- public String getScript(UIToggleControl toggleControl, String switchType, String state) {
+ public String getScript(UIToggleControl toggleControl, String switchType, boolean isExpanded) {
StringBuffer pattern = new StringBuffer();
@@ -196,17 +195,13 @@
String toggleId = toggleControl.getClientId();
- String script = (pattern.length() > 0) ? MessageFormat.format(pattern.toString(), toggleId, state) : null;
+ String script = (pattern.length() > 0) ? MessageFormat.format(pattern.toString(), toggleId, isExpanded) : null;
return script;
}
protected String getState(boolean expand) {
return expand ? EXPAND_STATE : COLLAPSE_STATE;
- }
+ }
- protected boolean isExpanded(String state) {
- return state.equals(EXPAND_STATE);
- }
-
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2009-12-07 15:00:46 UTC (rev 16089)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2009-12-07 15:01:18 UTC (rev 16090)
@@ -4,6 +4,8 @@
this.state = options.initialState;
this.formId = options.formId;
this.hidden = id + ":hidden";
+ this.expandControl = this.id + ":expand";
+ this.collapseControl = this.id + ":collapse";
}
Toggle.prototype.convertId = function(id) {
@@ -14,26 +16,32 @@
var elements = this.getElement(this.forId);
if(this.state != toState) {
-
- var hideId = this.id + ":" + toState;
- var showId = this.id + ":" + this.state;
-
- var hideControl = this.getElement(hideId);
- var showControl = this.getElement(showId);
-
- this.command("show", showControl);
- this.command("hide", hideControl);
-
- if(toState == 'collapse') {
+
+ this.toggleControls(toState);
+
+ if(toState) {
+ this.command("show", elements);
+ } else {
this.command("hide", elements);
- } else {
- this.command("show", elements);
}
+
this.state = toState;
this.saveState(this.state);
}
}
+Toggle.prototype.toggleControls = function(toState) {
+
+ var hideControlId = toState ? this.expandControl : this.collapseControl;
+ var showControlId = this.state ? this.expandControl : this.collapseControl;
+
+ var hideElement = this.getElement(hideControlId);
+ var showElement = this.getElement(showControlId);
+
+ this.command("show", showElement);
+ this.command("hide", hideElement);
+}
+
Toggle.prototype.saveState= function(state) {
var id = this.hidden;
var element = this.getElement(id);
@@ -42,23 +50,23 @@
}
}
-Toggle.prototype.clientToggle= function(toState){
- this.toggle(toState);
+Toggle.prototype.clientToggle= function(expand){
+ this.toggle(expand);
}
-Toggle.prototype.serverToggle = function(toState) {
- this.saveState(toState);
+Toggle.prototype.serverToggle = function(expand) {
+ this.saveState(expand);
var form = this.getElement(this.formId);
form.submit();
}
-Toggle.prototype.ajaxToggle = function(toState) {
+Toggle.prototype.ajaxToggle = function(expand) {
}
Toggle.prototype.command = function(name, element){
if(name) {
if(element && typeof element[name] == 'function') {
- element[name]();
+ element[name]();
}
}
}
@@ -77,20 +85,20 @@
}
}
-ToggleManager.clientToggle = function(id, state) {
+ToggleManager.clientToggle = function(id, expand) {
if(id) {
- this.process[id].clientToggle(state);
+ this.process[id].clientToggle(expand);
}
}
-ToggleManager.serverToggle = function(id, state) {
+ToggleManager.serverToggle = function(id, expand) {
if(id) {
- this.process[id].serverToggle(state);
+ this.process[id].serverToggle(expand);
}
}
-ToggleManager.ajaxToggle = function(id, state) {
+ToggleManager.ajaxToggle = function(id, expand) {
if(id) {
- this.process[id].ajaxToggle(state);
+ this.process[id].ajaxToggle(expand);
}
}
14 years, 6 months
JBoss Rich Faces SVN: r16089 - root/ui/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-12-07 10:00:46 -0500 (Mon, 07 Dec 2009)
New Revision: 16089
Modified:
root/ui/trunk/pom.xml
Log:
RFPL-195 - Code style policy
Modified: root/ui/trunk/pom.xml
===================================================================
--- root/ui/trunk/pom.xml 2009-12-07 15:00:05 UTC (rev 16088)
+++ root/ui/trunk/pom.xml 2009-12-07 15:00:46 UTC (rev 16089)
@@ -58,8 +58,6 @@
<configuration>
<configLocation>richfaces-checkstyle/richfaces-checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
-
- <failOnViolation>false</failOnViolation>
</configuration>
<phase>process-sources</phase>
14 years, 6 months
JBoss Rich Faces SVN: r16088 - root/framework/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-12-07 10:00:05 -0500 (Mon, 07 Dec 2009)
New Revision: 16088
Modified:
root/framework/trunk/pom.xml
Log:
RFPL-195 - Code style policy
Modified: root/framework/trunk/pom.xml
===================================================================
--- root/framework/trunk/pom.xml 2009-12-07 14:58:23 UTC (rev 16087)
+++ root/framework/trunk/pom.xml 2009-12-07 15:00:05 UTC (rev 16088)
@@ -109,8 +109,6 @@
<configuration>
<configLocation>richfaces-checkstyle/richfaces-checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
-
- <failOnViolation>false</failOnViolation>
</configuration>
<phase>process-sources</phase>
14 years, 6 months