Author: maksimkaszynski
Date: 2007-09-25 10:44:12 -0400 (Tue, 25 Sep 2007)
New Revision: 3107
Removed:
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/ClientSelection.java
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SelectionRange.java
branches/3.1.x/framework/impl/src/main/java/org/richfaces/model/selection/
branches/3.1.x/framework/impl/src/test/java/org/richfaces/model/selection/
Log:
fixed unit tests
Deleted:
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/ClientSelection.java
===================================================================
---
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-09-25
14:30:44 UTC (rev 3106)
+++
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-09-25
14:44:12 UTC (rev 3107)
@@ -1,129 +0,0 @@
-/**
- *
- */
-package org.richfaces.model.selection;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @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;
- }
- }
-}
Deleted:
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SelectionRange.java
===================================================================
---
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-09-25
14:30:44 UTC (rev 3106)
+++
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-09-25
14:44:12 UTC (rev 3107)
@@ -1,64 +0,0 @@
-/**
- *
- */
-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;
- }
-
-
-}
Show replies by date