summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-04-24 13:17:35 +0300
committerVaadin Code Review <review@vaadin.com>2013-04-24 10:49:12 +0000
commit31cc212c35b4817d1f067093f9305877fd14cf37 (patch)
treecfc51ff9ea530f0744ef324e4671e62cc4b2eda8 /server
parent4a6ed040c7c09ae61f1e3f751c0f1372610bfbc9 (diff)
downloadvaadin-framework-31cc212c35b4817d1f067093f9305877fd14cf37.tar.gz
vaadin-framework-31cc212c35b4817d1f067093f9305877fd14cf37.zip
Replaced Filterable.hasContainerFilters with getContainerFilters (#11234)
Change-Id: Ie0b05e55c1d8fc8d10d073c508b112da740c3333
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/data/Container.java7
-rw-r--r--server/src/com/vaadin/data/util/AbstractBeanContainer.java15
-rw-r--r--server/src/com/vaadin/data/util/AbstractInMemoryContainer.java16
-rw-r--r--server/src/com/vaadin/data/util/IndexedContainer.java14
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java19
-rw-r--r--server/src/com/vaadin/ui/Tree.java4
-rw-r--r--server/tests/src/com/vaadin/data/util/AbstractContainerTest.java18
7 files changed, 76 insertions, 17 deletions
diff --git a/server/src/com/vaadin/data/Container.java b/server/src/com/vaadin/data/Container.java
index 4db346a015..e93db52a35 100644
--- a/server/src/com/vaadin/data/Container.java
+++ b/server/src/com/vaadin/data/Container.java
@@ -954,11 +954,14 @@ public interface Container extends Serializable {
public void removeAllContainerFilters();
/**
- * Returns true if any filters have been applied to the container
+ * Returns the filters which have been applied to the container
*
+ * @return A collection of filters which have been applied to the
+ * container. An empty collection if no filters have been
+ * applied.
* @since 7.1
*/
- public boolean hasContainerFilters();
+ public Collection<Filter> getContainerFilters();
}
/**
diff --git a/server/src/com/vaadin/data/util/AbstractBeanContainer.java b/server/src/com/vaadin/data/util/AbstractBeanContainer.java
index c587cf5163..35403d6419 100644
--- a/server/src/com/vaadin/data/util/AbstractBeanContainer.java
+++ b/server/src/com/vaadin/data/util/AbstractBeanContainer.java
@@ -385,11 +385,26 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
removeFilter(filter);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.util.AbstractInMemoryContainer#hasContainerFilters()
+ */
@Override
public boolean hasContainerFilters() {
return super.hasContainerFilters();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters()
+ */
+ @Override
+ public Collection<Filter> getContainerFilters() {
+ return super.getContainerFilters();
+ }
+
/**
* Make this container listen to the given property provided it notifies
* when its value changes.
diff --git a/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java b/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java
index 940f2302f5..84304431bc 100644
--- a/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java
+++ b/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java
@@ -501,12 +501,22 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
}
/**
- * Checks if the container has filters
+ * Returns true if any filters have been applied to the container.
*
- * @return Returns true if the container has container filters applied
+ * @return true if the container has filters applied, false otherwise
+ * @since 7.1
*/
protected boolean hasContainerFilters() {
- return !getFilters().isEmpty();
+ return !getContainerFilters().isEmpty();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container.Filterable#getContainerFilters()
+ */
+ protected Collection<Filter> getContainerFilters() {
+ return Collections.unmodifiableCollection(filters);
}
/**
diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java
index 31f37ac277..d7bf70caf6 100644
--- a/server/src/com/vaadin/data/util/IndexedContainer.java
+++ b/server/src/com/vaadin/data/util/IndexedContainer.java
@@ -1192,9 +1192,23 @@ public class IndexedContainer extends
removeFilter(filter);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters()
+ */
@Override
public boolean hasContainerFilters() {
return super.hasContainerFilters();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters()
+ */
+ @Override
+ public Collection<Filter> getContainerFilters() {
+ return super.getContainerFilters();
+ }
}
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
index f8efdf0d4f..987466cdb7 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
@@ -597,11 +597,23 @@ public class SQLContainer implements Container, Container.Filterable,
}
/**
- * {@inheritDoc}
+ * Returns true if any filters have been applied to the container.
+ *
+ * @return true if the container has filters applied, false otherwise
+ * @since 7.1
*/
- @Override
public boolean hasContainerFilters() {
- return !filters.isEmpty();
+ return !getContainerFilters().isEmpty();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container.Filterable#getContainerFilters()
+ */
+ @Override
+ public Collection<Filter> getContainerFilters() {
+ return Collections.unmodifiableCollection(filters);
}
/**********************************************/
@@ -1825,4 +1837,5 @@ public class SQLContainer implements Container, Container.Filterable,
private static final Logger getLogger() {
return Logger.getLogger(SQLContainer.class.getName());
}
+
}
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java
index a5c3819edd..15175b5a8b 100644
--- a/server/src/com/vaadin/ui/Tree.java
+++ b/server/src/com/vaadin/ui/Tree.java
@@ -939,8 +939,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
com.vaadin.data.Container.ItemSetChangeEvent event) {
super.containerItemSetChange(event);
if (getContainerDataSource() instanceof Filterable) {
- boolean hasFilters = ((Filterable) getContainerDataSource())
- .hasContainerFilters();
+ boolean hasFilters = !((Filterable) getContainerDataSource())
+ .getContainerFilters().isEmpty();
if (!hasFilters) {
/*
* If Container is not filtered then the itemsetchange is caused
diff --git a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java
index 64db805623..81c90ba07b 100644
--- a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java
+++ b/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java
@@ -314,10 +314,12 @@ public abstract class AbstractContainerTest extends TestCase {
initializeContainer(container);
// Filter by "contains ab"
- container.addContainerFilter(new SimpleStringFilter(
- FULLY_QUALIFIED_NAME, "ab", false, false));
+ SimpleStringFilter filter1 = new SimpleStringFilter(
+ FULLY_QUALIFIED_NAME, "ab", false, false);
+ container.addContainerFilter(filter1);
- assertTrue(container.hasContainerFilters());
+ assertTrue(container.getContainerFilters().size() == 1);
+ assertEquals(filter1, container.getContainerFilters().iterator().next());
validateContainer(container, "com.vaadin.data.BufferedValidatable",
"com.vaadin.ui.TabSheet",
@@ -327,12 +329,14 @@ public abstract class AbstractContainerTest extends TestCase {
// Filter by "contains da" (reversed as ad here)
container.removeAllContainerFilters();
- assertFalse(container.hasContainerFilters());
+ assertTrue(container.getContainerFilters().isEmpty());
- container.addContainerFilter(new SimpleStringFilter(
- REVERSE_FULLY_QUALIFIED_NAME, "ad", false, false));
+ SimpleStringFilter filter2 = new SimpleStringFilter(
+ REVERSE_FULLY_QUALIFIED_NAME, "ad", false, false);
+ container.addContainerFilter(filter2);
- assertTrue(container.hasContainerFilters());
+ assertTrue(container.getContainerFilters().size() == 1);
+ assertEquals(filter2, container.getContainerFilters().iterator().next());
validateContainer(container, "com.vaadin.data.Buffered",
"com.vaadin.server.ComponentSizeValidator",