summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-10-14 02:45:43 (EDT)
committerSteffen Kriese2010-10-14 02:45:43 (EDT)
commitd0e27af48b389826f8e2ff2c29b9c9e5635809a5 (patch)
tree8f7eab93030a4b1407c355794582474b3f01b67c
parentc436e9292dddae1cd17780603e5e2421d9869f79 (diff)
downloadorg.eclipse.riena-d0e27af48b389826f8e2ff2c29b9c9e5635809a5.zip
org.eclipse.riena-d0e27af48b389826f8e2ff2c29b9c9e5635809a5.tar.gz
org.eclipse.riena-d0e27af48b389826f8e2ff2c29b9c9e5635809a5.tar.bz2
Fixed outputonly behavior in CCombo
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java6
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java6
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java21
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MarkerSupport.java22
4 files changed, 49 insertions, 6 deletions
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 f82c5dc..399feba 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
@@ -55,6 +55,12 @@ public class CComboRidget extends AbstractComboRidget {
}
@Override
+ public void updateFromModel() {
+ super.updateFromModel();
+ selectionTypeEnforcer.setSavedSelection(getSelection());
+ }
+
+ @Override
protected void bindUIControl() {
super.bindUIControl();
if (getUIControl() != null) {
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java
index 2d05ad6..764d6cd 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java
@@ -44,6 +44,12 @@ public class ComboRidget extends AbstractComboRidget {
};
@Override
+ public void updateFromModel() {
+ super.updateFromModel();
+ selectionTypeEnforcer.setSavedSelection(getSelection());
+ }
+
+ @Override
protected void checkUIControl(final Object uiControl) {
AbstractSWTRidget.assertType(uiControl, Combo.class);
if (uiControl != null) {
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 b01817a..fa78dd1 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
@@ -708,8 +708,9 @@ public abstract class AbstractComboRidget extends AbstractSWTRidget implements I
}
/**
- * TwoAdapter that saves the current selection, when outputOnly changes and
- * applies it again after the user tries to select an entry in the combo.
+ * TwoWayAdapter that saves the current selection, when outputOnly changes
+ * and applies it again after the user tries to select an entry in the
+ * combo.
*
* @since 3.0
*/
@@ -720,18 +721,32 @@ public abstract class AbstractComboRidget extends AbstractSWTRidget implements I
public SelectionTypeEnforcer(final AbstractComboRidget ridget) {
this.ridget = ridget;
+ this.savedSelection = ridget.getSelection();
}
@Override
public void widgetSelected(final org.eclipse.swt.events.SelectionEvent e) {
super.widgetSelected(e);
if (ridget.isOutputOnly()) {
- ridget.setSelection(savedSelection);
+ if (null == savedSelection) {
+ ridget.setSelection(-1);
+ } else {
+ ridget.setSelection(savedSelection);
+ }
}
}
public void propertyChange(final PropertyChangeEvent evt) {
savedSelection = ridget.getSelection();
}
+
+ /**
+ * @param savedSelection
+ * the savedSelection to set
+ */
+ public void setSavedSelection(final Object savedSelection) {
+ this.savedSelection = savedSelection;
+ }
+
}
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MarkerSupport.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MarkerSupport.java
index 90f3a24..e8edcab 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MarkerSupport.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MarkerSupport.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.log.Logger;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -164,7 +165,7 @@ public class MarkerSupport extends BasicMarkerSupport {
protected void addMandatory(final Control control) {
if (getData(PRE_MANDATORY_BACKGROUND_KEY) == null) {
- setData(PRE_MANDATORY_BACKGROUND_KEY, control.getBackground());
+ setData(PRE_MANDATORY_BACKGROUND_KEY, getControlBackground(control));
}
final RienaDefaultLnf lnf = LnfManager.getLnf();
Color color = lnf.getColor(LnfKeyConstants.MANDATORY_MARKER_BACKGROUND);
@@ -180,11 +181,25 @@ public class MarkerSupport extends BasicMarkerSupport {
protected void addOutput(final Control control, final Color color) {
if (getData(PRE_OUTPUT_BACKGROUND_KEY) == null) {
- setData(PRE_OUTPUT_BACKGROUND_KEY, control.getBackground());
+ final Color background = getControlBackground(control);
+ setData(PRE_OUTPUT_BACKGROUND_KEY, background);
control.setBackground(color);
}
}
+ private Color getControlBackground(final Control control) {
+ // a CCombo does return the background of the composite instead of the list we use
+ if (control instanceof CCombo) {
+ try {
+ final Control txt = ReflectionUtils.getHidden(control, "list"); //$NON-NLS-1$
+ return txt.getBackground();
+ } catch (final RuntimeException ex) {
+ ex.printStackTrace();
+ }
+ }
+ return control.getBackground();
+ }
+
@Override
protected void clearAllMarkers(final Control control) {
super.clearAllMarkers(control);
@@ -210,7 +225,8 @@ public class MarkerSupport extends BasicMarkerSupport {
protected void clearOutput(final Control control) {
if (getData(PRE_OUTPUT_BACKGROUND_KEY) != null) {
- control.setBackground((Color) getData(PRE_OUTPUT_BACKGROUND_KEY));
+ final Color data = (Color) getData(PRE_OUTPUT_BACKGROUND_KEY);
+ control.setBackground(data);
setData(PRE_OUTPUT_BACKGROUND_KEY, null);
}
}