summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-10-05 09:36:47 (EDT)
committerSteffen Kriese2010-10-05 09:36:47 (EDT)
commit87cc1a3cd5b07d7098746cf056ef1bde8bb2cafb (patch)
treeedc32cf610326d984c849481dbee0379274d79bf
parentb4cecf4cd44f167b6aaadc2484e81fc2bac7c4ed (diff)
downloadorg.eclipse.riena-87cc1a3cd5b07d7098746cf056ef1bde8bb2cafb.zip
org.eclipse.riena-87cc1a3cd5b07d7098746cf056ef1bde8bb2cafb.tar.gz
org.eclipse.riena-87cc1a3cd5b07d7098746cf056ef1bde8bb2cafb.tar.bz2
when Combo/CCombo is outputOnly, reject selection
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidget.java11
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java14
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractComboRidget.java26
3 files changed, 49 insertions, 2 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 94b5dc6..f82c5dc 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
@@ -23,6 +23,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractComboRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
@@ -36,6 +37,8 @@ public class CComboRidget extends AbstractComboRidget {
private final ModifyListener modifyListener;
+ private final SelectionTypeEnforcer selectionTypeEnforcer;
+
public CComboRidget() {
modifyListener = new CComboModifyListener();
addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
@@ -46,6 +49,9 @@ public class CComboRidget extends AbstractComboRidget {
}
}
});
+
+ selectionTypeEnforcer = new SelectionTypeEnforcer(this);
+ addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, selectionTypeEnforcer);
}
@Override
@@ -53,6 +59,7 @@ public class CComboRidget extends AbstractComboRidget {
super.bindUIControl();
if (getUIControl() != null) {
updateBgColor(isEnabled());
+ getUIControl().addSelectionListener(selectionTypeEnforcer);
}
}
@@ -182,7 +189,9 @@ public class CComboRidget extends AbstractComboRidget {
*/
private final class CComboModifyListener implements ModifyListener {
public void modifyText(final ModifyEvent e) {
- setText(getUIControlText());
+ if (!isOutputOnly()) {
+ setText(getUIControlText());
+ }
}
}
} \ No newline at end of file
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 4d8fb01..2d05ad6 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
@@ -19,6 +19,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Combo;
+import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractComboRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
@@ -27,9 +28,18 @@ import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
*/
public class ComboRidget extends AbstractComboRidget {
+ private final SelectionTypeEnforcer selectionTypeEnforcer;
+
+ public ComboRidget() {
+ selectionTypeEnforcer = new SelectionTypeEnforcer(this);
+ addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, selectionTypeEnforcer);
+ }
+
private final ModifyListener modifyListener = new ModifyListener() {
public void modifyText(final ModifyEvent e) {
- setText(getUIControlText());
+ if (!isOutputOnly()) {
+ setText(getUIControlText());
+ }
}
};
@@ -41,6 +51,8 @@ public class ComboRidget extends AbstractComboRidget {
if ((style & SWT.READ_ONLY) == 0) {
throw new BindingException("Combo must be READ_ONLY"); //$NON-NLS-1$
}
+
+ ((Combo) uiControl).addSelectionListener(selectionTypeEnforcer);
}
}
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 f0aab86..5505014 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
@@ -35,6 +35,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.riena.core.util.ListenerList;
import org.eclipse.riena.core.util.ReflectionUtils;
@@ -701,4 +702,29 @@ 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.
+ */
+ protected final static class SelectionTypeEnforcer extends SelectionAdapter implements PropertyChangeListener {
+
+ private final AbstractComboRidget ridget;
+ private Object savedSelection;
+
+ public SelectionTypeEnforcer(final AbstractComboRidget ridget) {
+ this.ridget = ridget;
+ }
+
+ @Override
+ public void widgetSelected(final org.eclipse.swt.events.SelectionEvent e) {
+ super.widgetSelected(e);
+ if (ridget.isOutputOnly()) {
+ ridget.setSelection(savedSelection);
+ }
+ }
+
+ public void propertyChange(final PropertyChangeEvent evt) {
+ savedSelection = ridget.getSelection();
+ }
+ }
}