import java.io.Serializable;
import java.util.Collection;
+import com.vaadin.data.util.filter.SimpleStringFilter;
import com.vaadin.data.util.filter.UnsupportedFilterException;
/**
/**
* 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
* 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.
*
* 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);
/**
* Remove all filters from given property.
- *
- * @deprecated use {@link Filterable#removeContainerFilter(Filter)}
*/
- @Deprecated
public void removeContainerFilters(Object propertyId);
}
*
* <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.
*
*/
public void removeContainerFilter(Filter filter);
+ /**
+ * Remove all active filters from the container.
+ */
+ public void removeAllContainerFilters();
+
}
/**
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;
*/
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
*/
@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);
* <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>
* {@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
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 */
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
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
\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
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
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
\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
\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