Author: abelevich
Date: 2007-05-24 14:35:53 -0400 (Thu, 24 May 2007)
New Revision: 876
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java
Log:
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java 2007-05-24
18:35:53 UTC (rev 876)
@@ -0,0 +1,75 @@
+/*
+ * 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/DataRange.java,v
$
+ * $Revision: 1.5 $
+ */
+
+package org.richfaces.model;
+
+
+/**
+ * Data window wrapper.
+ * Instance should be able to access any object within current data window.
+ * Subclasses can be built around any data source, (e.g. ResultSet, ScrollableResult or
simple List).
+ *
+ *
+ * @author Maksim Kaszynski
+ */
+public abstract class DataRange {
+ private SortOrder sortOrder;
+ private int startRow;
+ private int endRow;
+
+ /**
+ * Construct a DataRange object.
+ * @param startRow
+ * @param endRow
+ * @param sortOrder
+ */
+ public DataRange(int startRow, int endRow, SortOrder sortOrder) {
+ super();
+ this.sortOrder = sortOrder;
+ this.startRow = startRow;
+ this.endRow = endRow;
+ }
+ /**
+ * @return the endRow
+ */
+ public int getEndRow() {
+ return endRow;
+ }
+ /**
+ * @return the sortOrder
+ */
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+ /**
+ * @return the startRow
+ */
+ public int getStartRow() {
+ return startRow;
+ }
+
+ /**
+ * test if specified absolute index lies within this data range
+ * @param index
+ * @return
+ */
+ public boolean hit(int index) {
+ return index >= startRow && index < endRow;
+ }
+
+ /**
+ * Implementations should define this method to get object at given absolute position.
+ *
+ * @param index - absolute index of record within entire recordset, NOT relative to the
start of data range.
+ * @return object at given position within whole recordset.
+ */
+ public abstract Object getRowData(int index);
+
+}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java 2007-05-24
18:35:53 UTC (rev 876)
@@ -0,0 +1,28 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import org.ajax4jsf.ajax.repeat.Range;
+
+/**
+ * @author maksim
+ *
+ */
+public abstract class GridRange implements Range {
+
+ private SortOrder sortOrder;
+
+ public abstract IterationBounds getIterationBounds(int rowCount);
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+
+
+}
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java 2007-05-24
18:35:53 UTC (rev 876)
@@ -0,0 +1,63 @@
+/*
+ * 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/IterationBounds.java,v
$
+ * $Revision: 1.3 $
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+public class IterationBounds implements Serializable {
+
+ public interface RowVisitor {
+ public void visit(int rowIndex);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ private int startRow;
+ private int endRow;
+
+ public IterationBounds() {
+ }
+ public IterationBounds(int startRow, int endRow) {
+ super();
+ this.startRow = startRow;
+ this.endRow = endRow;
+ }
+
+ public boolean within(int i) {
+ return i >= startRow && i < endRow;
+ }
+
+ public void iterate(RowVisitor rowVisitor) {
+ for (int i = startRow; i < endRow; i++) {
+ rowVisitor.visit(i);
+ }
+ }
+
+ public int size() {
+ return endRow - startRow;
+ }
+
+ public int getEndRow() {
+ return endRow;
+ }
+
+ public int getStartRow() {
+ return startRow;
+ }
+ /**
+ * @see java.lang.Object#toString()
+ */
+
+ public String toString() {
+ // TODO Auto-generated method stub
+ return "[" + startRow + "," + endRow + "]";
+ }
+}
\ No newline at end of file
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java 2007-05-24
18:35:20 UTC (rev 875)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java 2007-05-24
18:35:53 UTC (rev 876)
@@ -11,6 +11,9 @@
public class ScrollableGridDataModel extends SequenceDataModel{
+ private SortOrder sortOrder;
+
+
public ScrollableGridDataModel(DataModel model) {
super(model);
}
@@ -19,4 +22,12 @@
super.walk(context, visitor, range, argument);
}
+
+ public SortOrder getSortOrder(){
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder){
+ this.sortOrder = sortOrder;
+ }
}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java 2007-05-24
18:35:53 UTC (rev 876)
@@ -0,0 +1,65 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+/**
+ * @author maksim
+ *
+ */
+public class SequenceRange extends GridRange {
+
+ private int start;
+ private int end;
+
+ public SequenceRange(int start, int end) {
+ super();
+ this.start = start;
+ this.end = end;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public void setStart(int start) {
+ this.start = start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ public void setEnd(int end) {
+ this.end = end;
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.jsf.model.GridRange#getIterationBounds(int)
+ */
+ public IterationBounds getIterationBounds(int rowCount) {
+ int a = start, b = end;
+
+ if (start > rowCount) {
+ a = rowCount;
+ }
+
+ if (end > rowCount) {
+ b = rowCount;
+ }
+ if (b < 0) {
+ b = rowCount;
+ }
+
+ if (a > b) {
+ int c = a;
+
+ a = b;
+ b = c;
+ }
+
+
+ return new IterationBounds(a,b);
+ }
+
+}
Show replies by date