diff options
| author | Dirk Fauth | 2023-01-12 08:07:30 +0000 |
|---|---|---|
| committer | Dirk Fauth | 2023-01-12 08:07:30 +0000 |
| commit | 2289a66815d36f20dc8668edd8f6d7ad5bac494b (patch) | |
| tree | fb41a1bf82d66f5dd86a7af483365a008bf1828f | |
| parent | c6cbcc598e0b349573fb3d26a1a6015f6bbde6dc (diff) | |
| download | org.eclipse.nebula.widgets.nattable-2289a66815d36f20dc8668edd8f6d7ad5bac494b.tar.gz org.eclipse.nebula.widgets.nattable-2289a66815d36f20dc8668edd8f6d7ad5bac494b.tar.xz org.eclipse.nebula.widgets.nattable-2289a66815d36f20dc8668edd8f6d7ad5bac494b.zip | |
Bug 581333 - [Mixed Filter Row] issues with column grouping
Fixed issues in combination with column grouping and cases when no
combobox filter editor is used.
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Change-Id: I8482ea70b262fe71c39be7c1d5f8a9122a71c93f
2 files changed, 49 insertions, 22 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java index 54038f35..6cd3270a 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java @@ -727,28 +727,33 @@ public class ComboBoxFilterRowHeaderComposite<T> extends CompositeLayer implemen @Override public Object getDataValueByPosition(int compositeColumnPosition, int compositeRowPosition) { - Object filterValue = super.getDataValueByPosition(compositeColumnPosition, compositeRowPosition); - - // The SELECT_ALL_ITEMS_VALUE is set to the FilterRowDataProvider by - // setAllValueSelected(). It is actually ignored in the - // ComboBoxGlazedListsFilterStrategy as it technically means "no filter" - // and results in having all entries checked in the - // FilterRowComboBoxCellEditor. For other filter editors this - // replacement is not done and causes incorrect visualization as it - // shows the value and implies an active filter. As the - // SELECT_ALL_ITEMS_VALUE is propagated in the constructor at a time - // where the editors are not yet configured, we remove the value - // reactively on accessing it for a consistent view. - - int columnIndex = getColumnIndexByPosition(compositeColumnPosition); - if (compositeRowPosition == 1 - && !isFilterRowComboBoxCellEditor(compositeColumnPosition) - && EditConstants.SELECT_ALL_ITEMS_VALUE.equals(filterValue)) { - this.filterRowDataLayer.getFilterRowDataProvider().getFilterIndexToObjectMap().remove(columnIndex); - filterValue = null; + // special handling only if the filter row is visible and the value of + // the filter row is requested + if (this.filterRowVisible && compositeRowPosition == getRowCount() - 1) { + Object filterValue = super.getDataValueByPosition(compositeColumnPosition, compositeRowPosition); + + // The SELECT_ALL_ITEMS_VALUE is set to the FilterRowDataProvider by + // setAllValueSelected(). It is actually ignored in the + // ComboBoxGlazedListsFilterStrategy as it technically means "no + // filter" and results in having all entries checked in the + // FilterRowComboBoxCellEditor. For other filter editors this + // replacement is not done and causes incorrect visualization as it + // shows the value and implies an active filter. As the + // SELECT_ALL_ITEMS_VALUE is propagated in the constructor at a time + // where the editors are not yet configured, we remove the value + // reactively on accessing it for a consistent view. + + int columnIndex = getColumnIndexByPosition(compositeColumnPosition); + if (!isFilterRowComboBoxCellEditor(compositeColumnPosition) + && EditConstants.SELECT_ALL_ITEMS_VALUE.equals(filterValue)) { + this.filterRowDataLayer.getFilterRowDataProvider().getFilterIndexToObjectMap().remove(columnIndex); + filterValue = null; + } + + return filterValue; } - return filterValue; + return super.getDataValueByPosition(compositeColumnPosition, compositeRowPosition); } private boolean isFilterRowComboBoxCellEditor(int columnPosition) { diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java index 1e87c888..51d3aab8 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2022 Dirk Fauth and others. + * Copyright (c) 2013, 2023 Dirk Fauth and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -127,7 +127,7 @@ public class ComboBoxGlazedListsFilterStrategy<T> extends DefaultGlazedListsStat @SuppressWarnings("rawtypes") @Override public void applyFilter(Map<Integer, Object> filterIndexToObjectMap) { - if (filterIndexToObjectMap.isEmpty()) { + if (filterIndexToObjectMap.isEmpty() && hasComboBoxFilterEditorRegistered()) { this.filterLock.writeLock().lock(); try { this.getMatcherEditor().getMatcherEditors().add(this.matchNone); @@ -255,4 +255,26 @@ public class ComboBoxGlazedListsFilterStrategy<T> extends DefaultGlazedListsStat return false; } + + /** + * Checks if at least one combobox cell editor is registered. Needed to the + * <i>matchNone</i> processing if the filter collection is empty. + * + * @return <code>true</code> if at least one combobox cell editor is + * registered, <code>false</code> if not. + * + * @since 2.1 + */ + protected boolean hasComboBoxFilterEditorRegistered() { + for (int i = 0; i < this.columnAccessor.getColumnCount(); i++) { + ICellEditor cellEditor = this.configRegistry.getConfigAttribute( + EditConfigAttributes.CELL_EDITOR, + DisplayMode.NORMAL, + FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + i, GridRegion.FILTER_ROW); + if (cellEditor instanceof FilterRowComboBoxCellEditor) { + return true; + } + } + return false; + } } |
