summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-10-19 07:34:53 (EDT)
committerSteffen Kriese2010-10-19 07:34:53 (EDT)
commit605f82da7137c838b2d36a2451596f165c115baa (patch)
tree1fe6f841a1c5a140cc9d2f9651fcfa0bc0e1bc00
parent54e5b210521fee1d782c85b8c31e0bdbe221cd98 (diff)
downloadorg.eclipse.riena-605f82da7137c838b2d36a2451596f165c115baa.zip
org.eclipse.riena-605f82da7137c838b2d36a2451596f165c115baa.tar.gz
org.eclipse.riena-605f82da7137c838b2d36a2451596f165c115baa.tar.bz2
CCombo now allows a selection that differs from the bound list
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java2
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java17
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java6
3 files changed, 20 insertions, 5 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java
index c29fd05..727d8df 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java
@@ -517,7 +517,7 @@ public abstract class AbstractComboRidgetTest extends AbstractSWTRidgetTest {
ridget.setSelection("X");
- assertEquals(null, ridget.getSelection());
+ assertEquals("X", ridget.getSelection());
assertEquals(-1, getSelectionIndex(control));
ridget.setSelection("A");
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java
index 399feba..5d31385 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java
@@ -49,12 +49,27 @@ public class CComboRidget extends AbstractComboRidget {
}
}
});
-
selectionTypeEnforcer = new SelectionTypeEnforcer(this);
addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, selectionTypeEnforcer);
}
@Override
+ public void setSelection(final Object newSelection) {
+ assertIsBoundToModel();
+ final Object oldSelection = selectionObservable.getValue();
+ if (oldSelection != newSelection) {
+ if (newSelection == null) {
+ if (getUIControl() != null) {
+ clearUIControlListSelection();
+ }
+ selectionObservable.setValue(null);
+ } else {
+ selectionObservable.setValue(newSelection);
+ }
+ }
+ }
+
+ @Override
public void updateFromModel() {
super.updateFromModel();
selectionTypeEnforcer.setSavedSelection(getSelection());
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java
index fa78dd1..0a1ef3d 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java
@@ -56,9 +56,9 @@ import org.eclipse.riena.ui.ridgets.swt.nls.Messages;
*/
public abstract class AbstractComboRidget extends AbstractSWTRidget implements IComboRidget {
/** List of available options (ridget). */
- private final IObservableList rowObservables;
+ protected final IObservableList rowObservables;
/** The selected option (ridget). */
- private final IObservableValue selectionObservable;
+ protected final IObservableValue selectionObservable;
/** Selection validator that allows or cancels a selection request. */
private final SelectionBindingValidator selectionValidator;
/** IValueChangeListener that fires a selection event on change. */
@@ -510,7 +510,7 @@ public abstract class AbstractComboRidget extends AbstractSWTRidget implements I
}
}
- private void assertIsBoundToModel() {
+ protected void assertIsBoundToModel() {
if (optionValues == null) {
throw new BindingException("ridget not bound to model"); //$NON-NLS-1$
}