diff options
| author | Dirk Fauth | 2022-11-07 09:24:01 +0000 |
|---|---|---|
| committer | Dirk Fauth | 2022-11-07 09:24:01 +0000 |
| commit | 60745539c48acaac8472a59e752370b6a6b5a904 (patch) | |
| tree | d10f462fb7ac96115106d7dc0376c4f91fd2a257 | |
| parent | 687b1ddb67f9e7067f43c8ede2088e5302a158a9 (diff) | |
| download | org.eclipse.nebula.widgets.nattable-60745539c48acaac8472a59e752370b6a6b5a904.tar.gz org.eclipse.nebula.widgets.nattable-60745539c48acaac8472a59e752370b6a6b5a904.tar.xz org.eclipse.nebula.widgets.nattable-60745539c48acaac8472a59e752370b6a6b5a904.zip | |
Bug 580995 - selectAll in FilterNatCombo selects also filtered items
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Change-Id: Ic4190967f5d669b70ac3f7a016f715063732041a
| -rw-r--r-- | org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java index 36427dfd..8fb0fed4 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2020 Dirk Fauth and others. + * Copyright (c) 2013, 2022 Dirk Fauth and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -355,7 +355,14 @@ public class FilterNatCombo extends NatCombo { }); this.selectAllItemViewer.addCheckStateListener(event -> { - if (event.getChecked()) { + boolean performCheck = event.getChecked(); + if (!performCheck && (getSelectionCount() < FilterNatCombo.this.itemList.size())) { + // checked but grayed, so not all items selected + // treat it as if the action is to select all + performCheck = true; + } + + if (performCheck) { // select all FilterNatCombo.this.dropdownTable.selectAll(); } else { @@ -366,18 +373,20 @@ public class FilterNatCombo extends NatCombo { // after selection is performed we need to ensure that // selection and checkboxes are in sync for (TableItem tableItem : FilterNatCombo.this.dropdownTable.getItems()) { - tableItem.setChecked( - FilterNatCombo.this.dropdownTable.isSelected( - FilterNatCombo.this.itemList.indexOf(tableItem.getText()))); + tableItem.setChecked(performCheck); } // sync the selectionStateMap based on the state of the select // all checkbox - for (String item : FilterNatCombo.this.itemList) { - FilterNatCombo.this.selectionStateMap.put(item, event.getChecked()); + for (TableItem tableItem : FilterNatCombo.this.dropdownTable.getItems()) { + // for (String item : FilterNatCombo.this.itemList) { + FilterNatCombo.this.selectionStateMap.put(tableItem.getText(), performCheck); } updateTextControl(!FilterNatCombo.this.multiselect); + // also refresh the selectAllItemViewer to show a potential grayed + // checked state in case of an active filter + this.selectAllItemViewer.refresh(); }); for (ICheckStateListener l : this.checkStateListener) { |
