Bug 572635 - ComboBoxes with single select and checkboxes do not work
reliably
Change-Id: I0b3d17da2695ca212618ccf17482bb50e9e5e6e8
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java
index 3f95b98..3e05d90 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2020 Original authors and others.
+ * Copyright (c) 2012, 2021 Original authors and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -657,28 +657,33 @@
// table index which may not match the index in the itemList
int itemTableIndex = NatCombo.this.dropdownTable.indexOf(chosenItem);
- // This case handles check actions
if (!selected) {
+ // handle checkbox interactions
+
+ if (!NatCombo.this.multiselect) {
+ // on single select first set all states to false
+ NatCombo.this.itemList.forEach(item -> NatCombo.this.selectionStateMap.put(item, Boolean.FALSE));
+ }
if (!chosenItem.getChecked()) {
NatCombo.this.selectionStateMap.put(chosenItem.getText(), Boolean.FALSE);
} else {
NatCombo.this.selectionStateMap.put(chosenItem.getText(), Boolean.TRUE);
}
- } else if (!NatCombo.this.useCheckbox) {
- if (NatCombo.this.multiselect && isCtrlPressed) {
+ } else {
+ // handle item interactions
+
+ if (!NatCombo.this.multiselect || (!NatCombo.this.useCheckbox && !isCtrlPressed)) {
+ // A single item was selected. Clear all previous state
+ NatCombo.this.itemList.forEach(item -> NatCombo.this.selectionStateMap.put(item, Boolean.FALSE));
+
+ // Set the state for the selected item
+ NatCombo.this.selectionStateMap.put(chosenItem.getText(), Boolean.TRUE);
+ } else if (NatCombo.this.multiselect && isCtrlPressed) {
boolean isSelected = NatCombo.this.dropdownTable.isSelected(itemTableIndex);
NatCombo.this.selectionStateMap.put(chosenItem.getText(), isSelected);
if (NatCombo.this.useCheckbox) {
chosenItem.setChecked(isSelected);
}
- } else {
- // A single item was selected. Clear all previous state
- for (String item : NatCombo.this.itemList) {
- NatCombo.this.selectionStateMap.put(item, Boolean.FALSE);
- }
-
- // Set the state for the selected item
- NatCombo.this.selectionStateMap.put(chosenItem.getText(), Boolean.TRUE);
}
}
@@ -1063,7 +1068,7 @@
}
this.text.setText(textValue);
- if (this.multiselect) {
+ if (this.multiselect && this.freeEdit) {
this.text.setSelection(textValue.length() - this.multiselectTextSuffix.length());
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/pom.xml b/org.eclipse.nebula.widgets.nattable.extension.e4/pom.xml
index 61aa0e2..f9b9a96 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/pom.xml
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/pom.xml
@@ -43,11 +43,16 @@
<artifactId>org.eclipse.e4.core.di.annotations</artifactId>
<version>1.6.400</version>
</dependency>
+
+ <!-- temporarily disabled because of incorrect dependency information in Maven Central -->
+ <!--
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.e4.ui.workbench</artifactId>
<version>1.10.100</version>
</dependency>
+ -->
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>