Bug 572635 - ComboBoxes with single select and checkboxes do not work
reliably

Change-Id: I73bfeb6a5e517d39ce4cb2110c055f91d31d23d3
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java
index 57c99b5..fcf43d7 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java
@@ -493,12 +493,21 @@
         combo.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseUp(MouseEvent e) {
-                commit(MoveDirectionEnum.NONE,
-                        (!ComboBoxCellEditor.this.multiselect && ComboBoxCellEditor.this.editMode == EditModeEnum.INLINE));
-                if (!ComboBoxCellEditor.this.multiselect && ComboBoxCellEditor.this.editMode == EditModeEnum.DIALOG) {
-                    // hide the dropdown after a value was selected in the combo
-                    // in a dialog
-                    combo.hideDropdownControl();
+                // Mouse up and Selection Events get fired in the wrong order
+                // on iOS when clicking the checkbox. In this scenario the
+                // NatCombo will fire a Mouse up event programmatically with set
+                // data, to ensure that the processing is done in the correct
+                // order.
+                boolean isSingleSelectWithCheckbox = !ComboBoxCellEditor.this.multiselect && ComboBoxCellEditor.this.useCheckbox;
+                if (!isSingleSelectWithCheckbox || e.data != null) {
+
+                    commit(MoveDirectionEnum.NONE,
+                            (!ComboBoxCellEditor.this.multiselect && ComboBoxCellEditor.this.editMode == EditModeEnum.INLINE));
+                    if (!ComboBoxCellEditor.this.multiselect && ComboBoxCellEditor.this.editMode == EditModeEnum.DIALOG) {
+                        // hide the dropdown after a value was selected in the
+                        // combo in a dialog
+                        combo.hideDropdownControl();
+                    }
                 }
             }
         });
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 3e05d90..2f2c704 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
@@ -688,6 +688,20 @@
                 }
 
                 updateTextControl(false);
+
+                // Mouse up and Selection Events get fired in the wrong order
+                // on iOS when clicking the checkbox. In this scenario the
+                // NatCombo will fire a Mouse up event programmatically with set
+                // data, to ensure that the processing is done in the correct
+                // order.
+                if (!NatCombo.this.multiselect && NatCombo.this.useCheckbox) {
+                    Event event = new Event();
+                    event.widget = NatCombo.this;
+                    event.display = NatCombo.this.getDisplay();
+                    event.type = SWT.MouseUp;
+                    event.data = chosenItem;
+                    NatCombo.this.notifyListeners(SWT.MouseUp, event);
+                }
             }
         });