summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Koskinen <anna@vaadin.com>2016-07-06 12:01:43 +0300
committerVaadin Code Review <review@vaadin.com>2016-07-06 12:31:41 +0000
commit38256a873cb92871de6f9a19288066a361a69954 (patch)
tree6f107b6c789e456a99ba58d2dce11fd9d7b207d8
parent9bb15290835800f5cf64ba536aaedf7ea35dd0ca (diff)
downloadvaadin-framework-38256a873cb92871de6f9a19288066a361a69954.tar.gz
vaadin-framework-38256a873cb92871de6f9a19288066a361a69954.zip
Allow reaching the wrapped Item through GeneratedPropertyItem (#20032)
Change-Id: Ic38c2803b3d83e76fa74d21490a4277c6037b950
-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");