]> source.dussan.org Git - vaadin-framework.git/commitdiff
#6286 Container filtering improvements: Filterable does not inherit SimpleFilterable
authorHenri Sara <henri.sara@itmill.com>
Mon, 21 Mar 2011 09:29:35 +0000 (09:29 +0000)
committerHenri Sara <henri.sara@itmill.com>
Mon, 21 Mar 2011 09:29:35 +0000 (09:29 +0000)
svn changeset:17854/svn branch:6.6

src/com/vaadin/data/Container.java
src/com/vaadin/data/util/AbstractBeanContainer.java
src/com/vaadin/data/util/AbstractInMemoryContainer.java
src/com/vaadin/data/util/IndexedContainer.java
tests/src/com/vaadin/tests/server/container/AbstractContainerTest.java
tests/src/com/vaadin/tests/tickets/Ticket1995.java

index 3e409c8485030bbde5f3aa22d37599eb56f2db19..6e9903d597a35da1f178309fdf285748e6ccebf0 100644 (file)
@@ -7,6 +7,7 @@ package com.vaadin.data;
 import java.io.Serializable;
 import java.util.Collection;
 
+import com.vaadin.data.util.filter.SimpleStringFilter;
 import com.vaadin.data.util.filter.UnsupportedFilterException;
 
 /**
@@ -691,7 +692,11 @@ public interface Container extends Serializable {
 
     /**
      * Interface that is implemented by containers which allow reducing their
-     * visible contents based on a set of filters.
+     * visible contents based on a set of filters. This interface has been
+     * renamed from {@link Filterable}, and implementing the new
+     * {@link Filterable} instead of or in addition to {@link SimpleFilterable}
+     * is recommended. This interface might be removed in future Vaadin
+     * versions.
      * <p>
      * When a set of filters are set, only items that match all the filters are
      * included in the visible contents of the container. Still new items that
@@ -717,16 +722,22 @@ public interface Container extends Serializable {
      * 0, at index {@link com.vaadin.data.Container#size()} or at an undefined
      * position is up to the implementation.
      * </p>
+     * <p>
+     * SimpleFilterable can be implemented using the {@link Filterable} API and
+     * {@link SimpleStringFilter}.
+     * </p>
      * 
      * @since 5.0
-     * @deprecated use {@link Filterable}
      */
-    @Deprecated
     public interface SimpleFilterable extends Container, Serializable {
 
         /**
          * Add a filter for given property.
          * 
+         * The API {@link Filterable#addContainerFilter(Filter)} is recommended
+         * instead of this method. A {@link SimpleStringFilter} can be used with
+         * the new API to implement the old string filtering functionality.
+         * 
          * Only items where given property for which toString() contains or
          * starts with given filterString are visible in the container.
          * 
@@ -742,10 +753,7 @@ public interface Container extends Serializable {
          *            strings.
          * @param onlyMatchPrefix
          *            Only match prefixes; no other matches are included.
-         * 
-         * @deprecated use {@link Filterable#addContainerFilter(Filter)}
          */
-        @Deprecated
         public void addContainerFilter(Object propertyId, String filterString,
                 boolean ignoreCase, boolean onlyMatchPrefix);
 
@@ -754,10 +762,7 @@ public interface Container extends Serializable {
 
         /**
          * Remove all filters from given property.
-         * 
-         * @deprecated use {@link Filterable#removeContainerFilter(Filter)}
          */
-        @Deprecated
         public void removeContainerFilters(Object propertyId);
     }
 
@@ -849,15 +854,12 @@ public interface Container extends Serializable {
      * 
      * <p>
      * This API replaces the old Filterable interface, renamed to
-     * {@link SimpleFilterable} in Vaadin 6.6. Currently this interface extends
-     * {@link SimpleFilterable} for backwards compatibility, but might not do so
-     * in future versions. <code>removeAllContainerFilters()</code> will remain
-     * a part of the API.
+     * {@link SimpleFilterable} in Vaadin 6.6.
      * </p>
      * 
      * @since 6.6
      */
-    public interface Filterable extends SimpleFilterable, Serializable {
+    public interface Filterable extends Container, Serializable {
         /**
          * Adds a filter for the container.
          * 
@@ -878,6 +880,11 @@ public interface Container extends Serializable {
          */
         public void removeContainerFilter(Filter filter);
 
+        /**
+         * Remove all active filters from the container.
+         */
+        public void removeAllContainerFilters();
+
     }
 
     /**
index f5bd83648580b3d1ec9e8b9d09d5c003b61d9ca4..fab61786d12972e3093d4929f96d9b0e4f98de05 100644 (file)
@@ -14,6 +14,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 import com.vaadin.data.Container.Filterable;
+import com.vaadin.data.Container.SimpleFilterable;
 import com.vaadin.data.Container.Sortable;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
@@ -53,7 +54,7 @@ import com.vaadin.data.util.filter.UnsupportedFilterException;
  */
 public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
         AbstractInMemoryContainer<IDTYPE, String, BeanItem<BEANTYPE>> implements
-        Filterable, Sortable, ValueChangeListener {
+        Filterable, SimpleFilterable, Sortable, ValueChangeListener {
 
     /**
      * Resolver that maps beans to their (item) identifiers, removing the need
@@ -290,6 +291,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
      */
     @Override
     public boolean removeItem(Object itemId) {
+        // TODO should also remove items that are filtered out
         int origSize = size();
         Item item = getItem(itemId);
         int position = indexOfId(itemId);
index 548f30f98427b458f64c3fbf8452928b65209cb3..79803ed7b7e8de4196d3824a06a9d0a3da7ddcd8 100644 (file)
@@ -37,8 +37,8 @@ import com.vaadin.data.util.filter.UnsupportedFilterException;
  * <ul>
  * <li> {@link Container.Ordered}
  * <li> {@link Container.Indexed}
- * <li> {@link Filterable} (internal implementation, does not implement the
- * interface directly)
+ * <li> {@link Filterable} and {@link SimpleFilterable} (internal implementation,
+ * does not implement the interface directly)
  * <li> {@link Sortable} (internal implementation, does not implement the
  * interface directly)
  * </ul>
@@ -48,11 +48,20 @@ import com.vaadin.data.util.filter.UnsupportedFilterException;
  * {@link #sortContainer(Object[], boolean[])} in the method
  * <code>sort(Object[], boolean[])</code>.
  * 
- * To implement Filterable, subclasses need to implement the methods
- * <code>addContainerFilter()</code> (calling {@link #addFilter(Filter)}),
- * <code>removeAllContainerFilters()</code> (calling {@link #removeAllFilters()}
- * ) and <code>removeContainerFilters(Object)</code> (calling
- * {@link #removeFilters(Object)}).
+ * To implement {@link Filterable}, subclasses need to implement the methods
+ * {@link Filterable#addContainerFilter(com.vaadin.data.Container.Filter)}
+ * (calling {@link #addFilter(Filter)}),
+ * {@link Filterable#removeAllContainerFilters()} (calling
+ * {@link #removeAllFilters()}) and
+ * {@link Filterable#removeContainerFilter(com.vaadin.data.Container.Filter)}
+ * (calling {@link #removeFilter(com.vaadin.data.Container.Filter)}).
+ * 
+ * To implement {@link SimpleFilterable}, subclasses also need to implement the
+ * methods
+ * {@link SimpleFilterable#addContainerFilter(Object, String, boolean, boolean)}
+ * and {@link SimpleFilterable#removeContainerFilters(Object)} calling
+ * {@link #addFilter(com.vaadin.data.Container.Filter)} and
+ * {@link #removeFilters(Object)} respectively.
  * 
  * @param <ITEMIDTYPE>
  *            the class of item identifiers in the container, use Object if can
index 78df8b2cc283daeb6bf9729ee5eda4f86ca5143d..11e4c702eddcf28a14a6958268d1ef5bf7283811 100644 (file)
@@ -52,7 +52,8 @@ import com.vaadin.data.util.filter.UnsupportedFilterException;
 public class IndexedContainer extends
         AbstractInMemoryContainer<Object, Object, Item> implements
         Container.PropertySetChangeNotifier, Property.ValueChangeNotifier,
-        Container.Sortable, Cloneable, Container.Filterable {
+        Container.Sortable, Cloneable, Container.Filterable,
+        Container.SimpleFilterable {
 
     /* Internal structure */
 
index dd34681c00b6a203d70a69ebadb1e9c2d28343b4..a83fcfc0f7def386b8e51dca22cdf01de9ba4abb 100644 (file)
@@ -12,6 +12,7 @@ import com.vaadin.data.Container.ItemSetChangeEvent;
 import com.vaadin.data.Container.ItemSetChangeListener;\r
 import com.vaadin.data.Container.Sortable;\r
 import com.vaadin.data.Item;\r
+import com.vaadin.data.util.filter.SimpleStringFilter;\r
 \r
 public abstract class AbstractContainerTest extends TestCase {\r
 \r
@@ -312,7 +313,8 @@ public abstract class AbstractContainerTest extends TestCase {
         initializeContainer(container);\r
 \r
         // Filter by "contains ab"\r
-        container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);\r
+        container.addContainerFilter(new SimpleStringFilter(\r
+                FULLY_QUALIFIED_NAME, "ab", false, false));\r
 \r
         validateContainer(container, "com.vaadin.data.BufferedValidatable",\r
                 "com.vaadin.ui.TabSheet",\r
@@ -321,8 +323,8 @@ public abstract class AbstractContainerTest extends TestCase {
 \r
         // Filter by "contains da" (reversed as ad here)\r
         container.removeAllContainerFilters();\r
-        container.addContainerFilter(REVERSE_FULLY_QUALIFIED_NAME, "ad", false,\r
-                false);\r
+        container.addContainerFilter(new SimpleStringFilter(\r
+                REVERSE_FULLY_QUALIFIED_NAME, "ad", false, false));\r
 \r
         validateContainer(container, "com.vaadin.data.Buffered",\r
                 "com.vaadin.terminal.gwt.server.ComponentSizeValidator",\r
@@ -347,7 +349,8 @@ public abstract class AbstractContainerTest extends TestCase {
         initializeContainer(sortable);\r
 \r
         // Filter by "contains ab"\r
-        filterable.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);\r
+        filterable.addContainerFilter(new SimpleStringFilter(\r
+                FULLY_QUALIFIED_NAME, "ab", false, false));\r
 \r
         // Must be able to sort based on PROP1 for this test\r
         assertTrue(sortable.getSortableContainerPropertyIds().contains(\r
index 93f16ca52774342a090c91cfc2746ca4b9831c54..c681cb5bd0643ddd52a663c76af2ac86cd113513 100644 (file)
@@ -4,6 +4,7 @@ import com.vaadin.Application;
 import com.vaadin.data.Container;\r
 import com.vaadin.data.Container.Filterable;\r
 import com.vaadin.data.Item;\r
+import com.vaadin.data.util.filter.SimpleStringFilter;\r
 import com.vaadin.ui.Button;\r
 import com.vaadin.ui.Button.ClickEvent;\r
 import com.vaadin.ui.Table;\r
@@ -30,7 +31,8 @@ public class Ticket1995 extends Application {
 \r
         Filterable filterable = (Container.Filterable) table\r
                 .getContainerDataSource();\r
-        filterable.addContainerFilter(PROPERTY_1, "Row", true, false);\r
+        filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",\r
+                true, false));\r
 \r
         table.setColumnHeader(PROPERTY_1, "Test (filter: Row)");\r
 \r
@@ -58,7 +60,8 @@ public class Ticket1995 extends Application {
 \r
         getMainWindow().showNotification("Tried to add item 'abc', " + res);\r
 \r
-        filterable.addContainerFilter(PROPERTY_1, "Row", true, false);\r
+        filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",\r
+                true, false));\r
 \r
     }\r
 }\r