Author: konstantin.mishin
Date: 2008-04-10 08:41:56 -0400 (Thu, 10 Apr 2008)
New Revision: 7732
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
Log:
RF-2037
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2008-04-10
12:04:30 UTC (rev 7731)
+++
trunk/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2008-04-10
12:41:56 UTC (rev 7732)
@@ -3,6 +3,7 @@
*/
package org.richfaces.model.selection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -17,27 +18,39 @@
private Set<Object> keys = new LinkedHashSet<Object>();
+ private boolean selectAll = false;
+
public boolean addKey(Object rowKey) {
return keys.add(rowKey);
}
public boolean removeKey(Object rowKey) {
+ selectAll = false;
return keys.remove(rowKey);
}
public Iterator<Object> getKeys() {
- return keys.iterator();
+ Iterator<Object> result = Collections.emptyList().iterator();;
+ if (!selectAll) {
+ result = keys.iterator();
+ }
+ return result;
}
public int size() {
- return keys.size();
+ int result = -1;
+ if (!selectAll) {
+ result = keys.size();
+ }
+ return result;
}
public boolean isSelected(Object rowKey) {
- return keys.contains(rowKey);
+ return selectAll || keys.contains(rowKey);
}
public void clear() {
+ selectAll = false;
keys.clear();
}
@@ -45,6 +58,7 @@
final int prime = 31;
int result = 1;
result = prime * result + ((keys == null) ? 0 : keys.hashCode());
+ result = prime * result + (selectAll ? 1231 : 1237);
return result;
}
@@ -55,14 +69,20 @@
return false;
if (getClass() != obj.getClass())
return false;
- final SimpleSelection other = (SimpleSelection) obj;
+ SimpleSelection other = (SimpleSelection) obj;
if (keys == null) {
if (other.keys != null)
return false;
} else if (!keys.equals(other.keys))
return false;
+ if (selectAll != other.selectAll)
+ return false;
return true;
}
+
+ public void setSelectAll(boolean selectAll) {
+ this.selectAll = selectAll;
+ }
}
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2008-04-10
12:04:30 UTC (rev 7731)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2008-04-10
12:41:56 UTC (rev 7732)
@@ -83,6 +83,7 @@
if (clientSelection.isReset() || clientSelection.isSelectAll()) {
simpleSelection.clear();
+ simpleSelection.setSelectAll(clientSelection.isSelectAll());
}
try {