public void runFiltersNow() { owner.setRefreshingEnabled(false); if (owner.getFilterable() != null && lastOnDemandFilter != null) { owner.getFilterable().removeContainerFilter(lastOnDemandFilter); lastOnDemandFilter = filters.isEmpty() ? null : new And(filtersArray); if (owner.getFilterable() != null && lastOnDemandFilter != null) { owner.getFilterable().addContainerFilter(lastOnDemandFilter);
@Override public void removeAllContainerFilters() { if (filterableContainer == null) { throw new UnsupportedOperationException( "Wrapped container is not filterable"); } filterableContainer.removeAllContainerFilters(); activeFilters.clear(); }
filterable.addContainerFilter(filter); filterable.removeContainerFilter(filter);
owner.getFilterable().removeContainerFilter(filters.get(propertyId)); owner.getFilterable().removeContainerFilter(lastOnDemandFilter);
@Override public void addContainerFilter(Filter filter) throws UnsupportedFilterException { if (filterableContainer == null) { throw new UnsupportedOperationException( "Wrapped container is not filterable"); } List<Filter> addedFilters = new ArrayList<Filter>(); for (Entry<?, PropertyValueGenerator<?>> entry : propertyGenerators .entrySet()) { Object property = entry.getKey(); if (filter.appliesToProperty(property)) { // Have generated property modify filter to fit the original // data in the container. Filter modifiedFilter = entry.getValue().modifyFilter(filter); filterableContainer.addContainerFilter(modifiedFilter); // Keep track of added filters addedFilters.add(modifiedFilter); } } if (addedFilters.isEmpty()) { // No generated property modified this filter, use it as is addedFilters.add(filter); filterableContainer.addContainerFilter(filter); } // Map filter to actually added filters activeFilters.put(filter, addedFilters); }
void destroyFilterComponents() { owner.setRefreshingEnabled(false); /* Remove all filters from container */ for (Object propertyId : filters.keySet()) { if (owner.getFilterable() != null) { owner.getFilterable().removeContainerFilter(filters.get(propertyId)); } if (owner.getFilterGenerator() != null) { owner.getFilterGenerator().filterRemoved(propertyId); } } /* Remove listeners */ removeValueChangeListeners(); /* Clear the data related to filters */ customFields.clear(); filters.clear(); texts.clear(); enums.clear(); booleans.clear(); dates.clear(); numbers.clear(); /* also clear on-demand data */ if (owner.getFilterable() != null) { owner.getFilterable().removeContainerFilter(lastOnDemandFilter); } owner.setRefreshingEnabled(true); }
@Override public void containerItemSetChange(Container.ItemSetChangeEvent event) { super.containerItemSetChange(event); if (getContainerDataSource() instanceof Filterable) { boolean hasFilters = !((Filterable) getContainerDataSource()) .getContainerFilters().isEmpty(); if (!hasFilters) { /* * If Container is not filtered then the itemsetchange is caused * by either adding or removing items to the container. To * prevent a memory leak we should cleanup the expanded list * from items which was removed. * * However, there will still be a leak if the container is * filtered to show only a subset of the items in the tree and * later unfiltered items are removed from the container. In * that case references to the unfiltered item ids will remain * in the expanded list until the Tree instance is removed and * the list is destroyed, or the container data source is * replaced/updated. To force the removal of the removed items * the application developer needs to a) remove the container * filters temporarly or b) re-apply the container datasource * using setContainerDataSource(getContainerDataSource()) */ cleanupExpandedItems(); } } }
@Override public void removeContainerFilter(Filter filter) { container.removeContainerFilter(filter); }
@Override public void addContainerFilter(Filter filter) throws UnsupportedFilterException { container.addContainerFilter(filter); }
@Override public Collection<Filter> getContainerFilters() { return container.getContainerFilters(); }
@Override public void removeAllContainerFilters() { container.removeAllContainerFilters(); }
@Override public void removeContainerFilter(Filter filter) { if (filterableContainer == null) { throw new UnsupportedOperationException( "Wrapped container is not filterable"); } if (activeFilters.containsKey(filter)) { for (Filter f : activeFilters.get(filter)) { filterableContainer.removeContainerFilter(f); } activeFilters.remove(filter); } }
private void setFilter(Filter filter, Object propertyId) { if (owner.getFilterable() != null) { owner.getFilterable().addContainerFilter(filter); } filters.put(propertyId, filter); }
private void removeFilter(Object propertyId) { if (filters.get(propertyId) != null) { if (owner.getFilterable() != null) { owner.getFilterable().removeContainerFilter(filters.get(propertyId)); } filters.remove(propertyId); } }
@Override public void textChange(FieldEvents.TextChangeEvent event) { Container.Filterable f = (Container.Filterable) table.getContainerDataSource(); if (filter != null) { f.removeContainerFilter(filter); } filter = new SimpleStringFilter(i18n.translate("activationMonitor.activationLog.user.label"), event.getText(), true, false); f.addContainerFilter(filter); } });