aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/data/util/IndexedContainer.java
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2010-03-05 13:43:43 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2010-03-05 13:43:43 +0000
commit7cefe21c703e6e7822ba7456d45fa49a14dd067d (patch)
tree8891e28e97bce4f9db44dd7f50cbb6a844de8aef /src/com/vaadin/data/util/IndexedContainer.java
parent9b84a02d3f46d1f4dca4cc3b17c388d51ca5194a (diff)
parent2b1deeeced6d098a22d6e52b70e94dbb9e96df57 (diff)
downloadvaadin-framework-7cefe21c703e6e7822ba7456d45fa49a14dd067d.tar.gz
vaadin-framework-7cefe21c703e6e7822ba7456d45fa49a14dd067d.zip
merged changes from 6.3 + some container related changes
svn changeset:11664/svn branch:6.3_dd
Diffstat (limited to 'src/com/vaadin/data/util/IndexedContainer.java')
-rw-r--r--src/com/vaadin/data/util/IndexedContainer.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java
index d6d6d9e77c..3bac19cd7a 100644
--- a/src/com/vaadin/data/util/IndexedContainer.java
+++ b/src/com/vaadin/data/util/IndexedContainer.java
@@ -469,7 +469,13 @@ public class IndexedContainer implements Container.Indexed,
return null;
}
try {
- return itemIds.get(itemIds.indexOf(itemId) + 1);
+ int idx = itemIds.indexOf(itemId);
+ if (idx == -1) {
+ // If the given Item is not found in the Container,
+ // null is returned.
+ return null;
+ }
+ return itemIds.get(idx + 1);
} catch (final IndexOutOfBoundsException e) {
return null;
}
@@ -548,6 +554,11 @@ public class IndexedContainer implements Container.Indexed,
* java.lang.Object)
*/
public Item addItemAfter(Object previousItemId, Object newItemId) {
+ // Adding an item after null item adds the item as first item of the
+ // ordered container.
+ if (previousItemId == null) {
+ return addItemAt(0, newItemId);
+ }
// Get the index of the addition
int index = -1;
@@ -574,7 +585,11 @@ public class IndexedContainer implements Container.Indexed,
// Creates a new id
final Object id = generateId();
- return addItemAfter(previousItemId, id);
+ if (addItemAfter(previousItemId, id) != null) {
+ return id;
+ } else {
+ return null;
+ }
}
/*
@@ -953,7 +968,7 @@ public class IndexedContainer implements Container.Indexed,
* @param addedItemIndex
* index of new item if change event was an item addition
*/
- private void fireContentsChange(int addedItemIndex) {
+ protected void fireContentsChange(int addedItemIndex) {
if (itemSetChangeListeners != null) {
final Object[] l = itemSetChangeListeners.toArray();
final Container.ItemSetChangeEvent event = new IndexedContainer.ItemSetChangeEvent(
@@ -1549,7 +1564,7 @@ public class IndexedContainer implements Container.Indexed,
}
}
- private void updateContainerFiltering() {
+ protected void updateContainerFiltering() {
// Clearing filters?
if (filters == null || filters.isEmpty()) {
@@ -1571,7 +1586,7 @@ public class IndexedContainer implements Container.Indexed,
// Filter
for (final Iterator i = itemIds.iterator(); i.hasNext();) {
final Object id = i.next();
- if (passesFilters(new IndexedContainerItem(id))) {
+ if (passesFilters(id)) {
filteredItemIds.add(id);
}
}
@@ -1579,6 +1594,10 @@ public class IndexedContainer implements Container.Indexed,
fireContentsChange(-1);
}
+ protected final boolean passesFilters(Object itemId) {
+ return passesFilters(new IndexedContainerItem(itemId));
+ }
+
private boolean passesFilters(Item item) {
if (filters == null) {
return true;