[richfaces-svn-commits] JBoss Rich Faces SVN: r2074 - in trunk: framework/api/src/main/java/org/richfaces/event and 14 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Aug 6 09:44:50 EDT 2007


Author: maksimkaszynski
Date: 2007-08-06 09:44:50 -0400 (Mon, 06 Aug 2007)
New Revision: 2074

Added:
   trunk/framework/api/src/main/java/org/richfaces/component/ScriptExportable.java
   trunk/framework/api/src/main/java/org/richfaces/component/Selectable.java
   trunk/framework/api/src/main/java/org/richfaces/component/Sortable.java
   trunk/framework/api/src/main/java/org/richfaces/event/scroll/
   trunk/framework/api/src/main/java/org/richfaces/event/sort/
   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/framework/api/src/main/java/org/richfaces/model/selection/
   trunk/framework/impl/src/main/java/org/richfaces/model/
   trunk/framework/impl/src/test/java/org/richfaces/model/
   trunk/samples/scrollable-grid-demo/
   trunk/ui/scrollable-grid/
Removed:
   trunk/sandbox/api/src/main/java/org/richfaces/component/ScriptExportable.java
   trunk/sandbox/api/src/main/java/org/richfaces/component/Selectable.java
   trunk/sandbox/api/src/main/java/org/richfaces/component/Sortable.java
   trunk/sandbox/api/src/main/java/org/richfaces/event/scroll/
   trunk/sandbox/api/src/main/java/org/richfaces/event/sort/
   trunk/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java
   trunk/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
   trunk/sandbox/api/src/main/java/org/richfaces/model/SortField.java
   trunk/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java
   trunk/sandbox/api/src/main/java/org/richfaces/model/selection/
   trunk/sandbox/impl/src/main/java/org/richfaces/model/
   trunk/sandbox/impl/src/test/java/org/richfaces/model/
   trunk/sandbox/samples/scrollable-grid-demo/
   trunk/sandbox/ui/scrollable-grid/
Modified:
   trunk/samples/pom.xml
   trunk/samples/scrollable-grid-demo/pom.xml
   trunk/sandbox/samples/pom.xml
   trunk/sandbox/ui/pom.xml
   trunk/ui/pom.xml
   trunk/ui/scrollable-grid/pom.xml
Log:
moved scrollable grid into ui project

Copied: trunk/framework/api/src/main/java/org/richfaces/component/ScriptExportable.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/component/ScriptExportable.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/component/ScriptExportable.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/component/ScriptExportable.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,13 @@
+/**
+ * 
+ */
+package org.richfaces.component;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface ScriptExportable {
+	public String getScriptVar();
+	public void setScriptVar(String s);
+}

Copied: trunk/framework/api/src/main/java/org/richfaces/component/Selectable.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/component/Selectable.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/component/Selectable.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/component/Selectable.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,15 @@
+/**
+ * 
+ */
+package org.richfaces.component;
+
+import org.richfaces.model.selection.Selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selectable {
+	public Selection getSelection();
+	public void setSelection (Selection selection);
+}

Copied: trunk/framework/api/src/main/java/org/richfaces/component/Sortable.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/component/Sortable.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/component/Sortable.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/component/Sortable.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,23 @@
+/*
+ *  Copyright
+ *      Copyright (c) Exadel,Inc. 2006
+ *      All rights reserved.
+ *  
+ *  History
+ *      $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v $
+ *      $Revision: 1.1 $ 
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.model.SortOrder;
+
+
+/**
+ * @author Maksim Kaszynski
+ * Base interface for sort capable components
+ */
+public interface Sortable {
+	public SortOrder getSortOrder();
+	public void setSortOrder(SortOrder sortOrder);
+}

Copied: trunk/framework/api/src/main/java/org/richfaces/event/scroll (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/event/scroll)

Copied: trunk/framework/api/src/main/java/org/richfaces/event/sort (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/event/sort)

Copied: trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/GridDataModel.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,208 @@
+/**
+ * 
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * 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)}
+ * methods need to be overriden
+ * 
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class GridDataModel extends ExtendedDataModel {
+	
+	/**
+	 * Simple implementation - index-based row key
+	 * @author Maksim Kaszynski
+	 *
+	 */
+	private static class SimpleRowKey implements Serializable{
+
+		private static final long serialVersionUID = 1L;
+		private int i;
+
+		public SimpleRowKey(int i) {
+			super();
+			this.i = i;
+		}
+		
+		public int intValue() {
+			return i;
+		}
+		
+		public String toString() {
+			return String.valueOf(i);
+		}
+	}
+
+	
+	private static final Log log = LogFactory.getLog(GridDataModel.class);
+	
+	private Object rowKey;
+
+	private Map mapping;
+	
+	private SortOrder lastSortOrder;
+	
+	/**
+	 * Load range of data items from the source.
+	 * Starting from startRow, and up to but excluding endRow
+	 * @param startRow
+	 * @param endRow
+	 * @param sortOrder
+	 * @return list of ordered data
+	 */
+	public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
+
+	
+	/**
+	 * Load data range, and iterate over it
+	 */
+	public void walk(FacesContext context, DataVisitor visitor, Range range,
+			Object argument) throws IOException {
+		
+		if (log.isTraceEnabled()) {
+			log.trace("Starting walk");
+		}
+		
+		ScrollableGridRange sequenceRange = (ScrollableGridRange) range;
+		
+		int startIndex = sequenceRange.getFirst();
+		int last = sequenceRange.getLast();
+		
+		lastSortOrder = sequenceRange.getSortOrder();
+		
+		List objects = loadData(startIndex, last, lastSortOrder);
+		
+		mapping = new HashMap();
+		
+		for (int i = 0; i < objects.size(); i++,startIndex++) {
+			Object data = objects.get(i);
+			Object key = getId(data);
+			
+			if (key == null) {
+				key = new SimpleRowKey(startIndex);
+			}
+			
+			mapping.put(key, data);
+			
+			visitor.process(context, key, argument);
+			
+		}
+
+		if (log.isTraceEnabled()) {
+			log.trace("Ending walk");
+		}
+		
+	}
+	
+	
+	/**
+	 * This method is the reverse of {@link #getId(Object)}
+	 * If you override this method, you need to override {@link #getId(Object)} as well
+	 * @param id
+	 * @return
+	 */
+	public Object getObjectById(Object id) {
+		
+		if (id instanceof SimpleRowKey) {
+			int i = ((SimpleRowKey) id).intValue();
+			
+			List l = loadData(i, i + 1, lastSortOrder);
+			
+			return l.get(0);
+			
+		}
+		
+		return null;
+	}
+	
+	/**
+	 * 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
+	 * If you override this method, you need to override {@link #getObjectById(Object)} as well
+	 * @param o
+	 * @return
+	 */
+	public Object getId(Object o) {
+		return null;
+	}
+	
+	
+	public Object getRowData() {
+		
+		if (mapping != null && mapping.containsKey(rowKey)) {
+			return mapping.get(rowKey);	
+		} else {
+			return loadAndMap(rowKey);
+		}
+
+	}
+	
+	/**
+	 * Row indexes navigation is no longer supported
+	 */
+	public int getRowIndex() {
+		throw new UnsupportedOperationException("getRowIndex");
+	}
+	
+	/**
+	 * Quite simple implementation - data will be cached, so the call will be cheap
+	 */
+	public boolean isRowAvailable() {
+		return getRowData() != null;
+	}
+
+	/**
+	 * Row indexes navigation is no longer supported
+	 */
+	public void setRowIndex(int arg0) {
+		throw new UnsupportedOperationException("setRowIndex");
+	}
+
+	public Object getRowKey() {
+		return rowKey;
+	}
+
+	public void setRowKey(Object key) {
+		rowKey = key;
+	}
+
+	private Object loadAndMap(Object id) {
+		
+		if (log.isTraceEnabled()) {
+			log.trace("loadAndMap " + id);
+		}
+		
+		Object o = getObjectById(id);
+		if (o != null) {
+			if (mapping == null) {
+				mapping = new HashMap();
+			}
+			mapping.put(id, o);
+		}
+		return o;
+	}
+
+
+}

Copied: trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ScrollableGridRange.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,93 @@
+/*
+ *  Copyright
+ *      Copyright (c) Exadel,Inc. 2006
+ *      All rights reserved.
+ *  
+ *  History
+ *      $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableGridRange.java,v $
+ *      $Revision: 1.7 $ 
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+import org.ajax4jsf.model.Range;
+
+
+
+/**
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ */
+public class ScrollableGridRange implements Range, Serializable{
+	
+	private static final long serialVersionUID = -6675002421400464892L;
+	
+	private int first = 0;
+	private int last = 0;
+	private SortOrder sortOrder;
+	
+	public ScrollableGridRange(int first, int last, SortOrder sortOrder) {
+		super();
+		this.first = first;
+		this.last = last;
+		this.sortOrder = sortOrder;
+	}
+
+	/**
+	 * @return the bufferSize
+	 */
+	public int getLast() {
+		return last;
+	}
+	/**
+	 * @param bufferSize the bufferSize to set
+	 */
+	public void setLast(int lastRow) {
+		this.last = lastRow;
+	}
+	/**
+	 * @return the first
+	 */
+	public int getFirst() {
+		return first;
+	}
+	/**
+	 * @param first the first to set
+	 */
+	public void setFirst(int first) {
+		this.first = first;
+	}
+
+	public SortOrder getSortOrder() {
+		return sortOrder;
+	}
+
+	public void setSortOrder(SortOrder sortOrder) {
+		this.sortOrder = sortOrder;
+	}
+	
+	public boolean equals(Object obj) {
+	
+		if(!(obj instanceof ScrollableGridRange)){
+			return super.equals(obj);
+		}
+		
+		ScrollableGridRange ref = (ScrollableGridRange)obj;
+		
+		boolean ret = (this.first == ref.first)&&(this.last == ref.last );
+		
+		if(this.sortOrder != null){
+			ret = ret && this.sortOrder.equals(ref.sortOrder);  
+		} else {
+			ret = (ret && (ref.sortOrder == null));
+		}
+				
+		return ret;
+	}
+	
+	public int hashCode() {
+		return super.hashCode();
+	}
+}

Copied: trunk/framework/api/src/main/java/org/richfaces/model/SortField.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/model/SortField.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SortField.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SortField.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,89 @@
+/**
+ * 
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SortField implements Serializable{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private String name = null;
+	private int index = -1;
+	private Boolean ascending = null;
+	
+	
+	
+	public SortField(String name, int index, Boolean ascending) {
+		super();
+		this.name = name;
+		this.index = index;
+		this.ascending = ascending;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public int getIndex() {
+		return index;
+	}
+
+	public void setIndex(int index) {
+		this.index = index;
+	}
+
+	public Boolean getAscending() {
+		return ascending;
+	}
+
+	public void setAscending(Boolean ascending) {
+		this.ascending = ascending;
+	}
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result
+				+ ((ascending == null) ? 0 : ascending.hashCode());
+		result = prime * result + index;
+		result = prime * result + ((name == null) ? 0 : name.hashCode());
+		return result;
+	}
+
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		final SortField other = (SortField) obj;
+		if (ascending == null) {
+			if (other.ascending != null)
+				return false;
+		} else if (!ascending.equals(other.ascending))
+			return false;
+		if (index != other.index)
+			return false;
+		if (name == null) {
+			if (other.name != null)
+				return false;
+		} else if (!name.equals(other.name))
+			return false;
+		return true;
+	}
+
+	
+	
+}

Copied: trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SortOrder.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -0,0 +1,70 @@
+package org.richfaces.model;
+
+import java.io.Serializable;
+import java.util.Arrays;
+/**
+ *
+ * @author Maksim Kaszynski
+ * 
+ *
+ */
+public class SortOrder implements Serializable {
+
+	private static int hashCode(Object[] array) {
+		final int prime = 31;
+		if (array == null)
+			return 0;
+		int result = 1;
+		for (int index = 0; index < array.length; index++) {
+			result = prime * result
+					+ (array[index] == null ? 0 : array[index].hashCode());
+		}
+		return result;
+	}
+
+	private static final long serialVersionUID = 2423450561570551363L;
+
+	private SortField [] fields;
+
+	public SortOrder() {
+		
+	}
+	
+	public SortOrder(SortField[] fields) {
+		super();
+		this.fields = fields;
+	}
+
+
+
+	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;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		final SortOrder other = (SortOrder) obj;
+		if (!Arrays.equals(fields, other.fields))
+			return false;
+		return true;
+	}
+
+	
+	
+}
\ No newline at end of file

Copied: trunk/framework/api/src/main/java/org/richfaces/model/selection (from rev 2069, trunk/sandbox/api/src/main/java/org/richfaces/model/selection)

Copied: trunk/framework/impl/src/main/java/org/richfaces/model (from rev 2069, trunk/sandbox/impl/src/main/java/org/richfaces/model)

Copied: trunk/framework/impl/src/test/java/org/richfaces/model (from rev 2069, trunk/sandbox/impl/src/test/java/org/richfaces/model)

Modified: trunk/samples/pom.xml
===================================================================
--- trunk/samples/pom.xml	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/samples/pom.xml	2007-08-06 13:44:50 UTC (rev 2074)
@@ -459,5 +459,6 @@
 		-->
 		<module>panelmenu-sample</module>
 		<module>rich-message-demo</module>
+		<module>scrollable-grid-demo</module>
     	</modules>
 </project>
\ No newline at end of file

Copied: trunk/samples/scrollable-grid-demo (from rev 2069, trunk/sandbox/samples/scrollable-grid-demo)

Modified: trunk/samples/scrollable-grid-demo/pom.xml
===================================================================
--- trunk/sandbox/samples/scrollable-grid-demo/pom.xml	2007-08-06 10:39:16 UTC (rev 2069)
+++ trunk/samples/scrollable-grid-demo/pom.xml	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,17 +1,17 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <artifactId>samples</artifactId>
-    <groupId>org.richfaces.sandbox</groupId>
+    <groupId>org.richfaces</groupId>
     <version>3.1.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>scrollable-grid-demo</artifactId>
-  <groupId>org.richfaces.sandbox</groupId>
+  <groupId>org.richfaces.samples</groupId>
   <packaging>war</packaging>
   <name>scrollable-grid-demo Maven Webapp</name>
   <dependencies>
     <dependency>
-      <groupId>org.richfaces.sandbox.ui</groupId>
+      <groupId>org.richfaces.ui</groupId>
       <artifactId>scrollable-grid</artifactId>
       <version>3.1.0-SNAPSHOT</version>
     </dependency>

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/component/ScriptExportable.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/component/ScriptExportable.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/component/ScriptExportable.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,13 +0,0 @@
-/**
- * 
- */
-package org.richfaces.component;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface ScriptExportable {
-	public String getScriptVar();
-	public void setScriptVar(String s);
-}

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/component/Selectable.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/component/Selectable.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/component/Selectable.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,15 +0,0 @@
-/**
- * 
- */
-package org.richfaces.component;
-
-import org.richfaces.model.selection.Selection;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface Selectable {
-	public Selection getSelection();
-	public void setSelection (Selection selection);
-}

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/component/Sortable.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/component/Sortable.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/component/Sortable.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,23 +0,0 @@
-/*
- *  Copyright
- *      Copyright (c) Exadel,Inc. 2006
- *      All rights reserved.
- *  
- *  History
- *      $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v $
- *      $Revision: 1.1 $ 
- */
-
-package org.richfaces.component;
-
-import org.richfaces.model.SortOrder;
-
-
-/**
- * @author Maksim Kaszynski
- * Base interface for sort capable components
- */
-public interface Sortable {
-	public SortOrder getSortOrder();
-	public void setSortOrder(SortOrder sortOrder);
-}

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,208 +0,0 @@
-/**
- * 
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * 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)}
- * methods need to be overriden
- * 
- * @author Maksim Kaszynski
- *
- */
-public abstract class GridDataModel extends ExtendedDataModel {
-	
-	/**
-	 * Simple implementation - index-based row key
-	 * @author Maksim Kaszynski
-	 *
-	 */
-	private static class SimpleRowKey implements Serializable{
-
-		private static final long serialVersionUID = 1L;
-		private int i;
-
-		public SimpleRowKey(int i) {
-			super();
-			this.i = i;
-		}
-		
-		public int intValue() {
-			return i;
-		}
-		
-		public String toString() {
-			return String.valueOf(i);
-		}
-	}
-
-	
-	private static final Log log = LogFactory.getLog(GridDataModel.class);
-	
-	private Object rowKey;
-
-	private Map mapping;
-	
-	private SortOrder lastSortOrder;
-	
-	/**
-	 * Load range of data items from the source.
-	 * Starting from startRow, and up to but excluding endRow
-	 * @param startRow
-	 * @param endRow
-	 * @param sortOrder
-	 * @return list of ordered data
-	 */
-	public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
-
-	
-	/**
-	 * Load data range, and iterate over it
-	 */
-	public void walk(FacesContext context, DataVisitor visitor, Range range,
-			Object argument) throws IOException {
-		
-		if (log.isTraceEnabled()) {
-			log.trace("Starting walk");
-		}
-		
-		ScrollableGridRange sequenceRange = (ScrollableGridRange) range;
-		
-		int startIndex = sequenceRange.getFirst();
-		int last = sequenceRange.getLast();
-		
-		lastSortOrder = sequenceRange.getSortOrder();
-		
-		List objects = loadData(startIndex, last, lastSortOrder);
-		
-		mapping = new HashMap();
-		
-		for (int i = 0; i < objects.size(); i++,startIndex++) {
-			Object data = objects.get(i);
-			Object key = getId(data);
-			
-			if (key == null) {
-				key = new SimpleRowKey(startIndex);
-			}
-			
-			mapping.put(key, data);
-			
-			visitor.process(context, key, argument);
-			
-		}
-
-		if (log.isTraceEnabled()) {
-			log.trace("Ending walk");
-		}
-		
-	}
-	
-	
-	/**
-	 * This method is the reverse of {@link #getId(Object)}
-	 * If you override this method, you need to override {@link #getId(Object)} as well
-	 * @param id
-	 * @return
-	 */
-	public Object getObjectById(Object id) {
-		
-		if (id instanceof SimpleRowKey) {
-			int i = ((SimpleRowKey) id).intValue();
-			
-			List l = loadData(i, i + 1, lastSortOrder);
-			
-			return l.get(0);
-			
-		}
-		
-		return null;
-	}
-	
-	/**
-	 * 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
-	 * If you override this method, you need to override {@link #getObjectById(Object)} as well
-	 * @param o
-	 * @return
-	 */
-	public Object getId(Object o) {
-		return null;
-	}
-	
-	
-	public Object getRowData() {
-		
-		if (mapping != null && mapping.containsKey(rowKey)) {
-			return mapping.get(rowKey);	
-		} else {
-			return loadAndMap(rowKey);
-		}
-
-	}
-	
-	/**
-	 * Row indexes navigation is no longer supported
-	 */
-	public int getRowIndex() {
-		throw new UnsupportedOperationException("getRowIndex");
-	}
-	
-	/**
-	 * Quite simple implementation - data will be cached, so the call will be cheap
-	 */
-	public boolean isRowAvailable() {
-		return getRowData() != null;
-	}
-
-	/**
-	 * Row indexes navigation is no longer supported
-	 */
-	public void setRowIndex(int arg0) {
-		throw new UnsupportedOperationException("setRowIndex");
-	}
-
-	public Object getRowKey() {
-		return rowKey;
-	}
-
-	public void setRowKey(Object key) {
-		rowKey = key;
-	}
-
-	private Object loadAndMap(Object id) {
-		
-		if (log.isTraceEnabled()) {
-			log.trace("loadAndMap " + id);
-		}
-		
-		Object o = getObjectById(id);
-		if (o != null) {
-			if (mapping == null) {
-				mapping = new HashMap();
-			}
-			mapping.put(id, o);
-		}
-		return o;
-	}
-
-
-}

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,93 +0,0 @@
-/*
- *  Copyright
- *      Copyright (c) Exadel,Inc. 2006
- *      All rights reserved.
- *  
- *  History
- *      $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableGridRange.java,v $
- *      $Revision: 1.7 $ 
- */
-
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-import org.ajax4jsf.model.Range;
-
-
-
-/**
- * @author Maksim Kaszynski
- * @modified by Anton Belevich
- */
-public class ScrollableGridRange implements Range, Serializable{
-	
-	private static final long serialVersionUID = -6675002421400464892L;
-	
-	private int first = 0;
-	private int last = 0;
-	private SortOrder sortOrder;
-	
-	public ScrollableGridRange(int first, int last, SortOrder sortOrder) {
-		super();
-		this.first = first;
-		this.last = last;
-		this.sortOrder = sortOrder;
-	}
-
-	/**
-	 * @return the bufferSize
-	 */
-	public int getLast() {
-		return last;
-	}
-	/**
-	 * @param bufferSize the bufferSize to set
-	 */
-	public void setLast(int lastRow) {
-		this.last = lastRow;
-	}
-	/**
-	 * @return the first
-	 */
-	public int getFirst() {
-		return first;
-	}
-	/**
-	 * @param first the first to set
-	 */
-	public void setFirst(int first) {
-		this.first = first;
-	}
-
-	public SortOrder getSortOrder() {
-		return sortOrder;
-	}
-
-	public void setSortOrder(SortOrder sortOrder) {
-		this.sortOrder = sortOrder;
-	}
-	
-	public boolean equals(Object obj) {
-	
-		if(!(obj instanceof ScrollableGridRange)){
-			return super.equals(obj);
-		}
-		
-		ScrollableGridRange ref = (ScrollableGridRange)obj;
-		
-		boolean ret = (this.first == ref.first)&&(this.last == ref.last );
-		
-		if(this.sortOrder != null){
-			ret = ret && this.sortOrder.equals(ref.sortOrder);  
-		} else {
-			ret = (ret && (ref.sortOrder == null));
-		}
-				
-		return ret;
-	}
-	
-	public int hashCode() {
-		return super.hashCode();
-	}
-}

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/model/SortField.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/model/SortField.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,89 +0,0 @@
-/**
- * 
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SortField implements Serializable{
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
-	private String name = null;
-	private int index = -1;
-	private Boolean ascending = null;
-	
-	
-	
-	public SortField(String name, int index, Boolean ascending) {
-		super();
-		this.name = name;
-		this.index = index;
-		this.ascending = ascending;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public int getIndex() {
-		return index;
-	}
-
-	public void setIndex(int index) {
-		this.index = index;
-	}
-
-	public Boolean getAscending() {
-		return ascending;
-	}
-
-	public void setAscending(Boolean ascending) {
-		this.ascending = ascending;
-	}
-
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((ascending == null) ? 0 : ascending.hashCode());
-		result = prime * result + index;
-		result = prime * result + ((name == null) ? 0 : name.hashCode());
-		return result;
-	}
-
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		final SortField other = (SortField) obj;
-		if (ascending == null) {
-			if (other.ascending != null)
-				return false;
-		} else if (!ascending.equals(other.ascending))
-			return false;
-		if (index != other.index)
-			return false;
-		if (name == null) {
-			if (other.name != null)
-				return false;
-		} else if (!name.equals(other.name))
-			return false;
-		return true;
-	}
-
-	
-	
-}

Deleted: trunk/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java
===================================================================
--- trunk/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,70 +0,0 @@
-package org.richfaces.model;
-
-import java.io.Serializable;
-import java.util.Arrays;
-/**
- *
- * @author Maksim Kaszynski
- * 
- *
- */
-public class SortOrder implements Serializable {
-
-	private static int hashCode(Object[] array) {
-		final int prime = 31;
-		if (array == null)
-			return 0;
-		int result = 1;
-		for (int index = 0; index < array.length; index++) {
-			result = prime * result
-					+ (array[index] == null ? 0 : array[index].hashCode());
-		}
-		return result;
-	}
-
-	private static final long serialVersionUID = 2423450561570551363L;
-
-	private SortField [] fields;
-
-	public SortOrder() {
-		
-	}
-	
-	public SortOrder(SortField[] fields) {
-		super();
-		this.fields = fields;
-	}
-
-
-
-	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;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		final SortOrder other = (SortOrder) obj;
-		if (!Arrays.equals(fields, other.fields))
-			return false;
-		return true;
-	}
-
-	
-	
-}
\ No newline at end of file

Modified: trunk/sandbox/samples/pom.xml
===================================================================
--- trunk/sandbox/samples/pom.xml	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/samples/pom.xml	2007-08-06 13:44:50 UTC (rev 2074)
@@ -13,7 +13,6 @@
 	<name>RichFaces Sandbox Components Examples</name>
   <modules>
 
-    <module>scrollable-grid-demo</module>
     <module>panel2-sample</module>
     <module>simpleTogglePanel2-sample</module>
   </modules>

Modified: trunk/sandbox/ui/pom.xml
===================================================================
--- trunk/sandbox/ui/pom.xml	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/sandbox/ui/pom.xml	2007-08-06 13:44:50 UTC (rev 2074)
@@ -13,7 +13,6 @@
 	<name>Richfaces Sandbox UI</name>
 	<modules>
 		<module>panel2</module>
-		<module>scrollable-grid</module>
 		<module>simpleTogglePanel2</module>
 	</modules>
 </project>
\ No newline at end of file

Modified: trunk/ui/pom.xml
===================================================================
--- trunk/ui/pom.xml	2007-08-06 13:07:23 UTC (rev 2073)
+++ trunk/ui/pom.xml	2007-08-06 13:44:50 UTC (rev 2074)
@@ -84,6 +84,7 @@
 		<module>calendar</module>
 		<module>treeModel</module>
 		<module>message</module>
+		<module>scrollable-grid</module>
 	</modules>
 	<dependencies>
 		<dependency>

Copied: trunk/ui/scrollable-grid (from rev 2069, trunk/sandbox/ui/scrollable-grid)

Modified: trunk/ui/scrollable-grid/pom.xml
===================================================================
--- trunk/sandbox/ui/scrollable-grid/pom.xml	2007-08-06 10:39:16 UTC (rev 2069)
+++ trunk/ui/scrollable-grid/pom.xml	2007-08-06 13:44:50 UTC (rev 2074)
@@ -1,11 +1,11 @@
 <?xml version="1.0"?><project>
   <parent>
     <artifactId>ui</artifactId>
-    <groupId>org.richfaces.sandbox</groupId>
+    <groupId>org.richfaces</groupId>
     <version>3.1.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <groupId>org.richfaces.sandbox.ui</groupId>
+  <groupId>org.richfaces.ui</groupId>
   <artifactId>scrollable-grid</artifactId>
     <version>3.1.0-SNAPSHOT</version>
   <name>Scrollable Grid</name>
@@ -67,15 +67,5 @@
       <artifactId>richfaces-impl</artifactId>
       <version>3.1.0-SNAPSHOT</version>
     </dependency>
-    <dependency>
-      <groupId>org.richfaces.framework</groupId>
-      <artifactId>richfaces-impl</artifactId>
-      <version>3.1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.richfaces.sandbox</groupId>
-      <artifactId>richfaces-sandbox-impl</artifactId>
-      <version>3.1.0-SNAPSHOT</version>
-    </dependency>
   </dependencies>
 </project>
\ No newline at end of file




More information about the richfaces-svn-commits mailing list