aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/main/java/com/vaadin/data/util/GeneratedPropertyContainer.java16
-rw-r--r--server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerTest.java10
2 files changed, 24 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/data/util/GeneratedPropertyContainer.java b/server/src/main/java/com/vaadin/data/util/GeneratedPropertyContainer.java
index ca33f8098d..f7ea0f91e7 100644
--- a/server/src/main/java/com/vaadin/data/util/GeneratedPropertyContainer.java
+++ b/server/src/main/java/com/vaadin/data/util/GeneratedPropertyContainer.java
@@ -122,9 +122,11 @@ public class GeneratedPropertyContainer extends AbstractContainer implements
}
/**
- * Item implementation for generated properties.
+ * Item implementation for generated properties, used to wrap the Item that
+ * belongs to the wrapped container. To reach that Item use
+ * {@link #getWrappedItem()}
*/
- protected class GeneratedPropertyItem implements Item {
+ public class GeneratedPropertyItem implements Item {
private Item wrappedItem;
private Object itemId;
@@ -198,6 +200,16 @@ public class GeneratedPropertyContainer extends AbstractContainer implements
private GeneratedPropertyContainer getContainer() {
return GeneratedPropertyContainer.this;
}
+
+ /**
+ * Returns the wrapped Item that belongs to the wrapped container
+ *
+ * @return wrapped item.
+ * @since
+ */
+ public Item getWrappedItem() {
+ return wrappedItem;
+ }
};
/**
diff --git a/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerTest.java b/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerTest.java
index bfa77eab52..b08437a953 100644
--- a/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerTest.java
+++ b/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerTest.java
@@ -31,6 +31,7 @@ import com.vaadin.data.Container.PropertySetChangeEvent;
import com.vaadin.data.Container.PropertySetChangeListener;
import com.vaadin.data.Item;
import com.vaadin.data.sort.SortOrder;
+import com.vaadin.data.util.GeneratedPropertyContainer.GeneratedPropertyItem;
import com.vaadin.data.util.filter.Compare;
import com.vaadin.data.util.filter.UnsupportedFilterException;
@@ -285,6 +286,15 @@ public class GeneratedPropertyContainerTest {
.getContainerPropertyIds().contains("foo"));
}
+ @Test
+ public void testGetWrappedItem() {
+ Object itemId = wrappedContainer.getItemIds().iterator().next();
+ Item wrappedItem = wrappedContainer.getItem(itemId);
+ GeneratedPropertyItem generatedPropertyItem = (GeneratedPropertyItem) container
+ .getItem(itemId);
+ assertEquals(wrappedItem, generatedPropertyItem.getWrappedItem());
+ }
+
private Indexed createContainer() {
wrappedContainer = new IndexedContainer();
wrappedContainer.addContainerProperty("foo", String.class, "foo");