[richfaces-svn-commits] JBoss Rich Faces SVN: r2220 - in trunk: framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts and 6 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Aug 13 09:00:28 EDT 2007
Author: maksimkaszynski
Date: 2007-08-13 09:00:28 -0400 (Mon, 13 Aug 2007)
New Revision: 2220
Added:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/extend/
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/extend/extend.js
trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/
trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/
trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
trunk/framework/api/src/main/java/org/richfaces/model/SortField.java
trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java
trunk/ui/scrollable-grid/generatescript.xml
trunk/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
Log:
moved packages across jars
Modified: trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java 2007-08-13 12:04:01 UTC (rev 2219)
+++ trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java 2007-08-13 13:00:28 UTC (rev 2220)
@@ -21,7 +21,7 @@
* Base class for data models
* Subclasses must implement {@link #loadData(int, int, SortOrder)}
* For certain features (like selection and sorting) to work correctly together,
- * {@link #getId(Object)} and {@link #getObjectById(Object)}
+ * both {@link #getId(Object)} and {@link #getObjectById(Object)}
* methods need to be overriden
*
* @author Maksim Kaszynski
@@ -136,7 +136,6 @@
}
/**
- * To get rid of Entity interface, method is introduced
* Implementations may override it to provide domain-specific searches
* Id should be serializable
* Default implementation returns <code>null</code> anyway
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-08-13 12:04:01 UTC (rev 2219)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-08-13 13:00:28 UTC (rev 2220)
@@ -14,9 +14,8 @@
import org.ajax4jsf.model.Range;
-
-
/**
+ * Iteration range for Scrollable Grid
* @author Maksim Kaszynski
* @modified by Anton Belevich
*/
Modified: trunk/framework/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SortField.java 2007-08-13 12:04:01 UTC (rev 2219)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SortField.java 2007-08-13 13:00:28 UTC (rev 2220)
@@ -6,6 +6,7 @@
import java.io.Serializable;
/**
+ * Sort field is the piece of {@link SortOrder}
* @author Maksim Kaszynski
*
*/
Modified: trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java 2007-08-13 12:04:01 UTC (rev 2219)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java 2007-08-13 13:00:28 UTC (rev 2220)
@@ -3,13 +3,16 @@
import java.io.Serializable;
import java.util.Arrays;
/**
- *
+ * Class representing grid sort order
+ * Sort Order is the combination of {@link SortField}
+ * Order of occurrence of sort fields must be maintained
+ * to guarantee stable sorting
* @author Maksim Kaszynski
- *
- *
*/
public class SortOrder implements Serializable {
+ private static final long serialVersionUID = 2423450561570551363L;
+
private static int hashCode(Object[] array) {
final int prime = 31;
if (array == null)
@@ -22,8 +25,6 @@
return result;
}
- private static final long serialVersionUID = 2423450561570551363L;
-
private SortField [] fields;
public SortOrder() {
@@ -37,21 +38,6 @@
- public SortField[] getFields() {
- return fields;
- }
-
- public void setFields(SortField[] fields) {
- this.fields = fields;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + SortOrder.hashCode(fields);
- return result;
- }
-
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -65,6 +51,21 @@
return true;
}
+ public SortField[] getFields() {
+ return fields;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + SortOrder.hashCode(fields);
+ return result;
+ }
+
+ public void setFields(SortField[] fields) {
+ this.fields = fields;
+ }
+
}
\ No newline at end of file
Added: trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/extend/extend.js
===================================================================
--- trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/extend/extend.js (rev 0)
+++ trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/extend/extend.js 2007-08-13 13:00:28 UTC (rev 2220)
@@ -0,0 +1,189 @@
+// vim: tw=80 ts=4 sw=4 noet
+// ----------------------------------------------------------------------------
+// Project : Extend - Prototype OOP extension
+// URL : <http://www.ivy.fr/js/extend>
+// ----------------------------------------------------------------------------
+// Author : Sebastien Pierre <sebastien at ivy.fr>
+// License : Revised BSD License
+// ----------------------------------------------------------------------------
+// Creation : 08-Sep-2006
+// Last mod : 17-Nov-2006
+// ----------------------------------------------------------------------------
+
+// The Extend object holds all the information required to implement the
+// inheritance and other OO-goodness.
+if(!window.Extend) {
+
+Extend = {
+ VERSION: 1.1,
+ CLASSDEF: "CLASSDEF",
+ DELETE: "DELETE",
+ // These are a list of methods of class instances that are reserved by the
+ // OO layer (see the reparent method for more info)
+ INSTANCE_RESERVED: {
+ CLASSDEF: true,
+ getClass: true,
+ parentClass: true
+ },
+
+ // Sets up a class
+ setupClass: function( _class, declaration )
+ {
+ // We create an empty prototype if the user did not provide one
+ declaration = declaration || {}
+ _class.prototype = declaration
+ // We clone the given method definition, because they will be augmented
+ // with the ones defined in the parent class
+ _class.methods = {}
+ for ( var key in declaration ) { _class.methods[key] = declaration[key] }
+ _class.inherited = {}
+ _class.parentClass = undefined
+ if ( declaration[Extend.CLASSDEF] )
+ { _class.className = declaration[Extend.CLASSDEF].name }
+ else
+ { _class.className = undefined }
+ _class.subclasses = _class.subclasses || []
+ _class.constructor = Extend.Operations.constructor
+ _class.reparent = Extend.Operations.reparent
+ _class.method = Extend.Operations.method
+ _class.update = Extend.Operations.update
+ if ( declaration[Extend.CLASSDEF] )
+ { _class.reparent(declaration[Extend.CLASSDEF].parent) }
+ // We update the class methods with an `ofClass` method that returns the
+ // class, so that instances will have a proper
+ declaration.getClass = function() {return _class}
+ declaration.parentClass = function() {return this.getClass().parentClass}
+ declaration.parentCall = function() {
+ var new_args = []
+ for ( var i=1;i<arguments.length;i++ ) {new_args.push(arguments[i])}
+ return this.parentClass().method(arguments[0]).apply(this, new_args)
+ }
+ declaration.setClass = function(newClass) {
+ return this.getClass().parentClass
+ }
+ // We reparent the subclasses if any
+ for ( var i=0 ; i<_class.subclasses ; i++ ) {
+ _class.subclasses[i].reparent(_class)
+ }
+ return _class
+ },
+ // These are operations that will be "mixed-in" with the new classes
+ Operations: {
+ constructor: function() {
+ return this.prototype.initialize || function() {}
+ },
+ // Reparents this class
+ reparent: function( newParentClass )
+ {
+ if ( this.parentClass )
+ {
+ var this_index = this.subclasses.indexOf(this)
+ this.parentClass.subclasses.splice(this_index, 1)
+ for ( var method_name in this.inherited ) {
+ this.method(method_name, null, this.parentClass)
+ }
+ }
+ this.parentClass = newParentClass
+ if ( !newParentClass ) return
+ var parent_methods = newParentClass.prototype
+ // We iterate on all the parent methods
+ for ( parent_method_name in parent_methods ) {
+ // If the method is a reserved one, we skip it
+ if ( Extend.INSTANCE_RESERVED[parent_method_name] == true ) { continue }
+ // If the method is not directly defined in the current class, we add it
+ if ( this.methods[parent_method_name] == undefined )
+ {
+ this.method( parent_method_name,
+ parent_methods[parent_method_name],
+ newParentClass.inherited[parent_method_name] || newParentClass
+ )
+ }
+ }
+ newParentClass.subclasses.push(this)
+ },
+ update: function(newPrototype) {
+ Extend.setupClass(this, newPrototype||this.prototype)
+ },
+ // Returns, sets or deletes a method in this class
+ method: function( name, body, declaredIn ) {
+ if ( body == undefined )
+ {
+ var method = this.prototype[name]
+ if ( name == undefined ) throw new Error("Method not found: "+name)
+ return method
+ }
+ else
+ {
+ declaredIn = declaredIn || this
+ // If the method is declared in this class
+ if ( declaredIn == this )
+ {
+ if ( body == Extend.DELETE ) {
+ delete this.methods[name]
+ delete this.inherited[name]
+ delete this.prototype[name]
+ // If the method is defined in the parent we set it
+ if ( this.parentClass ) {
+ var parent_method = this.parentClass.method(name)
+ if ( parent_method ) {
+ this.method(name, parent_method, this.parentClass.inherited[name] || this.parentClass)
+ }
+ }
+ } else {
+ this.methods[name] = body
+ this.prototype[name] = body
+ delete this.inherited[name]
+ }
+ }
+ // Or if its declared in another class
+ else
+ {
+ if ( body == Extend.DELETE ) {
+ delete this.inherited[name]
+ delete this.methods[name]
+ delete this.prototype[name]
+ // If the method is defined in the parent we set it
+ if ( this.parentClass ) {
+ var parent_method = this.parentClass.method(name)
+ if ( parent_method ) {
+ this.method(name, parent_method, this.parentClass.inherited[name] || this.parentClass)
+ }
+ }
+ }
+ else {
+ if ( this.methods[name] == undefined ) {
+ this.inherited[name] = declaredIn
+ this.prototype[name] = body
+ }
+ }
+ }
+ for ( var i=0 ; i<this.subclasses.length ; i++ )
+ {
+ this.subclasses[i].method(name,body,declaredIn)
+ }
+ }
+ }
+ }
+}
+
+// In case prototype is not available, we use this instead
+try {
+ Class = Class
+} catch ( Error ) {
+ Class = {create:function() {return function() {this.initialize.apply(this, arguments)}}}
+}
+Class._create = Class.create
+Class.create = function( declaration ) {
+ var new_class = Extend.setupClass(Class._create(declaration), declaration)
+ // The following only works on FireFox
+ /*
+ new_class.watch("prototype", function(id,oldval,newval) {
+ new_class.prototype = newval
+ Extend.setupClass(new_class, newval)
+ return newval
+ })*/
+ return new_class
+};
+
+};
+// EOF
Modified: trunk/ui/scrollable-grid/generatescript.xml
===================================================================
--- trunk/ui/scrollable-grid/generatescript.xml 2007-08-13 12:04:01 UTC (rev 2219)
+++ trunk/ui/scrollable-grid/generatescript.xml 2007-08-13 13:00:28 UTC (rev 2220)
@@ -21,7 +21,6 @@
<property name="gen-script-full-name" value="${target-dir}/${script-path}/${gen-script-name}"></property>
<concat append="false" binary="false" destfile="${gen-script-full-name}">
<filelist dir="${resources-dir}">
- <file name="${resources-dir}/common/prototype/ext/extend.js"/>
<file name="${resources-dir}/ClientUILib.js"/>
<file name="${resources-dir}/ClientUI/common/utils/Utils.js"/>
<file name="${resources-dir}/ClientUI/common/utils/StringBuilder.js"/>
@@ -56,7 +55,6 @@
<property name="gen-script-full-name" value="${target-dir}/${script-path}/${gen-script-name}"></property>
<concat append="false" binary="false" destfile="${gen-script-full-name}">
<filelist dir="${resources-dir}">
- <file name="/common/prototype/ext/extend.js"/>
<file name="ClientUILib.js"/>
<file name="/ClientUI/common/utils/Utils.js"/>
<file name="/ClientUI/common/utils/StringBuilder.js"/>
Added: trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
===================================================================
--- trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java (rev 0)
+++ trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-08-13 13:00:28 UTC (rev 2220)
@@ -0,0 +1,131 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Class representing selection on client side.
+ * Actually, it's renderer specific
+ * @author Maksim Kaszynski
+ *
+ */
+public class ClientSelection implements Serializable{
+
+ private static final long serialVersionUID = 5855157282287053681L;
+
+ public static final String FLAG_RESET = "x";
+
+ public static final String FLAG_ALL = "a";
+
+ private String selectionFlag;
+
+ private List ranges = new ArrayList();
+
+ public ClientSelection() {
+ }
+
+
+ public void addRange(SelectionRange range) {
+ ranges.add(range);
+ }
+
+ public boolean isSelected(int i) {
+ boolean result = false;
+ Iterator iterator = ranges.iterator();
+ while (iterator.hasNext() && !result) {
+ result |= ((SelectionRange) iterator.next()).within(i);
+ }
+ return result;
+ }
+
+ public List getRanges() {
+ return ranges;
+ }
+
+ public void addIndex(int j) {
+ if(this.isSelected(j)) return;
+
+
+
+ SelectionRange firstRange = null;
+
+ int s = ranges.size();
+
+ int insertPosition = 0;
+
+ for(int i = 0; i < s && insertPosition >= 0 ; i++) {
+
+ firstRange = (SelectionRange) ranges.get(i);
+
+ if (firstRange.getStartIndex() == j + 1) {
+
+ firstRange.setStartIndex(j);
+ insertPosition = -1;
+
+ } else if (firstRange.getEndIndex() == j - 1) {
+
+ firstRange.setEndIndex(j);
+
+ if (i + 1 < s) {
+ SelectionRange range2 = (SelectionRange) ranges.get(i + 1);
+
+ if (range2.getStartIndex() == j || range2.getStartIndex() == j + 1) {
+
+ ranges.remove(i + 1);
+
+ firstRange.setEndIndex(range2.getEndIndex());
+ }
+ }
+
+ insertPosition = -1;
+
+ } else if (firstRange.getStartIndex() > j) {
+ insertPosition = i;
+ }
+
+ }
+
+ if (insertPosition >= 0) {
+ firstRange = new SelectionRange(j,j);
+ ranges.add(insertPosition, firstRange);
+
+ return;
+ }
+
+
+ }
+
+ private boolean reset = false;
+ public boolean isReset() {
+ return reset;
+ }
+
+ private boolean selectAll = false;
+ public boolean isSelectAll() {
+ return selectAll;
+ }
+
+
+ public String getSelectionFlag() {
+ return selectionFlag;
+ }
+
+
+ public void setSelectionFlag(String selectionFlag) {
+ this.selectionFlag = selectionFlag;
+
+ reset = false;
+ selectAll = false;
+
+ if (FLAG_ALL.equals(selectionFlag)) {
+ selectAll = true;
+ } else if (FLAG_RESET.equals(selectionFlag)) {
+ reset = true;
+ }
+ }
+}
Added: trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
===================================================================
--- trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java (rev 0)
+++ trunk/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-08-13 13:00:28 UTC (rev 2220)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SelectionRange {
+ private int startIndex = -1;;
+ private int endIndex = -1;
+
+ public SelectionRange(int startIndex, int endIndex) {
+ super();
+ this.startIndex = startIndex;
+ this.endIndex = endIndex;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ public void setEndIndex(int endIndex) {
+ this.endIndex = endIndex;
+ }
+
+ public boolean within(int index) {
+ return startIndex <= index && endIndex >= index;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + endIndex;
+ result = prime * result + startIndex;
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SelectionRange other = (SelectionRange) obj;
+ if (endIndex != other.endIndex)
+ return false;
+ if (startIndex != other.startIndex)
+ return false;
+ return true;
+ }
+
+
+}
Modified: trunk/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-08-13 12:04:01 UTC (rev 2219)
+++ trunk/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-08-13 13:00:28 UTC (rev 2220)
@@ -19,6 +19,7 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
+ /org/richfaces/renderkit/html/scripts/extend/extend.js,
/org/richfaces/renderkit/html/scripts/scrollable-grid.js
</h:scripts>
More information about the richfaces-svn-commits
mailing list