summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-04-15 09:55:23 (EDT)
committerCarsten Drossel2009-04-15 09:55:23 (EDT)
commitf347756f0797729786ec7b66b32199cf16e0cc32 (patch)
treeb443696b2bb68de9b1c291a9d5a85a251aa41532
parent8b26bd9300d43f285eed0e63905e4427801d4c9f (diff)
downloadorg.eclipse.riena-f347756f0797729786ec7b66b32199cf16e0cc32.zip
org.eclipse.riena-f347756f0797729786ec7b66b32199cf16e0cc32.tar.gz
org.eclipse.riena-f347756f0797729786ec7b66b32199cf16e0cc32.tar.bz2
refactoring for bug 271760: moved is/setEnabled up from IMarkableRidget to IRidget; IActionRidget now extends IRidget instead of IMarkableRidget
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/CompositeTableSubModuleController.java6
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java6
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/MarkerSubModuleController.java29
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TableSubModuleController.java6
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeSubModuleController.java11
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeTableSubModuleController.java11
-rw-r--r--org.eclipse.riena.sample.app.client.rcpmail/src/org/eclipse/riena/sample/app/client/rcpmail/MarkerSubModuleController.java30
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractRidgetTestCase.java433
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetTest.java394
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetWithControlTest.java33
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuItemRidgetTest.java31
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidgetTest.java30
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidgetTest.java66
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/binding/SwtControlRidgetMapperTest.java25
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ComboRidget.java3
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CompositeTableRidget.java2
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/DateTimeRidget.java3
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MasterDetailsRidget.java14
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidget.java22
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MultipleChoiceRidget.java4
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidget.java119
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidget.java4
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java18
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidget.java3
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidget.java3
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ToggleButtonRidget.java4
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TreeRidget.java3
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/uiprocess/UIProcessRidget.java18
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractListRidget.java3
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java37
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractMarkerSupport.java2
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IActionRidget.java6
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IMarkableRidget.java20
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IRidget.java20
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/MessageBox.java15
35 files changed, 862 insertions, 572 deletions
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/CompositeTableSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/CompositeTableSubModuleController.java
index 02dc15b..381f45d 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/CompositeTableSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/CompositeTableSubModuleController.java
@@ -29,8 +29,8 @@ import org.eclipse.riena.ui.ridgets.AbstractCompositeRidget;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IActionRidget;
import org.eclipse.riena.ui.ridgets.ICompositeTableRidget;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.IRowRidget;
import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
import org.eclipse.riena.ui.ridgets.ITextRidget;
@@ -154,8 +154,8 @@ public class CompositeTableSubModuleController extends SubModuleController {
// helping methods
//////////////////
- private void bindEnablementToValue(DataBindingContext dbc, IMarkableRidget ridget, IObservableValue value) {
- dbc.bindValue(BeansObservables.observeValue(ridget, IMarkableRidget.PROPERTY_ENABLED), value, null, null);
+ private void bindEnablementToValue(DataBindingContext dbc, IRidget ridget, IObservableValue value) {
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
}
}
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java
index 34112f5..9e6f1b2 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java
@@ -28,7 +28,7 @@ import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IActionRidget;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ITableRidget;
import org.eclipse.riena.ui.ridgets.ITextRidget;
@@ -146,8 +146,8 @@ public class ListSubModuleController extends SubModuleController {
bindEnablementToValue(dbc, buttonSave, hasSelection);
}
- private void bindEnablementToValue(DataBindingContext dbc, IMarkableRidget ridget, IObservableValue value) {
- dbc.bindValue(BeansObservables.observeValue(ridget, IMarkableRidget.PROPERTY_ENABLED), value, null, null);
+ private void bindEnablementToValue(DataBindingContext dbc, IRidget ridget, IObservableValue value) {
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
}
}
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/MarkerSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/MarkerSubModuleController.java
index 2c2fa41..e4f3b1a 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/MarkerSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/MarkerSubModuleController.java
@@ -38,6 +38,7 @@ import org.eclipse.riena.ui.ridgets.IGroupedTreeTableRidget;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
import org.eclipse.riena.ui.ridgets.INumericTextRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.IRowRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
@@ -138,9 +139,9 @@ public class MarkerSubModuleController extends SubModuleController {
final IToggleButtonRidget buttonRadioB = (IToggleButtonRidget) getRidget("buttonRadioB"); //$NON-NLS-1$
final IToggleButtonRidget buttonCheck = (IToggleButtonRidget) getRidget("buttonCheck"); //$NON-NLS-1$
- final IMarkableRidget[] markables = new IMarkableRidget[] { textName, textPrice, textAmount, textDate, dtDate,
- comboAge, choiceType, choiceFlavor, listPersons, tablePersons, compTable, treePersons, treeWCols,
- buttonToggle, buttonPush, buttonRadioA, buttonRadioB, buttonCheck };
+ final IRidget[] markables = new IRidget[] { textName, textPrice, textAmount, textDate, dtDate, comboAge,
+ choiceType, choiceFlavor, listPersons, tablePersons, compTable, treePersons, treeWCols, buttonToggle,
+ buttonPush, buttonRadioA, buttonRadioB, buttonCheck };
final IToggleButtonRidget checkMandatory = (IToggleButtonRidget) getRidget("checkMandatory"); //$NON-NLS-1$
final IToggleButtonRidget checkError = (IToggleButtonRidget) getRidget("checkError"); //$NON-NLS-1$
@@ -152,8 +153,10 @@ public class MarkerSubModuleController extends SubModuleController {
checkMandatory.addListener(new IActionListener() {
public void callback() {
boolean isMandatory = checkMandatory.isSelected();
- for (IMarkableRidget ridget : markables) {
- ridget.setMandatory(isMandatory);
+ for (IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setMandatory(isMandatory);
+ }
}
if (isMandatory) {
textName.setText(""); //$NON-NLS-1$
@@ -182,8 +185,10 @@ public class MarkerSubModuleController extends SubModuleController {
public void callback() {
boolean isError = checkError.isSelected();
- for (IMarkableRidget ridget : markables) {
- ridget.setErrorMarked(isError);
+ for (IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setErrorMarked(isError);
+ }
}
// using this "always wrong" validator for purposes of this
// demo. It prevents the error marker being removed from the
@@ -207,7 +212,7 @@ public class MarkerSubModuleController extends SubModuleController {
checkDisabled.addListener(new IActionListener() {
public void callback() {
boolean isEnabled = !checkDisabled.isSelected();
- for (IMarkableRidget ridget : markables) {
+ for (IRidget ridget : markables) {
ridget.setEnabled(isEnabled);
}
}
@@ -217,8 +222,10 @@ public class MarkerSubModuleController extends SubModuleController {
checkOutput.addListener(new IActionListener() {
public void callback() {
boolean isOutput = checkOutput.isSelected();
- for (IMarkableRidget ridget : markables) {
- ridget.setOutputOnly(isOutput);
+ for (IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setOutputOnly(isOutput);
+ }
}
}
});
@@ -227,7 +234,7 @@ public class MarkerSubModuleController extends SubModuleController {
checkHidden.addListener(new IActionListener() {
public void callback() {
boolean isVisible = !checkHidden.isSelected();
- for (IMarkableRidget ridget : markables) {
+ for (IRidget ridget : markables) {
ridget.setVisible(isVisible);
}
}
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TableSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TableSubModuleController.java
index 948cf91..40ec9e0 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TableSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TableSubModuleController.java
@@ -31,7 +31,7 @@ import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IActionRidget;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ITableRidget;
@@ -138,8 +138,8 @@ public class TableSubModuleController extends SubModuleController {
bindEnablementToValue(dbc, buttonRename, hasSelection);
}
- private void bindEnablementToValue(DataBindingContext dbc, IMarkableRidget ridget, IObservableValue value) {
- dbc.bindValue(BeansObservables.observeValue(ridget, IMarkableRidget.PROPERTY_ENABLED), value, null, null);
+ private void bindEnablementToValue(DataBindingContext dbc, IRidget ridget, IObservableValue value) {
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
}
private String getNewValue(Object oldValue) {
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeSubModuleController.java
index cf1928b..fe176fd 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeSubModuleController.java
@@ -19,18 +19,19 @@ import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.riena.example.client.views.TreeSubModuleView;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IActionRidget;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ITreeRidget;
import org.eclipse.riena.ui.ridgets.tree2.ITreeNode;
import org.eclipse.riena.ui.ridgets.tree2.TreeNode;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Shell;
/**
* Controller for the {@link TreeSubModuleView} example.
@@ -224,8 +225,8 @@ public class TreeSubModuleController extends SubModuleController {
// helping methods
//////////////////
- private void bindEnablementToValue(DataBindingContext dbc, IMarkableRidget ridget, IObservableValue value) {
- dbc.bindValue(BeansObservables.observeValue(ridget, IMarkableRidget.PROPERTY_ENABLED), value, null, null);
+ private void bindEnablementToValue(DataBindingContext dbc, IRidget ridget, IObservableValue value) {
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
}
private TreeNode[] createTreeInput() {
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeTableSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeTableSubModuleController.java
index 2d2bbb2..6eda003 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeTableSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/TreeTableSubModuleController.java
@@ -19,6 +19,9 @@ import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.riena.beans.common.TypedComparator;
import org.eclipse.riena.beans.common.WordNode;
import org.eclipse.riena.example.client.views.TreeSubModuleView;
@@ -27,11 +30,9 @@ import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IActionRidget;
import org.eclipse.riena.ui.ridgets.IGroupedTreeTableRidget;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.IToggleButtonRidget;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Shell;
/**
* Controller for the {@link TreeSubModuleView} example.
@@ -193,8 +194,8 @@ public class TreeTableSubModuleController extends SubModuleController {
bindEnablementToValue(dbc, buttonCollapse, hasSelection);
}
- private void bindEnablementToValue(DataBindingContext dbc, IMarkableRidget ridget, IObservableValue value) {
- dbc.bindValue(BeansObservables.observeValue(ridget, IMarkableRidget.PROPERTY_ENABLED), value, null, null);
+ private void bindEnablementToValue(DataBindingContext dbc, IRidget ridget, IObservableValue value) {
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
}
private String getNewValue(Object oldValue) {
diff --git a/org.eclipse.riena.sample.app.client.rcpmail/src/org/eclipse/riena/sample/app/client/rcpmail/MarkerSubModuleController.java b/org.eclipse.riena.sample.app.client.rcpmail/src/org/eclipse/riena/sample/app/client/rcpmail/MarkerSubModuleController.java
index ee45fa0..155a5ab 100644
--- a/org.eclipse.riena.sample.app.client.rcpmail/src/org/eclipse/riena/sample/app/client/rcpmail/MarkerSubModuleController.java
+++ b/org.eclipse.riena.sample.app.client.rcpmail/src/org/eclipse/riena/sample/app/client/rcpmail/MarkerSubModuleController.java
@@ -18,6 +18,7 @@ import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
+
import org.eclipse.riena.beans.common.Person;
import org.eclipse.riena.beans.common.TestBean;
import org.eclipse.riena.beans.common.WordNode;
@@ -30,6 +31,7 @@ import org.eclipse.riena.ui.ridgets.IComboRidget;
import org.eclipse.riena.ui.ridgets.IGroupedTreeTableRidget;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
import org.eclipse.riena.ui.ridgets.ITableRidget;
@@ -111,9 +113,9 @@ public class MarkerSubModuleController extends SubModuleController {
final IToggleButtonRidget buttonRadioB = (IToggleButtonRidget) getRidget("buttonRadioB"); //$NON-NLS-1$
final IToggleButtonRidget buttonCheck = (IToggleButtonRidget) getRidget("buttonCheck"); //$NON-NLS-1$
- final IMarkableRidget[] markables = new IMarkableRidget[] { textName, textPrice, comboAge, choiceType,
- choiceFlavor, listPersons, tablePersons, treePersons, treeWCols, buttonToggle, buttonPush,
- buttonRadioA, buttonRadioB, buttonCheck };
+ final IRidget[] markables = new IRidget[] { textName, textPrice, comboAge, choiceType, choiceFlavor,
+ listPersons, tablePersons, treePersons, treeWCols, buttonToggle, buttonPush, buttonRadioA,
+ buttonRadioB, buttonCheck };
final IToggleButtonRidget checkMandatory = (IToggleButtonRidget) getRidget("checkMandatory"); //$NON-NLS-1$
final IToggleButtonRidget checkError = (IToggleButtonRidget) getRidget("checkError"); //$NON-NLS-1$
@@ -125,8 +127,10 @@ public class MarkerSubModuleController extends SubModuleController {
checkMandatory.addListener(new IActionListener() {
public void callback() {
boolean isMandatory = checkMandatory.isSelected();
- for (IMarkableRidget ridget : markables) {
- ridget.setMandatory(isMandatory);
+ for (IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setMandatory(isMandatory);
+ }
}
if (isMandatory) {
textName.setText(""); //$NON-NLS-1$
@@ -152,8 +156,10 @@ public class MarkerSubModuleController extends SubModuleController {
public void callback() {
boolean isError = checkError.isSelected();
- for (IMarkableRidget ridget : markables) {
- ridget.setErrorMarked(isError);
+ for (IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setErrorMarked(isError);
+ }
}
/*
* using this "always wrong" validator for purposes of this
@@ -175,7 +181,7 @@ public class MarkerSubModuleController extends SubModuleController {
checkDisabled.addListener(new IActionListener() {
public void callback() {
boolean isEnabled = !checkDisabled.isSelected();
- for (IMarkableRidget ridget : markables) {
+ for (IRidget ridget : markables) {
ridget.setEnabled(isEnabled);
}
}
@@ -185,8 +191,10 @@ public class MarkerSubModuleController extends SubModuleController {
checkOutput.addListener(new IActionListener() {
public void callback() {
boolean isOutput = checkOutput.isSelected();
- for (IMarkableRidget ridget : markables) {
- ridget.setOutputOnly(isOutput);
+ for (IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setOutputOnly(isOutput);
+ }
}
}
});
@@ -195,7 +203,7 @@ public class MarkerSubModuleController extends SubModuleController {
checkHidden.addListener(new IActionListener() {
public void callback() {
boolean isVisible = !checkHidden.isSelected();
- for (IMarkableRidget ridget : markables) {
+ for (IRidget ridget : markables) {
ridget.setVisible(isVisible);
}
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractRidgetTestCase.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractRidgetTestCase.java
new file mode 100644
index 0000000..1e2d4eb
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractRidgetTestCase.java
@@ -0,0 +1,433 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.internal.ui.ridgets.swt;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.HashSet;
+
+import org.easymock.EasyMock;
+
+import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.jface.databinding.swt.SWTObservables;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.riena.core.marker.IMarker;
+import org.eclipse.riena.core.util.ReflectionUtils;
+import org.eclipse.riena.tests.RienaTestCase;
+import org.eclipse.riena.tests.collect.UITestCase;
+import org.eclipse.riena.ui.core.marker.DisabledMarker;
+import org.eclipse.riena.ui.core.marker.MandatoryMarker;
+import org.eclipse.riena.ui.core.marker.OutputMarker;
+import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
+import org.eclipse.riena.ui.tests.base.PropertyChangeEventEquals;
+
+/**
+ * Superclass to test a Ridget .
+ */
+@UITestCase
+public abstract class AbstractRidgetTestCase extends RienaTestCase {
+
+ private Shell shell;
+ private Object widget;
+ private IRidget ridget;
+ private Text otherControl;
+ protected PropertyChangeListener propertyChangeListenerMock;
+
+ protected abstract Object createWidget(final Composite parent);
+
+ protected abstract IRidget createRidget();
+
+ protected Object getWidget() {
+ return widget;
+ }
+
+ protected IRidget getRidget() {
+ return ridget;
+ }
+
+ protected Shell getShell() {
+ return shell;
+ }
+
+ protected Control getOtherControl() {
+ return otherControl;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Display display = Display.getDefault();
+
+ Realm realm = SWTObservables.getRealm(display);
+ assertNotNull(realm);
+ ReflectionUtils.invokeHidden(realm, "setDefault", realm);
+
+ shell = new Shell(SWT.SYSTEM_MODAL | SWT.ON_TOP);
+
+ shell.setLayout(new RowLayout(SWT.VERTICAL));
+
+ widget = createWidget(shell);
+
+ ridget = createRidget();
+ ridget.setUIControl(widget);
+ propertyChangeListenerMock = EasyMock.createMock(PropertyChangeListener.class);
+ ridget.addPropertyChangeListener(propertyChangeListenerMock);
+
+ otherControl = new Text(shell, SWT.SINGLE);
+ otherControl.setText("other focusable widget");
+
+ shell.setSize(130, 100);
+ shell.setLocation(0, 0);
+ shell.open();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ridget = null;
+ widget = null;
+ otherControl = null;
+ shell.dispose();
+ shell = null;
+
+ super.tearDown();
+ }
+
+ // easy mock helper methods
+ // /////////////////////////
+
+ protected final void verifyPropertyChangeEvents() {
+ EasyMock.verify(propertyChangeListenerMock);
+ }
+
+ protected final void expectNoPropertyChangeEvent() {
+ EasyMock.reset(propertyChangeListenerMock);
+ EasyMock.replay(propertyChangeListenerMock);
+ }
+
+ protected final void expectPropertyChangeEvents(PropertyChangeEvent... propertyChangeEvents) {
+ EasyMock.reset(propertyChangeListenerMock);
+ for (PropertyChangeEvent propertyChangeEvent : propertyChangeEvents) {
+ propertyChangeListenerMock.propertyChange(createArgumentMatcher(propertyChangeEvent));
+ }
+ EasyMock.replay(propertyChangeListenerMock);
+ }
+
+ protected final void expectPropertyChangeEvent(String propertyName, Object oldValue, Object newValue) {
+ expectPropertyChangeEvents(new PropertyChangeEvent(getRidget(), propertyName, oldValue, newValue));
+ }
+
+ // test methods
+ // /////////////
+
+ public void testIsVisible() {
+ getShell().open();
+
+ assertTrue("Fails for " + getRidget(), getRidget().isVisible());
+ if (isWidgetControl()) {
+ assertTrue("Fails for " + getRidget(), ((Control) getWidget()).isVisible());
+ }
+
+ getRidget().setVisible(false);
+
+ assertFalse("Fails for " + getRidget(), getRidget().isVisible());
+ if (isWidgetControl()) {
+ assertFalse("Fails for " + getRidget(), ((Control) getWidget()).isVisible());
+ }
+
+ getRidget().setVisible(true);
+
+ assertTrue("Fails for " + getRidget(), getRidget().isVisible());
+ if (isWidgetControl()) {
+ assertTrue("Fails for " + getRidget(), ((Control) getWidget()).isVisible());
+ }
+
+ getRidget().setUIControl(null);
+ getRidget().setVisible(false);
+
+ assertFalse("Fails for " + getRidget(), getRidget().isVisible());
+ if (isWidgetControl()) {
+ assertTrue("Fails for " + getRidget(), ((Control) getWidget()).isVisible());
+ }
+
+ getRidget().setUIControl(getWidget());
+
+ assertFalse("Fails for " + getRidget(), getRidget().isVisible());
+ if (isWidgetControl()) {
+ assertFalse("Fails for " + getRidget(), ((Control) getWidget()).isVisible());
+ }
+ }
+
+ public void testIsEnabled() throws Exception {
+
+ assertTrue("Fails for " + getRidget(), getRidget().isEnabled());
+ if (isWidgetControl()) {
+ assertTrue("Fails for " + getRidget(), ((Control) getWidget()).isEnabled());
+ }
+
+ getRidget().setEnabled(false);
+
+ assertFalse("Fails for " + getRidget(), getRidget().isEnabled());
+ if (isWidgetControl()) {
+ assertFalse("Fails for " + getRidget(), ((Control) getWidget()).isEnabled());
+ }
+
+ getRidget().setEnabled(false);
+
+ assertFalse("Fails for " + getRidget(), getRidget().isEnabled());
+ if (isWidgetControl()) {
+ assertFalse("Fails for " + getRidget(), ((Control) getWidget()).isEnabled());
+ }
+
+ getRidget().setEnabled(true);
+
+ assertTrue("Fails for " + getRidget(), getRidget().isEnabled());
+ if (isWidgetControl()) {
+ assertTrue("Fails for " + getRidget(), ((Control) getWidget()).isEnabled());
+ }
+
+ getRidget().setUIControl(null);
+ getRidget().setEnabled(false);
+
+ assertFalse("Fails for " + getRidget(), getRidget().isEnabled());
+ if (isWidgetControl()) {
+ assertTrue("Fails for " + getRidget(), ((Control) getWidget()).isEnabled());
+ }
+
+ getRidget().setUIControl(getWidget());
+
+ assertFalse("Fails for " + getRidget(), getRidget().isEnabled());
+ if (isWidgetControl()) {
+ assertFalse("Fails for " + getRidget(), ((Control) getWidget()).isEnabled());
+ }
+ }
+
+ public void testFiresTooltipProperty() {
+ expectPropertyChangeEvent(IRidget.PROPERTY_TOOLTIP, null, "begood");
+
+ getRidget().setToolTipText("begood");
+
+ verifyPropertyChangeEvents();
+ expectNoPropertyChangeEvent();
+
+ getRidget().setToolTipText("begood");
+
+ verifyPropertyChangeEvents();
+ expectPropertyChangeEvent(IRidget.PROPERTY_TOOLTIP, "begood", null);
+
+ getRidget().setToolTipText(null);
+
+ verifyPropertyChangeEvents();
+ }
+
+ public void testFiresMarkerProperty() {
+ if (!(getRidget() instanceof IMarkableRidget)) {
+ return;
+ }
+ IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
+ IMarker marker = new MandatoryMarker();
+ HashSet<IMarker> before = new HashSet<IMarker>(markableRidget.getMarkers());
+ HashSet<IMarker> after = new HashSet<IMarker>(before);
+ after.add(marker);
+
+ assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
+ assertEquals("Fails for " + markableRidget, before.size() + 1, after.size());
+
+ expectPropertyChangeEvent(IMarkableRidget.PROPERTY_MARKER, before, after);
+ markableRidget.addMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.addMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IMarkableRidget.PROPERTY_MARKER, after, before);
+ markableRidget.removeMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.removeMarker(marker);
+ verifyPropertyChangeEvents();
+ }
+
+ public void testFiresDisabledPropertyUsingSetter() {
+ if (!(getRidget() instanceof IMarkableRidget)) {
+ return;
+ }
+ IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
+ markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
+ markableRidget.addPropertyChangeListener(IRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
+
+ assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
+
+ expectNoPropertyChangeEvent();
+ markableRidget.setEnabled(true);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
+ markableRidget.setEnabled(false);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.setEnabled(false);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
+ markableRidget.setEnabled(true);
+ verifyPropertyChangeEvents();
+ }
+
+ public void testFiresDisabledPropertyUsingAddRemove() {
+ if (!(getRidget() instanceof IMarkableRidget)) {
+ return;
+ }
+ IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
+ IMarker marker = new DisabledMarker();
+ markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
+ markableRidget.addPropertyChangeListener(IRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
+
+ assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
+
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
+ markableRidget.addMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.addMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
+ markableRidget.removeMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.removeMarker(marker);
+ verifyPropertyChangeEvents();
+ }
+
+ /**
+ * Check that disabling / enabling works when we don't have a bound control.
+ */
+ public void testDisableWithoutUIControl() {
+ if (!(getRidget() instanceof IMarkableRidget)) {
+ return;
+ }
+ IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
+ markableRidget.setUIControl(null);
+
+ assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
+
+ markableRidget.setEnabled(false);
+
+ assertFalse("Fails for " + markableRidget, markableRidget.isEnabled());
+
+ markableRidget.setEnabled(true);
+
+ assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
+ }
+
+ public void testFiresOutputPropertyUsingSetter() {
+ if (!(getRidget() instanceof IMarkableRidget)) {
+ return;
+ }
+ IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
+ markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
+ markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, propertyChangeListenerMock);
+
+ assertFalse("Fails for " + markableRidget, markableRidget.isOutputOnly());
+
+ expectNoPropertyChangeEvent();
+ markableRidget.setOutputOnly(false);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.FALSE, Boolean.TRUE);
+ markableRidget.setOutputOnly(true);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.setOutputOnly(true);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.TRUE, Boolean.FALSE);
+ markableRidget.setOutputOnly(false);
+ verifyPropertyChangeEvents();
+ }
+
+ public void testFiresOutputPropertyUsingAddRemove() {
+ if (!(getRidget() instanceof IMarkableRidget)) {
+ return;
+ }
+ IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
+ IMarker marker = new OutputMarker();
+ markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
+ markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, propertyChangeListenerMock);
+
+ assertFalse("Fails for " + markableRidget, markableRidget.isOutputOnly());
+
+ expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.FALSE, Boolean.TRUE);
+ markableRidget.addMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.addMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.TRUE, Boolean.FALSE);
+ markableRidget.removeMarker(marker);
+ verifyPropertyChangeEvents();
+
+ expectNoPropertyChangeEvent();
+ markableRidget.removeMarker(marker);
+ verifyPropertyChangeEvents();
+ }
+
+ // helping methods
+ // ////////////////
+
+ private PropertyChangeEvent createArgumentMatcher(PropertyChangeEvent propertyChangeEvent) {
+ return PropertyChangeEventEquals.eqPropertyChangeEvent(propertyChangeEvent);
+ }
+
+ protected void assertMarkerIgnored(IMarker marker) {
+ AbstractSWTWidgetRidget ridgetImpl = (AbstractSWTWidgetRidget) getRidget();
+ Control control = (Control) getWidget();
+ Color originalForegroundColor = control.getForeground();
+ Color originalBackgroundColor = control.getBackground();
+
+ ridgetImpl.addMarker(marker);
+
+ assertTrue(control.isVisible());
+ assertTrue(control.isEnabled());
+ assertEquals(originalForegroundColor, control.getForeground());
+ assertEquals(originalBackgroundColor, control.getBackground());
+
+ ridgetImpl.removeMarker(marker);
+
+ assertTrue(control.isVisible());
+ assertTrue(control.isEnabled());
+ assertEquals(originalForegroundColor, control.getForeground());
+ assertEquals(originalBackgroundColor, control.getBackground());
+ }
+
+ protected boolean isWidgetControl() {
+ return getWidget() instanceof Control;
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetTest.java
index 313dccd..8f94182 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetTest.java
@@ -10,172 +10,61 @@
*******************************************************************************/
package org.eclipse.riena.internal.ui.ridgets.swt;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import org.easymock.EasyMock;
-
-import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.riena.core.marker.IMarker;
-import org.eclipse.riena.core.util.ReflectionUtils;
-import org.eclipse.riena.tests.RienaTestCase;
import org.eclipse.riena.tests.UITestHelper;
-import org.eclipse.riena.tests.collect.UITestCase;
-import org.eclipse.riena.ui.core.marker.DisabledMarker;
-import org.eclipse.riena.ui.core.marker.MandatoryMarker;
-import org.eclipse.riena.ui.core.marker.OutputMarker;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.listener.FocusEvent;
import org.eclipse.riena.ui.ridgets.listener.IFocusListener;
-import org.eclipse.riena.ui.tests.base.PropertyChangeEventEquals;
/**
- * Tests for the class {@link AbstractSwtRidget}.
+ * Superclass to test a Ridget which is bound to an SWT-Widget.
*/
-@UITestCase
-public abstract class AbstractSWTRidgetTest extends RienaTestCase {
-
- private Shell shell;
- private Widget widget;
- private IRidget ridget;
- private Text otherControl;
- private PropertyChangeListener propertyChangeListenerMock;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- Display display = Display.getDefault();
-
- Realm realm = SWTObservables.getRealm(display);
- assertNotNull(realm);
- ReflectionUtils.invokeHidden(realm, "setDefault", realm);
-
- shell = new Shell(SWT.SYSTEM_MODAL | SWT.ON_TOP);
- shell.setLayout(new RowLayout(SWT.VERTICAL));
-
- widget = createWidget(shell);
-
- ridget = createRidget();
- ridget.setUIControl(widget);
- propertyChangeListenerMock = EasyMock.createMock(PropertyChangeListener.class);
- ridget.addPropertyChangeListener(propertyChangeListenerMock);
-
- otherControl = new Text(shell, SWT.SINGLE);
- otherControl.setText("other focusable widget");
-
- shell.setSize(130, 100);
- shell.setLocation(0, 0);
- shell.open();
- }
-
- @Override
- protected void tearDown() throws Exception {
- ridget = null;
- widget = null;
- otherControl = null;
- shell.dispose();
- shell = null;
-
- super.tearDown();
- }
+public abstract class AbstractSWTRidgetTest extends AbstractRidgetTestCase {
// protected methods
// //////////////////
protected abstract Widget createWidget(final Composite parent);
- protected abstract IRidget createRidget();
-
protected Widget getWidget() {
- return widget;
- }
-
- protected IRidget getRidget() {
- return ridget;
- }
-
- protected final Shell getShell() {
- return shell;
- }
-
- // easy mock helper methods
- // /////////////////////////
-
- protected final void verifyPropertyChangeEvents() {
- EasyMock.verify(propertyChangeListenerMock);
- }
-
- protected final void expectNoPropertyChangeEvent() {
- EasyMock.reset(propertyChangeListenerMock);
- EasyMock.replay(propertyChangeListenerMock);
- }
-
- protected final void expectPropertyChangeEvents(PropertyChangeEvent... propertyChangeEvents) {
- EasyMock.reset(propertyChangeListenerMock);
- for (PropertyChangeEvent propertyChangeEvent : propertyChangeEvents) {
- propertyChangeListenerMock.propertyChange(createArgumentMatcher(propertyChangeEvent));
- }
- EasyMock.replay(propertyChangeListenerMock);
- }
-
- protected final void expectPropertyChangeEvent(String propertyName, Object oldValue, Object newValue) {
- expectPropertyChangeEvents(new PropertyChangeEvent(getRidget(), propertyName, oldValue, newValue));
+ return (Widget) super.getWidget();
}
// test methods
// /////////////
- public void testIsVisible() {
- shell.open();
- ridget.setVisible(false);
- assertFalse("Fails for " + ridget, ridget.isVisible());
-
- ridget.setVisible(true);
- assertTrue("Fails for " + ridget, ridget.isVisible());
- }
-
public void testGetToolTip() {
- if (!(getWidget() instanceof Control)) {
+ if (!isWidgetControl()) {
// only Control supports tool tips
return;
}
- ridget.setUIControl(null);
+ getRidget().setUIControl(null);
- assertEquals("Fails for " + ridget, null, ridget.getToolTipText());
+ assertEquals("Fails for " + getRidget(), null, getRidget().getToolTipText());
- ridget.setToolTipText("foo");
+ getRidget().setToolTipText("foo");
- assertEquals("Fails for " + ridget, "foo", ridget.getToolTipText());
+ assertEquals("Fails for " + getRidget(), "foo", getRidget().getToolTipText());
Control aControl = (Control) getWidget();
aControl.setToolTipText(null);
- ridget.setUIControl(aControl);
+ getRidget().setUIControl(aControl);
- assertEquals("Fails for " + ridget, "foo", ridget.getToolTipText());
- assertEquals("Fails for " + ridget, "foo", ((Control) ridget.getUIControl()).getToolTipText());
+ assertEquals("Fails for " + getRidget(), "foo", getRidget().getToolTipText());
+ assertEquals("Fails for " + getRidget(), "foo", ((Control) getRidget().getUIControl()).getToolTipText());
}
public void testGetFocusable() {
- if (!(getWidget() instanceof Control)) {
+ if (!isWidgetControl()) {
// only Control supports focus
return;
}
@@ -195,30 +84,30 @@ public abstract class AbstractSWTRidgetTest extends RienaTestCase {
public void testSetFocusable() {
- if (!(getWidget() instanceof Control)) {
+ if (!isWidgetControl()) {
// only Control supports focus
return;
}
IRidget aRidget = getRidget();
Control aControl = (Control) getWidget();
- otherControl.moveAbove(aControl);
+ getOtherControl().moveAbove(aControl);
aControl.setFocus();
if (aControl.isFocusControl()) { // skip if control cannot receive focus
aRidget.setFocusable(false);
- otherControl.setFocus();
+ getOtherControl().setFocus();
- assertTrue("Fails for " + otherControl, otherControl.isFocusControl());
+ assertTrue("Fails for " + getOtherControl(), getOtherControl().isFocusControl());
- UITestHelper.sendString(otherControl.getDisplay(), "\t");
+ UITestHelper.sendString(getOtherControl().getDisplay(), "\t");
assertFalse("Fails for " + aControl, aControl.isFocusControl());
aRidget.setFocusable(true);
- otherControl.setFocus();
- UITestHelper.sendString(otherControl.getDisplay(), "\t");
+ getOtherControl().setFocus();
+ UITestHelper.sendString(getOtherControl().getDisplay(), "\t");
assertTrue("Fails for " + aControl, aControl.isFocusControl());
}
@@ -226,7 +115,7 @@ public abstract class AbstractSWTRidgetTest extends RienaTestCase {
public void testRequestFocus() throws Exception {
- if (!(getWidget() instanceof Control)) {
+ if (!isWidgetControl()) {
// only Control supports focus
return;
}
@@ -234,10 +123,10 @@ public abstract class AbstractSWTRidgetTest extends RienaTestCase {
Control aControl = (Control) getWidget();
aControl.setFocus();
if (aControl.isFocusControl()) { // skip if control cannot receive focus
- assertTrue("Fails for " + otherControl, otherControl.setFocus());
+ assertTrue("Fails for " + getOtherControl(), getOtherControl().setFocus());
assertFalse("Fails for " + aControl, aControl.isFocusControl());
- assertFalse("Fails for " + ridget, ridget.hasFocus());
+ assertFalse("Fails for " + getRidget(), getRidget().hasFocus());
final List<FocusEvent> focusGainedEvents = new ArrayList<FocusEvent>();
final List<FocusEvent> focusLostEvents = new ArrayList<FocusEvent>();
@@ -250,211 +139,32 @@ public abstract class AbstractSWTRidgetTest extends RienaTestCase {
focusLostEvents.add(event);
}
};
- ridget.addFocusListener(focusListener);
+ getRidget().addFocusListener(focusListener);
- ridget.requestFocus();
+ getRidget().requestFocus();
assertTrue("Fails for " + aControl, aControl.isFocusControl());
- assertTrue("Fails for " + ridget, ridget.hasFocus());
- assertEquals("Fails for " + ridget, 1, focusGainedEvents.size());
- assertEquals("Fails for " + ridget, ridget, focusGainedEvents.get(0).getNewFocusOwner());
- assertEquals("Fails for " + ridget, 0, focusLostEvents.size());
+ assertTrue("Fails for " + getRidget(), getRidget().hasFocus());
+ assertEquals("Fails for " + getRidget(), 1, focusGainedEvents.size());
+ assertEquals("Fails for " + getRidget(), getRidget(), focusGainedEvents.get(0).getNewFocusOwner());
+ assertEquals("Fails for " + getRidget(), 0, focusLostEvents.size());
- assertTrue("Fails for " + otherControl, otherControl.setFocus());
+ assertTrue("Fails for " + getOtherControl(), getOtherControl().setFocus());
assertFalse("Fails for " + aControl, aControl.isFocusControl());
- assertFalse("Fails for " + ridget, ridget.hasFocus());
- assertEquals("Fails for " + ridget, 1, focusGainedEvents.size());
- assertEquals("Fails for " + ridget, 1, focusLostEvents.size());
- assertEquals("Fails for " + ridget, ridget, focusLostEvents.get(0).getOldFocusOwner());
-
- ridget.removeFocusListener(focusListener);
-
- ridget.requestFocus();
- assertTrue("Fails for " + otherControl, otherControl.setFocus());
-
- assertEquals("Fails for " + ridget, 1, focusGainedEvents.size());
- assertEquals("Fails for " + ridget, 1, focusLostEvents.size());
- }
- }
-
- public void testFiresTooltipProperty() {
- expectPropertyChangeEvent(IRidget.PROPERTY_TOOLTIP, null, "begood");
-
- ridget.setToolTipText("begood");
-
- verifyPropertyChangeEvents();
- expectNoPropertyChangeEvent();
-
- ridget.setToolTipText("begood");
-
- verifyPropertyChangeEvents();
- expectPropertyChangeEvent(IRidget.PROPERTY_TOOLTIP, "begood", null);
-
- ridget.setToolTipText(null);
-
- verifyPropertyChangeEvents();
- }
-
- public void testFiresMarkerProperty() {
- if (!(getRidget() instanceof IMarkableRidget)) {
- return;
- }
- IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
- IMarker marker = new MandatoryMarker();
- HashSet<IMarker> before = new HashSet<IMarker>(markableRidget.getMarkers());
- HashSet<IMarker> after = new HashSet<IMarker>(before);
- after.add(marker);
-
- assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
- assertEquals("Fails for " + markableRidget, before.size() + 1, after.size());
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_MARKER, before, after);
- markableRidget.addMarker(marker);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.addMarker(marker);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_MARKER, after, before);
- markableRidget.removeMarker(marker);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.removeMarker(marker);
- verifyPropertyChangeEvents();
- }
-
- public void testFiresDisabledPropertyUsingSetter() {
- if (!(getRidget() instanceof IMarkableRidget)) {
- return;
- }
- IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
- markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
- markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
-
- assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
-
- expectNoPropertyChangeEvent();
- markableRidget.setEnabled(true);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
- markableRidget.setEnabled(false);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.setEnabled(false);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
- markableRidget.setEnabled(true);
- verifyPropertyChangeEvents();
- }
-
- public void testFiresDisabledPropertyUsingAddRemove() {
- if (!(getRidget() instanceof IMarkableRidget)) {
- return;
- }
- IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
- IMarker marker = new DisabledMarker();
- markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
- markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
-
- assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
- markableRidget.addMarker(marker);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.addMarker(marker);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
- markableRidget.removeMarker(marker);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.removeMarker(marker);
- verifyPropertyChangeEvents();
- }
-
- /**
- * Check that disabling / enabling works when we don't have a bound control.
- */
- public void testDisableWithoutUIControl() {
- if (!(getRidget() instanceof IMarkableRidget)) {
- return;
- }
- IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
- markableRidget.setUIControl(null);
-
- assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
-
- markableRidget.setEnabled(false);
-
- assertFalse("Fails for " + markableRidget, markableRidget.isEnabled());
+ assertFalse("Fails for " + getRidget(), getRidget().hasFocus());
+ assertEquals("Fails for " + getRidget(), 1, focusGainedEvents.size());
+ assertEquals("Fails for " + getRidget(), 1, focusLostEvents.size());
+ assertEquals("Fails for " + getRidget(), getRidget(), focusLostEvents.get(0).getOldFocusOwner());
- markableRidget.setEnabled(true);
+ getRidget().removeFocusListener(focusListener);
- assertTrue("Fails for " + markableRidget, markableRidget.isEnabled());
- }
+ getRidget().requestFocus();
+ assertTrue("Fails for " + getOtherControl(), getOtherControl().setFocus());
- public void testFiresOutputPropertyUsingSetter() {
- if (!(getRidget() instanceof IMarkableRidget)) {
- return;
+ assertEquals("Fails for " + getRidget(), 1, focusGainedEvents.size());
+ assertEquals("Fails for " + getRidget(), 1, focusLostEvents.size());
}
- IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
- markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
- markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, propertyChangeListenerMock);
-
- assertFalse("Fails for " + markableRidget, markableRidget.isOutputOnly());
-
- expectNoPropertyChangeEvent();
- markableRidget.setOutputOnly(false);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.FALSE, Boolean.TRUE);
- markableRidget.setOutputOnly(true);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.setOutputOnly(true);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.TRUE, Boolean.FALSE);
- markableRidget.setOutputOnly(false);
- verifyPropertyChangeEvents();
- }
-
- public void testFiresOutputPropertyUsingAddRemove() {
- if (!(getRidget() instanceof IMarkableRidget)) {
- return;
- }
- IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
- IMarker marker = new OutputMarker();
- markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
- markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_OUTPUT_ONLY, propertyChangeListenerMock);
-
- assertFalse("Fails for " + markableRidget, markableRidget.isOutputOnly());
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.FALSE, Boolean.TRUE);
- markableRidget.addMarker(marker);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.addMarker(marker);
- verifyPropertyChangeEvents();
-
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_OUTPUT_ONLY, Boolean.TRUE, Boolean.FALSE);
- markableRidget.removeMarker(marker);
- verifyPropertyChangeEvents();
-
- expectNoPropertyChangeEvent();
- markableRidget.removeMarker(marker);
- verifyPropertyChangeEvents();
}
/**
@@ -483,32 +193,4 @@ public abstract class AbstractSWTRidgetTest extends RienaTestCase {
assertTrue("Fails for " + control, control.isVisible());
}
- // helping methods
- // ////////////////
-
- private PropertyChangeEvent createArgumentMatcher(PropertyChangeEvent propertyChangeEvent) {
- return PropertyChangeEventEquals.eqPropertyChangeEvent(propertyChangeEvent);
- }
-
- protected void assertMarkerIgnored(IMarker marker) {
- AbstractSWTWidgetRidget ridgetImpl = (AbstractSWTWidgetRidget) getRidget();
- Control control = (Control) getWidget();
- Color originalForegroundColor = control.getForeground();
- Color originalBackgroundColor = control.getBackground();
-
- ridgetImpl.addMarker(marker);
-
- assertTrue(control.isVisible());
- assertTrue(control.isEnabled());
- assertEquals(originalForegroundColor, control.getForeground());
- assertEquals(originalBackgroundColor, control.getBackground());
-
- ridgetImpl.removeMarker(marker);
-
- assertTrue(control.isVisible());
- assertTrue(control.isEnabled());
- assertEquals(originalForegroundColor, control.getForeground());
- assertEquals(originalBackgroundColor, control.getBackground());
- }
-
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetWithControlTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetWithControlTest.java
index 2f8cb29..84daeb5 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetWithControlTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractSWTRidgetWithControlTest.java
@@ -19,8 +19,17 @@ import java.util.List;
import junit.framework.TestCase;
import org.easymock.EasyMock;
+
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.jface.databinding.swt.SWTObservables;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
import org.eclipse.riena.core.marker.IMarker;
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.tests.UITestHelper;
@@ -33,17 +42,11 @@ import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.listener.FocusEvent;
import org.eclipse.riena.ui.ridgets.listener.IFocusListener;
import org.eclipse.riena.ui.tests.base.PropertyChangeEventEquals;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
/**
- * Abstract test class for <code>control</code>s of type <code>Control</code> or
- * controls supporting simular features.
+ * @deprecated use
+ * @see AbstractRidgetTestCase
+ * @see AbstractSWTRidgetTest
*/
@UITestCase
public abstract class AbstractSWTRidgetWithControlTest extends TestCase {
@@ -314,7 +317,7 @@ public abstract class AbstractSWTRidgetWithControlTest extends TestCase {
}
IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
- markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
+ markableRidget.addPropertyChangeListener(IRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
assertTrue(markableRidget.isEnabled());
@@ -322,7 +325,7 @@ public abstract class AbstractSWTRidgetWithControlTest extends TestCase {
markableRidget.setEnabled(true);
verifyPropertyChangeEvents();
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
markableRidget.setEnabled(false);
verifyPropertyChangeEvents();
@@ -330,7 +333,7 @@ public abstract class AbstractSWTRidgetWithControlTest extends TestCase {
markableRidget.setEnabled(false);
verifyPropertyChangeEvents();
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
markableRidget.setEnabled(true);
verifyPropertyChangeEvents();
}
@@ -342,11 +345,11 @@ public abstract class AbstractSWTRidgetWithControlTest extends TestCase {
IMarkableRidget markableRidget = (IMarkableRidget) getRidget();
IMarker marker = new DisabledMarker();
markableRidget.removePropertyChangeListener(propertyChangeListenerMock);
- markableRidget.addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
+ markableRidget.addPropertyChangeListener(IRidget.PROPERTY_ENABLED, propertyChangeListenerMock);
assertTrue(markableRidget.isEnabled());
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.TRUE, Boolean.FALSE);
markableRidget.addMarker(marker);
verifyPropertyChangeEvents();
@@ -354,7 +357,7 @@ public abstract class AbstractSWTRidgetWithControlTest extends TestCase {
markableRidget.addMarker(marker);
verifyPropertyChangeEvents();
- expectPropertyChangeEvent(IMarkableRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
+ expectPropertyChangeEvent(IRidget.PROPERTY_ENABLED, Boolean.FALSE, Boolean.TRUE);
markableRidget.removeMarker(marker);
verifyPropertyChangeEvents();
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuItemRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuItemRidgetTest.java
index 34a809e..84dc943 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuItemRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuItemRidgetTest.java
@@ -10,10 +10,6 @@
*******************************************************************************/
package org.eclipse.riena.internal.ui.ridgets.swt;
-import org.eclipse.riena.core.util.ReflectionUtils;
-import org.eclipse.riena.ui.ridgets.IActionListener;
-import org.eclipse.riena.ui.ridgets.IActionRidget;
-import org.eclipse.riena.ui.ridgets.swt.uibinding.SwtControlRidgetMapper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
@@ -21,6 +17,11 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.riena.core.util.ReflectionUtils;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.swt.uibinding.SwtControlRidgetMapper;
+
/**
* Tests of the class {@link MenuItemRidget}.
*/
@@ -53,6 +54,28 @@ public class MenuItemRidgetTest extends AbstractSWTRidgetTest {
return (MenuItemRidget) super.getRidget();
}
+ @Override
+ public void testIsVisible() {
+ getShell().open();
+
+ assertTrue("Fails for " + getRidget(), getRidget().isVisible());
+ assertFalse("Fails for " + getRidget(), getWidget().isDisposed());
+
+ getRidget().setVisible(false);
+
+ assertFalse("Fails for " + getRidget(), getRidget().isVisible());
+ // widget expected to be hidden by disposing it:
+ assertTrue("Fails for " + getRidget(), getWidget().isDisposed());
+
+ getRidget().setVisible(true);
+
+ assertTrue("Fails for " + getRidget(), getRidget().isVisible());
+ // dispose of old widget cannot be undone:
+ assertTrue("Fails for " + getRidget(), getWidget().isDisposed());
+ // but a new widget should have been created:
+ assertFalse("Fails for " + getRidget(), getRidget().getUIControl().isDisposed());
+ }
+
/**
* Tests the constructor {@code MenuItemRidget()}.
*/
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidgetTest.java
index 023bf21..b7ce2f3 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidgetTest.java
@@ -16,6 +16,9 @@ import java.util.List;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
import org.eclipse.riena.tests.UITestHelper;
import org.eclipse.riena.ui.ridgets.IMessageBoxRidget;
import org.eclipse.riena.ui.ridgets.IRidget;
@@ -23,13 +26,11 @@ import org.eclipse.riena.ui.ridgets.IMessageBoxRidget.MessageBoxOption;
import org.eclipse.riena.ui.ridgets.listener.FocusEvent;
import org.eclipse.riena.ui.ridgets.listener.IFocusListener;
import org.eclipse.riena.ui.swt.MessageBox;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
/**
* Tests for the MessageBoxRidget.
*/
-public class MessageBoxRidgetTest extends AbstractSWTRidgetWithControlTest {
+public class MessageBoxRidgetTest extends AbstractRidgetTestCase {
/*
* (non-Javadoc)
@@ -318,12 +319,6 @@ public class MessageBoxRidgetTest extends AbstractSWTRidgetWithControlTest {
assertEquals(getWidget(), getRidget().getUIControl());
}
- @Override
- public void testGetToolTip() {
- // no test, because tooltips not yet supported
- }
-
- @Override
public void testGetFocusable() {
IRidget aRidget = getRidget();
@@ -339,7 +334,6 @@ public class MessageBoxRidgetTest extends AbstractSWTRidgetWithControlTest {
assertTrue(aRidget.isFocusable());
}
- @Override
public void testSetFocusable() {
IRidget aRidget = getRidget();
@@ -368,7 +362,6 @@ public class MessageBoxRidgetTest extends AbstractSWTRidgetWithControlTest {
}
}
- @Override
public void testRequestFocus() throws Exception {
MessageBox aControl = getWidget();
@@ -419,6 +412,21 @@ public class MessageBoxRidgetTest extends AbstractSWTRidgetWithControlTest {
}
}
+ @Override
+ public void testFiresTooltipProperty() {
+ // tooltips are not supported
+ }
+
+ @Override
+ public void testIsVisible() {
+
+ assertFalse(getRidget().isVisible());
+
+ getRidget().setVisible(true);
+
+ super.testIsVisible();
+ }
+
private void setMessageBoxReturnValue(final int returnValue) {
getRidget().setUIControl(new MessageBox(getShell()) {
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidgetTest.java
index c105946..a437087 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidgetTest.java
@@ -10,29 +10,75 @@
*******************************************************************************/
package org.eclipse.riena.internal.ui.ridgets.swt;
-import junit.framework.TestCase;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
-import org.eclipse.riena.tests.collect.NonUITestCase;
+import org.eclipse.riena.tests.collect.UITestCase;
+import org.eclipse.riena.ui.ridgets.IRidget;
/**
* Tests of the class {@link ShellRidget}.
*/
-@NonUITestCase
-public class ShellRidgetTest extends TestCase {
+@UITestCase
+public class ShellRidgetTest extends AbstractSWTRidgetTest {
+
+ @Override
+ protected IRidget createRidget() {
+ return new MockShellRidget();
+ }
+
+ @Override
+ protected Widget createWidget(Composite parent) {
+ return getShell();
+ }
+
+ @Override
+ protected MockShellRidget getRidget() {
+ return (MockShellRidget) super.getRidget();
+ }
+
+ @Override
+ protected Shell getWidget() {
+ return (Shell) super.getWidget();
+ }
+
+ /**
+ * @see org.eclipse.riena.internal.ui.ridgets.swt.AbstractSWTRidgetTest#testGetFocusable()
+ */
+ @Override
+ public void testGetFocusable() {
+
+ assertFalse(getRidget().isFocusable());
+
+ getRidget().setFocusable(true);
+
+ assertFalse(getRidget().isFocusable());
+ }
/**
* Tests the method {@code hasChanged}.
*/
public void testHasChanged() {
- MockShellRidget ridget = new MockShellRidget();
+ assertTrue(getRidget().hasChanged("a", "b"));
+ assertFalse(getRidget().hasChanged("a", "a"));
+ assertTrue(getRidget().hasChanged(null, "b"));
+ assertTrue(getRidget().hasChanged("a", null));
+ assertFalse(getRidget().hasChanged(null, null));
+ }
+
+ public void testSetActive() throws Exception {
+
+ getRidget().setActive(false);
+
+ assertFalse(getRidget().isEnabled());
+ assertFalse(getWidget().isEnabled());
- assertTrue(ridget.hasChanged("a", "b"));
- assertFalse(ridget.hasChanged("a", "a"));
- assertTrue(ridget.hasChanged(null, "b"));
- assertTrue(ridget.hasChanged("a", null));
- assertFalse(ridget.hasChanged(null, null));
+ getRidget().setActive(true);
+ assertTrue(getRidget().isEnabled());
+ assertTrue(getWidget().isEnabled());
}
/**
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/binding/SwtControlRidgetMapperTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/binding/SwtControlRidgetMapperTest.java
index 042b7a5..e53b396 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/binding/SwtControlRidgetMapperTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/binding/SwtControlRidgetMapperTest.java
@@ -13,6 +13,12 @@ package org.eclipse.riena.navigation.ui.swt.binding;
import java.beans.PropertyChangeListener;
import org.eclipse.core.databinding.BindingException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.internal.ui.ridgets.swt.ActionRidget;
import org.eclipse.riena.internal.ui.ridgets.swt.LabelRidget;
@@ -24,11 +30,6 @@ import org.eclipse.riena.ui.ridgets.listener.IFocusListener;
import org.eclipse.riena.ui.ridgets.swt.uibinding.SwtControlRidgetMapper;
import org.eclipse.riena.ui.ridgets.swt.uibinding.SwtControlRidgetMapper.Mapping;
import org.eclipse.riena.ui.ridgets.uibinding.IMappingCondition;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
/**
* Tests of the class <code>SwtControlRidgetMapper</code>
@@ -329,6 +330,13 @@ public class SwtControlRidgetMapperTest extends RienaTestCase {
public void setVisible(boolean visible) {
}
+ public boolean isEnabled() {
+ return false;
+ }
+
+ public void setEnabled(boolean enabled) {
+ }
+
public void addFocusListener(IFocusListener listener) {
}
@@ -402,6 +410,13 @@ public class SwtControlRidgetMapperTest extends RienaTestCase {
public void setVisible(boolean visible) {
}
+ public boolean isEnabled() {
+ return false;
+ }
+
+ public void setEnabled(boolean enabled) {
+ }
+
public void addFocusListener(IFocusListener listener) {
}
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 7d4e232..578cf50 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
@@ -39,6 +39,7 @@ import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.ui.common.IComboEntryFactory;
import org.eclipse.riena.ui.ridgets.IComboRidget;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
/**
@@ -109,7 +110,7 @@ public class ComboRidget extends AbstractSWTRidget implements IComboRidget {
strToObjConverter = new StringToObjectConverter();
selectionValidator = new SelectionBindingValidator();
valueChangeValidator = new ValueChangeValidator();
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
applyEnabled();
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CompositeTableRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CompositeTableRidget.java
index ab727ff..1eea1b9 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CompositeTableRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/CompositeTableRidget.java
@@ -114,7 +114,7 @@ public class CompositeTableRidget extends AbstractSelectableIndexedRidget implem
}
}
});
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
refreshRowStyles();
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/DateTimeRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/DateTimeRidget.java
index 130b965..9ecdb68 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/DateTimeRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/DateTimeRidget.java
@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.DateTime;
import org.eclipse.riena.ui.ridgets.IDateTimeRidget;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ITextRidget;
/**
@@ -55,7 +56,7 @@ public class DateTimeRidget extends AbstractEditableRidget implements IDateTimeR
updateEditable();
}
});
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
updateEditable();
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MasterDetailsRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MasterDetailsRidget.java
index 2af5481..a7e3d4d 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MasterDetailsRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MasterDetailsRidget.java
@@ -73,7 +73,7 @@ public class MasterDetailsRidget extends AbstractCompositeRidget implements IMas
|| editable == null
// ignore these events:
|| IMarkableRidget.PROPERTY_MARKER.equals(evt.getPropertyName())
- || IMarkableRidget.PROPERTY_ENABLED.equals(evt.getPropertyName())
+ || IRidget.PROPERTY_ENABLED.equals(evt.getPropertyName())
|| IMarkableRidget.PROPERTY_OUTPUT_ONLY.equals(evt.getPropertyName())) {
return;
}
@@ -201,6 +201,14 @@ public class MasterDetailsRidget extends AbstractCompositeRidget implements IMas
}
}
+ @Override
+ protected final void updateEnabled() {
+ MasterDetailsComposite control = getUIControl();
+ if (control != null) {
+ control.setEnabled(isEnabled());
+ }
+ }
+
// helping methods
//////////////////
@@ -210,10 +218,10 @@ public class MasterDetailsRidget extends AbstractCompositeRidget implements IMas
}
}
- private void bindEnablementToValue(DataBindingContext dbc, IMarkableRidget ridget, IObservableValue value) {
+ private void bindEnablementToValue(DataBindingContext dbc, IRidget ridget, IObservableValue value) {
Assert.isNotNull(ridget);
Assert.isNotNull(value);
- dbc.bindValue(BeansObservables.observeValue(ridget, IMarkableRidget.PROPERTY_ENABLED), value, null, null);
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
}
private boolean canApply() {
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidget.java
index ad5e711..29beb7d 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MessageBoxRidget.java
@@ -13,9 +13,6 @@ package org.eclipse.riena.internal.ui.ridgets.swt;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.riena.ui.ridgets.AbstractRidget;
-import org.eclipse.riena.ui.ridgets.IMessageBoxRidget;
-import org.eclipse.riena.ui.swt.MessageBox;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -23,6 +20,10 @@ import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.riena.ui.ridgets.AbstractRidget;
+import org.eclipse.riena.ui.ridgets.IMessageBoxRidget;
+import org.eclipse.riena.ui.swt.MessageBox;
+
/**
* The ridget for a message box.
*/
@@ -33,6 +34,7 @@ public class MessageBoxRidget extends AbstractRidget implements IMessageBoxRidge
private String text;
private boolean blocked;
private boolean visible;
+ private boolean enabled = true;
private boolean focusable;
private FocusListener focusManager;
private Type type = Type.PLAIN;
@@ -189,6 +191,10 @@ public class MessageBoxRidget extends AbstractRidget implements IMessageBoxRidge
return messageBox != null && visible;
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
public void requestFocus() {
if (isFocusable()) {
messageBox.requestFocus();
@@ -227,6 +233,11 @@ public class MessageBoxRidget extends AbstractRidget implements IMessageBoxRidge
updateUIControl();
}
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ updateUIControl();
+ }
+
@Override
public void updateFromModel() {
// do nothing
@@ -235,6 +246,7 @@ public class MessageBoxRidget extends AbstractRidget implements IMessageBoxRidge
private void updateUIControl() {
if (messageBox != null) {
updateVisible();
+ updateEnabled();
}
}
@@ -242,6 +254,10 @@ public class MessageBoxRidget extends AbstractRidget implements IMessageBoxRidge
messageBox.setVisible(visible);
}
+ private void updateEnabled() {
+ messageBox.setVisible(enabled);
+ }
+
/**
* Checks the type of the UI-control. If the test fails, some kind of
* unchecked exception is thrown.
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MultipleChoiceRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MultipleChoiceRidget.java
index 94060eb..8e198f2 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MultipleChoiceRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MultipleChoiceRidget.java
@@ -35,8 +35,8 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.riena.beans.common.ListBean;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
import org.eclipse.riena.ui.swt.ChoiceComposite;
import org.eclipse.riena.ui.swt.lnf.LnFUpdater;
@@ -63,7 +63,7 @@ public class MultipleChoiceRidget extends AbstractSWTRidget implements IMultiple
disableMandatoryMarkers(hasInput());
}
});
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
updateSelection(getUIControl());
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidget.java
index cededab..914a034 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ShellRidget.java
@@ -11,32 +11,28 @@
package org.eclipse.riena.internal.ui.ridgets.swt;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.riena.core.util.ListenerList;
-import org.eclipse.riena.ui.ridgets.AbstractRidget;
-import org.eclipse.riena.ui.ridgets.IRidget;
+import org.eclipse.riena.ui.ridgets.AbstractMarkerSupport;
import org.eclipse.riena.ui.ridgets.IWindowRidget;
import org.eclipse.riena.ui.ridgets.UIBindingFailure;
import org.eclipse.riena.ui.ridgets.listener.IWindowRidgetListener;
import org.eclipse.riena.ui.ridgets.uibinding.IBindingPropertyLocator;
import org.eclipse.riena.ui.swt.utils.ImageStore;
import org.eclipse.riena.ui.swt.utils.SWTBindingPropertyLocator;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Shell;
/**
* The ridget for a Shell control.
*/
-public class ShellRidget extends AbstractRidget implements IWindowRidget {
+public class ShellRidget extends AbstractSWTWidgetRidget implements IWindowRidget {
private static Image missingImage;
- private Shell shell;
- private String toolTip = null;
- private boolean blocked;
private boolean closeable;
- private boolean active;
private String title;
private String icon;
private ListenerList<IWindowRidgetListener> windowRidgetListeners;
@@ -48,7 +44,6 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
title = ""; //$NON-NLS-1$
closeable = true;
- active = true;
windowRidgetListeners = new ListenerList<IWindowRidgetListener>(IWindowRidgetListener.class);
shellListener = new RidgetShellListener();
}
@@ -58,26 +53,48 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
setUIControl(shell);
}
- /*
- * @see org.eclipse.riena.ui.ridgets.IRidget#getUIControl()
- */
public Shell getUIControl() {
- return shell;
+ return (Shell) super.getUIControl();
}
- /*
- * @see org.eclipse.riena.ui.ridgets.IRidget#setUIControl(java.lang.Object)
+ /**
+ * @see org.eclipse.riena.internal.ui.ridgets.swt.AbstractSWTWidgetRidget#checkUIControl(java.lang.Object)
*/
- public void setUIControl(Object uiControl) {
+ @Override
+ protected void checkUIControl(Object uiControl) {
if (uiControl != null && !(uiControl instanceof Shell)) {
throw new UIBindingFailure("uiControl of a ShellRidget must be a Shell but was a " //$NON-NLS-1$
+ uiControl.getClass().getSimpleName());
}
+ }
+ /**
+ * @see org.eclipse.riena.internal.ui.ridgets.swt.AbstractSWTWidgetRidget#unbindUIControl()
+ */
+ @Override
+ protected void unbindUIControl() {
removeShellListener();
- shell = (Shell) uiControl;
+ }
+
+ /**
+ * @see org.eclipse.riena.internal.ui.ridgets.swt.AbstractSWTWidgetRidget#bindUIControl()
+ */
+ @Override
+ protected void bindUIControl() {
+
addShellListener();
updateToolTip();
+ updateCloseable();
+ updateTitle();
+ updateIcon();
+ }
+
+ /**
+ * @see org.eclipse.riena.internal.ui.ridgets.swt.AbstractSWTWidgetRidget#createMarkerSupport()
+ */
+ @Override
+ protected AbstractMarkerSupport createMarkerSupport() {
+ return new BasicMarkerSupport(this, propertyChangeSupport);
}
private void addShellListener() {
@@ -100,14 +117,6 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
windowRidgetListeners.remove(listener);
}
- public boolean isVisible() {
- return getUIControl().isVisible();
- }
-
- public void setVisible(boolean visible) {
- getUIControl().setVisible(visible);
- }
-
public void dispose() {
getUIControl().dispose();
}
@@ -224,7 +233,6 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
}
public boolean isFocusable() {
- // TODO Auto-generated method stub
return false;
}
@@ -232,36 +240,9 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
// TODO Auto-generated method stub
}
- public String getToolTipText() {
- return toolTip;
- }
-
- public void setToolTipText(String toolTipText) {
- String oldValue = toolTip;
- toolTip = toolTipText;
- updateToolTip();
- firePropertyChange(IRidget.PROPERTY_TOOLTIP, oldValue, toolTip);
- }
-
- private void updateToolTip() {
+ protected void updateToolTip() {
if (getUIControl() != null) {
- getUIControl().setToolTipText(toolTip);
- }
- }
-
- /*
- * @see org.eclipse.riena.ui.ridgets.IRidget#isBlocked()
- */
- public boolean isBlocked() {
- return blocked;
- }
-
- /*
- * @see org.eclipse.riena.ui.ridgets.IRidget#setBlocked(boolean)
- */
- public void setBlocked(boolean blocked) {
- if (this.blocked != blocked) {
- this.blocked = blocked;
+ getUIControl().setToolTipText(getToolTipText());
}
}
@@ -269,10 +250,7 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
* @see org.eclipse.riena.ui.ridgets.IWindowRidget#setActive(boolean)
*/
public void setActive(boolean active) {
- if (this.active != active) {
- this.active = active;
- updateActive();
- }
+ setEnabled(active);
}
/*
@@ -289,12 +267,6 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
// TODO
}
- private void updateActive() {
- if (getUIControl() != null) {
- getUIControl().setEnabled(active);
- }
- }
-
@Override
public void updateFromModel() {
@@ -303,7 +275,6 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
if (getUIControl() != null) {
updateTitle();
updateIcon();
- updateActive();
}
}
@@ -342,4 +313,12 @@ public class ShellRidget extends AbstractRidget implements IWindowRidget {
// do nothing yet
}
}
+
+ /**
+ * @see org.eclipse.riena.internal.ui.ridgets.swt.AbstractSWTWidgetRidget#isDisableMandatoryMarker()
+ */
+ @Override
+ public boolean isDisableMandatoryMarker() {
+ return false;
+ }
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidget.java
index 6d978bc..7ad9f38 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidget.java
@@ -35,7 +35,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
import org.eclipse.riena.ui.swt.ChoiceComposite;
@@ -64,7 +64,7 @@ public class SingleChoiceRidget extends AbstractSWTRidget implements ISingleChoi
disableMandatoryMarkers(hasInput());
}
});
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
updateSelection(getUIControl());
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java
index 1a5997b..e748d18 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java
@@ -18,6 +18,10 @@ import java.util.List;
import java.util.Map;
import java.util.TimerTask;
+import org.osgi.framework.BundleContext;
+
+import org.eclipse.swt.widgets.Display;
+
import org.eclipse.riena.core.injector.Inject;
import org.eclipse.riena.internal.ui.ridgets.swt.uiprocess.DefaultProcessDetailComparator;
import org.eclipse.riena.internal.ui.ridgets.swt.uiprocess.IProcessDetailComparatorContrib;
@@ -34,8 +38,6 @@ import org.eclipse.riena.ui.swt.Statusline;
import org.eclipse.riena.ui.swt.StatuslineUIProcess;
import org.eclipse.riena.ui.swt.uiprocess.ProcessState;
import org.eclipse.riena.ui.swt.uiprocess.ProgressInfoDataObject;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.framework.BundleContext;
/**
* Controls the {@link StatuslineUIProcess} (part of {@link Statusline}).
@@ -290,7 +292,11 @@ public class StatuslineUIProcessRidget extends AbstractRidget implements IStatus
}
public boolean isVisible() {
- return false;
+ return true;
+ }
+
+ public boolean isEnabled() {
+ return true;
}
public void requestFocus() {
@@ -307,7 +313,11 @@ public class StatuslineUIProcessRidget extends AbstractRidget implements IStatus
}
public void setVisible(boolean visible) {
- // allways visible
+ // always visible
+ }
+
+ public void setEnabled(boolean enabled) {
+ // always enabled
}
public String getID() {
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidget.java
index 9b2fd24..e372e40 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidget.java
@@ -52,6 +52,7 @@ import org.eclipse.riena.ui.common.ISortableByColumn;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IColumnFormatter;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ITableRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
@@ -112,7 +113,7 @@ public class TableRidget extends AbstractSelectableIndexedRidget implements ITab
sortableColumnsMap = new HashMap<Integer, Boolean>();
comparatorMap = new HashMap<Integer, Comparator<Object>>();
formatterMap = new HashMap<Integer, IColumnFormatter>();
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
applyEraseListener();
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidget.java
index 57ff86a..be9e742 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidget.java
@@ -32,6 +32,7 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ITextRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
import org.eclipse.riena.ui.ridgets.validation.IValidationRuleStatus;
@@ -57,7 +58,7 @@ public class TextRidget extends AbstractEditableRidget implements ITextRidget {
modifyListener = new SyncModifyListener();
verifyListener = new ValidationListener();
isDirectWriting = false;
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
forceTextToControl(getTextInternal());
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ToggleButtonRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ToggleButtonRidget.java
index 1a3ad8e..cf487c7 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ToggleButtonRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/ToggleButtonRidget.java
@@ -29,7 +29,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.riena.ui.ridgets.IActionListener;
-import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.IToggleButtonRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
@@ -54,7 +54,7 @@ public class ToggleButtonRidget extends AbstractValueRidget implements IToggleBu
actionObserver = new ActionObserver();
textAlreadyInitialized = false;
useRidgetIcon = false;
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean isEnabled = ((Boolean) evt.getNewValue()).booleanValue();
updateSelection(isEnabled);
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TreeRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TreeRidget.java
index 9c420a2..7ed22c7 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TreeRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/TreeRidget.java
@@ -78,6 +78,7 @@ import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IColumnFormatter;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ISelectableRidget;
import org.eclipse.riena.ui.ridgets.ITreeRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
@@ -132,7 +133,7 @@ public class TreeRidget extends AbstractSelectableRidget implements ITreeRidget
selectionTypeEnforcer = new SelectionTypeEnforcer();
doubleClickForwarder = new DoubleClickForwarder();
expansionStack = new LinkedList<ExpansionCommand>();
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
applyEraseListener();
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/uiprocess/UIProcessRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/uiprocess/UIProcessRidget.java
index 2cb7682..1020f0d 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/uiprocess/UIProcessRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/uiprocess/UIProcessRidget.java
@@ -22,6 +22,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.riena.ui.core.uiprocess.IProgressVisualizer;
import org.eclipse.riena.ui.core.uiprocess.ProcessInfo;
import org.eclipse.riena.ui.ridgets.AbstractRidget;
@@ -33,8 +36,6 @@ import org.eclipse.riena.ui.ridgets.uibinding.IBindingPropertyLocator;
import org.eclipse.riena.ui.swt.uiprocess.ICancelListener;
import org.eclipse.riena.ui.swt.uiprocess.UIProcessControl;
import org.eclipse.riena.ui.swt.utils.SWTBindingPropertyLocator;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
/**
* The {@link UIProcessRidget} is not a standard {@link AbstractSWTRidget} as it
@@ -548,6 +549,13 @@ public class UIProcessRidget extends AbstractRidget implements IUIProcessRidget
return false;
}
+ public boolean isEnabled() {
+ if (getWindowShell() != null && !getWindowShell().isDisposed()) {
+ return getWindowShell().isEnabled();
+ }
+ return false;
+ }
+
/**
* request focus of window
*/
@@ -579,6 +587,12 @@ public class UIProcessRidget extends AbstractRidget implements IUIProcessRidget
}
}
+ public void setEnabled(boolean enabled) {
+ if (getWindowShell() != null && !getWindowShell().isDisposed()) {
+ getWindowShell().setEnabled(enabled);
+ }
+ }
+
public String getID() {
if (getUIControl() != null) {
IBindingPropertyLocator locator = SWTBindingPropertyLocator.getInstance();
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractListRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractListRidget.java
index b08ea62..b0aef69 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractListRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractListRidget.java
@@ -52,6 +52,7 @@ import org.eclipse.riena.ui.common.ISortableByColumn;
import org.eclipse.riena.ui.ridgets.IActionListener;
import org.eclipse.riena.ui.ridgets.IColumnFormatter;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.ITableRidget;
/**
@@ -102,7 +103,7 @@ public abstract class AbstractListRidget extends AbstractSelectableIndexedRidget
disableMandatoryMarkers(hasInput());
}
});
- addPropertyChangeListener(IMarkableRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
+ addPropertyChangeListener(IRidget.PROPERTY_ENABLED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean isEnabled = ((Boolean) evt.getNewValue()).booleanValue();
updateEnabled(isEnabled);
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java
index 284bb93..32aebb9 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.riena.ui.ridgets;
-import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
@@ -29,6 +28,7 @@ public abstract class AbstractCompositeRidget extends AbstractRidget implements
private Map<String, IRidget> ridgets;
private PropertyChangeListener propertyChangeListener;
private boolean visible;
+ private boolean enabled = true;
private String toolTip = null;
private boolean blocked;
@@ -55,6 +55,17 @@ public abstract class AbstractCompositeRidget extends AbstractRidget implements
}
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ if (this.enabled != enabled) {
+ this.enabled = enabled;
+ updateEnabled();
+ }
+ }
+
public IComplexComponent getUIControl() {
return uiControl;
}
@@ -68,6 +79,7 @@ public abstract class AbstractCompositeRidget extends AbstractRidget implements
this.uiControl = (IComplexComponent) uiControl;
updateVisible();
+ updateEnabled();
updateToolTipText();
}
@@ -162,18 +174,21 @@ public abstract class AbstractCompositeRidget extends AbstractRidget implements
////////////////////
/**
- * The default implementation can update the visibility of a
- * java.awt.Component.
- * <p>
- * Subclasses should override, to update the visibility of their UI controls
- * in an appropriate way.
+ * Updates the visibility of the complex UI control (and of the UI controls
+ * it contains). This default implementation does nothing and should be
+ * overridden by subclasses.
*/
protected void updateVisible() {
- // this java.awt.Component is an artefact of our swing legacy
- // and could be removed when swing support is no longer needed
- if (uiControl != null && uiControl instanceof Component) {
- ((Component) uiControl).setVisible(this.visible);
- }
+ // empty default implementation
+ }
+
+ /**
+ * Updates the enabled state of the complex UI control (and of the UI
+ * controls it contains). This default implementation does nothing and
+ * should be overridden by subclasses.
+ */
+ protected void updateEnabled() {
+ // empty default implementation
}
/**
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractMarkerSupport.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractMarkerSupport.java
index 820bf86..e3666d8 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractMarkerSupport.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractMarkerSupport.java
@@ -163,7 +163,7 @@ public abstract class AbstractMarkerSupport {
Boolean oldValue = isEnabled(oldMarkers);
Boolean newValue = isEnabled(getMarkers());
if (!oldValue.equals(newValue)) {
- PropertyChangeEvent evt = new PropertyChangeEvent(ridget, IMarkableRidget.PROPERTY_ENABLED, oldValue,
+ PropertyChangeEvent evt = new PropertyChangeEvent(ridget, IRidget.PROPERTY_ENABLED, oldValue,
newValue);
propertyChangeSupport.firePropertyChange(evt);
}
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IActionRidget.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IActionRidget.java
index 88d94dd..047f9f4 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IActionRidget.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IActionRidget.java
@@ -14,10 +14,10 @@ package org.eclipse.riena.ui.ridgets;
* A ridget for UI controls that allow an action to be performed on them, like
* clicking a button.
*/
-public interface IActionRidget extends IMarkableRidget {
+public interface IActionRidget extends IRidget {
- public static final String BASE_ID_TOOLBARACTION = "toolbarAction."; //$NON-NLS-1$
- public static final String BASE_ID_MENUACTION = "menuAction."; //$NON-NLS-1$
+ String BASE_ID_TOOLBARACTION = "toolbarAction."; //$NON-NLS-1$
+ String BASE_ID_MENUACTION = "menuAction."; //$NON-NLS-1$
/**
* Add an action listener to call back.
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IMarkableRidget.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IMarkableRidget.java
index 0c21a6f..2450dbc 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IMarkableRidget.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IMarkableRidget.java
@@ -28,11 +28,7 @@ public interface IMarkableRidget extends IRidget, IMarkable {
* added or removed ("marker").
*/
String PROPERTY_MARKER = "marker"; //$NON-NLS-1$
- /**
- * The name of the PropertyChangeEvent that will be fired when the
- * enablement state of this ridget is changed ("enabled").
- */
- String PROPERTY_ENABLED = "enabled"; //$NON-NLS-1$
+
/**
* The name of the PropertyChangeEvent that will be fired when the 'output
* only' state of this ridget is changed ("output").
@@ -40,20 +36,6 @@ public interface IMarkableRidget extends IRidget, IMarkable {
String PROPERTY_OUTPUT_ONLY = "output"; //$NON-NLS-1$
/**
- * Returns {@code false} if any DisabledMarker was added, {@code true}
- * otherwise.
- */
- boolean isEnabled();
-
- /**
- * Adds and removes a default DisabledMarker.
- *
- * @param enabled
- * The new enabled state.
- */
- void setEnabled(boolean enabled);
-
- /**
* @return Indicates whether any ErrorMarker was added.
*/
boolean isErrorMarked();
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IRidget.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IRidget.java
index 7a48eee..9d0c410 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IRidget.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IRidget.java
@@ -14,6 +14,7 @@ import java.beans.PropertyChangeListener;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+
import org.eclipse.riena.ui.ridgets.listener.IFocusListener;
/**
@@ -33,6 +34,12 @@ public interface IRidget {
String PROPERTY_TOOLTIP = "tooltip"; //$NON-NLS-1$
/**
+ * The name of the PropertyChangeEvent that will be fired when the
+ * enablement state of this ridget is changed ("enabled").
+ */
+ String PROPERTY_ENABLED = "enabled"; //$NON-NLS-1$
+
+ /**
* @return Indicates whether the UI-control is visible.
*/
boolean isVisible();
@@ -46,6 +53,19 @@ public interface IRidget {
void setVisible(boolean visible);
/**
+ * @return Indicates whether the UI-control is enabled.
+ */
+ boolean isEnabled();
+
+ /**
+ * Sets whether the UI-control is enabled.
+ *
+ * @param visible
+ * The new enabled state.
+ */
+ void setEnabled(boolean enabled);
+
+ /**
* Getter to access the UI-toolkit specific UI-control. Allows modifications
* of the UI-control that are not supported by the Ridgets API.
*
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/MessageBox.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/MessageBox.java
index fdb38fb..83e7e30 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/MessageBox.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/MessageBox.java
@@ -14,10 +14,11 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.riena.ui.swt.utils.IPropertyNameProvider;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.riena.ui.swt.utils.IPropertyNameProvider;
+
/**
* The <code>MessageBox</code> pops up a standard dialog box to display
* messages.
@@ -153,6 +154,18 @@ public class MessageBox implements IPropertyNameProvider {
}
/**
+ * Set the enabled state of a dialog that is shown.
+ *
+ * @param enabled
+ * the new enabled state.
+ */
+ public void setEnabled(boolean enabled) {
+ if (messageDialog != null) {
+ messageDialog.getShell().setEnabled(enabled);
+ }
+ }
+
+ /**
* Adds a focus listener.
*
* @param listener