Bug 582397 - [FilterRowComboBoxCellEditor] incorrect canonical values
equals check
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Change-Id: Id220fef3fd83d9735856ec185d410de86c473686
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxCellEditor.java
index f539fd8..f01358a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxCellEditor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxCellEditor.java
@@ -24,6 +24,7 @@
import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
+import org.eclipse.nebula.widgets.nattable.util.ObjectUtils;
import org.eclipse.nebula.widgets.nattable.widget.EditModeEnum;
import org.eclipse.nebula.widgets.nattable.widget.NatCombo;
import org.eclipse.swt.SWT;
@@ -253,11 +254,7 @@
if (!isClosed()) {
try {
Object canonicalValue = getCanonicalValue();
- if ((canonicalValue != null && this.currentCanonicalValue == null)
- || (canonicalValue == null && this.currentCanonicalValue != null)
- || (canonicalValue != null
- && this.currentCanonicalValue != null
- && !canonicalValue.equals(this.currentCanonicalValue))) {
+ if (!canonicalValuesEquals(canonicalValue)) {
if (super.commit(direction, closeAfterCommit)) {
this.currentCanonicalValue = canonicalValue;
@@ -292,6 +289,39 @@
return false;
}
+ @SuppressWarnings("rawtypes")
+ private boolean canonicalValuesEquals(Object canonicalValue) {
+ if (canonicalValue != null && this.currentCanonicalValue == null) {
+ return false;
+ }
+
+ if (canonicalValue == null && this.currentCanonicalValue != null) {
+ return false;
+ }
+
+ if (canonicalValue != null && this.currentCanonicalValue != null) {
+ if (canonicalValue instanceof Collection && !(this.currentCanonicalValue instanceof Collection)) {
+ return false;
+ }
+
+ if (!(canonicalValue instanceof Collection) && this.currentCanonicalValue instanceof Collection) {
+ return false;
+ }
+
+ if (canonicalValue instanceof Collection && this.currentCanonicalValue instanceof Collection) {
+ return ObjectUtils.collectionsEqual(
+ (Collection) canonicalValue,
+ (Collection) this.currentCanonicalValue);
+ } else {
+ return canonicalValue.equals(this.currentCanonicalValue);
+ }
+ }
+
+ // should only happen if canonicalValue and currentCanonicalValue are
+ // null
+ return true;
+ }
+
/**
* This method will activate the usage of the dropdown filter via setting
* {@link #setShowDropdownFilter(boolean)} to <code>true</code>.