summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-08-30 05:28:47 (EDT)
committerSteffen Kriese2011-08-30 05:28:47 (EDT)
commitd09d457e970dc16625113918e6426b63154631a4 (patch)
treedcff2a0f1e3703ed5d87b7145786b85cfe109c06
parent2416bb0cc1ef0492baf95859cbd97e448f480a74 (diff)
downloadorg.eclipse.riena-d09d457e970dc16625113918e6426b63154631a4.zip
org.eclipse.riena-d09d457e970dc16625113918e6426b63154631a4.tar.gz
org.eclipse.riena-d09d457e970dc16625113918e6426b63154631a4.tar.bz2
cleand up fix for lost focus in ridgets due to disabled parentCompositev20110830_4_0_0_stable
-rw-r--r--org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java18
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/SubModuleControllerTest.java24
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTRidget.java2
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractRidget.java9
4 files changed, 46 insertions, 7 deletions
diff --git a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java
index cc5a787..c75915f 100644
--- a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java
+++ b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java
@@ -189,14 +189,24 @@ public class SubModuleController extends NavigationNodeController<ISubModuleNode
@Override
public void setBlocked(final boolean blocked) {
super.setBlocked(blocked);
- resetFocusRequest(getRidgets());
+ restoreFocusRequestFromRidget(getRidgets());
}
- private void resetFocusRequest(final Collection<? extends IRidget> collection) {
+ /**
+ * Checks all ridgets recursively in this controller, if a previous call to
+ * setFocus() failed and tries to set the focus again.
+ * <p>
+ * SWT has the limitation that it doesn't set the focus if the parent
+ * composite is disabled. Therefore we have to try to restore the first
+ * previous call to setFocus(), while the view is blocked.
+ *
+ * @param collection
+ * the collection to check
+ */
+ private void restoreFocusRequestFromRidget(final Collection<? extends IRidget> collection) {
for (final IRidget ridget : collection) {
-
if (ridget instanceof IComplexRidget) {
- resetFocusRequest(((IComplexRidget) ridget).getRidgets());
+ restoreFocusRequestFromRidget(((IComplexRidget) ridget).getRidgets());
} else {
if (ridget instanceof AbstractRidget) {
if (((AbstractRidget) ridget).isRetryRequestFocus()) {
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/SubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/SubModuleControllerTest.java
index 83d1dfa..6949d29 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/SubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/SubModuleControllerTest.java
@@ -38,6 +38,30 @@ import org.eclipse.riena.ui.ridgets.IWindowRidget;
@NonUITestCase
public class SubModuleControllerTest extends TestCase {
+ public void testRestoreFocusFromRidgetAfterBlock() {
+ final Display display = Display.getDefault();
+ final Shell shell = new Shell(display);
+ shell.pack();
+ shell.setVisible(true);
+
+ final Realm realm = SWTObservables.getRealm(display);
+ assertNotNull(realm);
+ ReflectionUtils.invokeHidden(realm, "setDefault", realm); //$NON-NLS-1$
+
+ final SubModuleNode node = new SubModuleNode();
+ node.setNavigationProcessor(new NavigationProcessor());
+ final SubModuleController controller = new SubModuleController(node);
+
+ final LabelRidget labelRidget = new LabelRidget();
+ labelRidget.setRetryRequestFocus(true);
+ controller.addRidget("label", labelRidget); //$NON-NLS-1$
+
+ controller.setBlocked(true);
+ labelRidget.setRetryRequestFocus(true);
+ controller.setBlocked(false);
+ assertFalse(labelRidget.isRetryRequestFocus());
+ }
+
/**
* Tests the method {@code getFullTitle()}.
*/
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTRidget.java
index aea2f9b..7545019 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTRidget.java
@@ -52,6 +52,8 @@ public abstract class AbstractSWTRidget extends AbstractSWTWidgetRidget {
if (isFocusable()) {
if (getUIControl() != null) {
final Control control = getUIControl();
+ // if setFocus() fails because e.g. the parent is disabled
+ // the state has to be saved, so it can be restored in submoduleController.unblockView()
setRetryRequestFocus(!control.setFocus());
}
}
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractRidget.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractRidget.java
index c0257b3..0fbf569 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractRidget.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractRidget.java
@@ -264,9 +264,10 @@ public abstract class AbstractRidget implements IRidget {
}
/**
- * TODO SKR
+ * Returns <code>true</code> if retryFocusRequest has been set otherwise
+ * <code>false</code>
*
- * @return
+ * @return the retryRequestFocus flag
* @since 4.0
*/
public boolean isRetryRequestFocus() {
@@ -274,7 +275,9 @@ public abstract class AbstractRidget implements IRidget {
}
/**
- * TODO SKR
+ * Marks this ridget, that a call to requestFocus() failed, because e.g. the
+ * parent is disabled. Afterwards this flag can be checked to restore the
+ * focus.
*
* @since 4.0
*/