summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-05-23 08:39:20 (EDT)
committerSteffen Kriese2011-05-23 08:39:20 (EDT)
commit008a415f3470e118a499a276eec280a32e2a2f73 (patch)
treefeb3660b05c41af0f346ab44174ec98eff9b9cb3
parent4f2a81cc072a316314dc0cb25750a6f00c8f6476 (diff)
downloadorg.eclipse.riena-008a415f3470e118a499a276eec280a32e2a2f73.zip
org.eclipse.riena-008a415f3470e118a499a276eec280a32e2a2f73.tar.gz
org.eclipse.riena-008a415f3470e118a499a276eec280a32e2a2f73.tar.bz2
RESOLVED - bug 346862: SingleChoiceRidget does not visualize marker in statusline
https://bugs.eclipse.org/bugs/show_bug.cgi?id=346862
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidgetTest.java13
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractChoiceRidget.java71
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MultipleChoiceRidget.java46
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidget.java2
4 files changed, 86 insertions, 46 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidgetTest.java
index bc54f88..361dfd7 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/SingleChoiceRidgetTest.java
@@ -76,6 +76,19 @@ public final class SingleChoiceRidgetTest extends MarkableRidgetTest {
// testing methods
// ////////////////
+ public void testHasFocus() throws Exception {
+ final ISingleChoiceRidget choiceRidget = getRidget();
+ assertNotNull(choiceRidget);
+
+ final ChoiceComposite widget = getWidget();
+ assertNotNull(widget);
+
+ assertFalse(choiceRidget.hasFocus());
+ getRidget().setUIControl(widget);
+ widget.getChildren()[0].setFocus();
+ assertTrue(getRidget().hasFocus());
+ }
+
/**
* Test that the control is mapped to the expected ridget.
*/
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractChoiceRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractChoiceRidget.java
new file mode 100644
index 0000000..02f14f7
--- /dev/null
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractChoiceRidget.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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 org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
+import org.eclipse.riena.ui.swt.utils.SWTControlFinder;
+
+/**
+ * Baseclass for all ChoiceRidgets.
+ */
+public abstract class AbstractChoiceRidget extends AbstractSWTRidget {
+
+ @Override
+ public boolean hasFocus() {
+ if (getUIControl() != null) {
+ final Control control = getUIControl();
+
+ if (control.isFocusControl()) {
+ return true;
+ }
+
+ if (!(control instanceof Composite)) {
+ return false;
+ }
+
+ final ChildFocusChecker checker = new ChildFocusChecker((Composite) control);
+ checker.run();
+
+ return checker.childHasFocus;
+ }
+ return false;
+ }
+
+ /**
+ * Iterates over the child controls of a given composite and checks if one
+ * them has the focus.
+ */
+ private static class ChildFocusChecker extends SWTControlFinder {
+
+ private boolean childHasFocus = false;
+
+ public ChildFocusChecker(final Composite composite) {
+ super(composite);
+ }
+
+ @Override
+ public void handleBoundControl(final Control control, final String bindingProperty) {
+ super.handleControl(control);
+ }
+
+ @Override
+ public void handleControl(final Control control) {
+ super.handleControl(control);
+ if (control.isFocusControl()) {
+ childHasFocus = true;
+ }
+ }
+ }
+
+}
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 44c7c63..b6c87ff 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
@@ -46,13 +46,12 @@ import org.eclipse.riena.ui.ridgets.swt.AbstractSWTRidget;
import org.eclipse.riena.ui.ridgets.swt.MarkerSupport;
import org.eclipse.riena.ui.swt.ChoiceComposite;
import org.eclipse.riena.ui.swt.lnf.LnFUpdater;
-import org.eclipse.riena.ui.swt.utils.SWTControlFinder;
import org.eclipse.riena.ui.swt.utils.SwtUtilities;
/**
* Ridget for a {@link ChoiceComposite} widget with multiple selection.
*/
-public class MultipleChoiceRidget extends AbstractSWTRidget implements IMultipleChoiceRidget {
+public class MultipleChoiceRidget extends AbstractChoiceRidget implements IMultipleChoiceRidget {
private final static LnFUpdater LNF_UPDATER = new LnFUpdater();
@@ -90,49 +89,6 @@ public class MultipleChoiceRidget extends AbstractSWTRidget implements IMultiple
}
@Override
- public boolean hasFocus() {
- if (getUIControl() != null) {
- final Control control = getUIControl();
-
- if (control.isFocusControl()) {
- return true;
- }
-
- if (!(control instanceof Composite)) {
- return false;
- }
-
- final ChildFocusChecker checker = new ChildFocusChecker((Composite) control);
- checker.run();
-
- return checker.childHasFocus;
- }
- return false;
- }
-
- private static class ChildFocusChecker extends SWTControlFinder {
-
- private boolean childHasFocus = false;
-
- public ChildFocusChecker(final Composite composite) {
- super(composite);
- }
-
- @Override
- public void handleBoundControl(final Control control, final String bindingProperty) {
- super.handleControl(control);
- }
-
- @Override
- public void handleControl(final Control control) {
- super.handleControl(control);
- if (control.isFocusControl()) {
- childHasFocus = true;
- }
- }
- }
-
- @Override
protected void bindUIControl() {
if (optionsBinding != null) {
createChildren(getUIControl());
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 cc96149..9214638 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
@@ -52,7 +52,7 @@ import org.eclipse.riena.ui.swt.utils.SwtUtilities;
/**
* Ridget for a {@link ChoiceComposite} widget with single selection.
*/
-public class SingleChoiceRidget extends AbstractSWTRidget implements ISingleChoiceRidget {
+public class SingleChoiceRidget extends AbstractChoiceRidget implements ISingleChoiceRidget {
private final static LnFUpdater LNF_UPDATER = new LnFUpdater();