summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-04-28 10:39:11 (EDT)
committerCarsten Drossel2009-04-28 10:39:11 (EDT)
commit4bebfafec21841f331641e23e5b5d1c46455b556 (patch)
tree5635f3e4bbe92b57af0dbaa8c521b4b885a7c65c
parentea3853f203b7662b0414c5c65917bdb9f22da0ef (diff)
downloadorg.eclipse.riena-4bebfafec21841f331641e23e5b5d1c46455b556.zip
org.eclipse.riena-4bebfafec21841f331641e23e5b5d1c46455b556.tar.gz
org.eclipse.riena-4bebfafec21841f331641e23e5b5d1c46455b556.tar.bz2
bug 261980 - firing 'showing' property change event to hide markers of ridgets whose widgets become invisible because a parent becomes invisible
-rw-r--r--org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeController.java1
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeControllerTest.java2
-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.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTWidgetRidget.java75
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractMarkerSupport.java5
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/IRidget.java10
6 files changed, 94 insertions, 1 deletions
diff --git a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeController.java b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeController.java
index 9e50cdc..8560523 100644
--- a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeController.java
+++ b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeController.java
@@ -166,6 +166,7 @@ public abstract class NavigationNodeController<N extends INavigationNode<?>> ext
*/
public void addRidget(String id, IRidget ridget) {
ridget.addPropertyChangeListener(IBasicMarkableRidget.PROPERTY_MARKER, propertyChangeListener);
+ ridget.addPropertyChangeListener(IRidget.PROPERTY_SHOWING, propertyChangeListener);
ridgets.put(id, ridget);
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeControllerTest.java
index 4c1746c..107c40c 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/controllers/NavigationNodeControllerTest.java
@@ -83,7 +83,7 @@ public class NavigationNodeControllerTest extends TestCase {
PropertyChangeSupport support = ReflectionUtils.getHidden(ridget, "propertyChangeSupport");
assertNotNull(support.getPropertyChangeListeners());
- assertEquals(1, support.getPropertyChangeListeners().length);
+ assertEquals(2, support.getPropertyChangeListeners().length);
}
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 78dd8bb..38be144 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
@@ -115,6 +115,7 @@ public abstract class AbstractSWTRidget extends AbstractSWTWidgetRidget {
*/
@Override
protected final void installListeners() {
+ super.installListeners();
if (getUIControl() != null) {
getUIControl().addFocusListener(focusManager);
}
@@ -129,6 +130,7 @@ public abstract class AbstractSWTRidget extends AbstractSWTWidgetRidget {
if (getUIControl() != null) {
getUIControl().removeFocusListener(focusManager);
}
+ super.uninstallListeners();
}
@Override
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTWidgetRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTWidgetRidget.java
index e018c55..809b143 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTWidgetRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractSWTWidgetRidget.java
@@ -15,7 +15,12 @@ import java.util.Collection;
import java.util.Collections;
import org.eclipse.core.databinding.BindingException;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.riena.core.marker.IMarker;
@@ -47,6 +52,7 @@ public abstract class AbstractSWTWidgetRidget extends AbstractRidget implements
private OutputMarker outputMarker;
private HiddenMarker hiddenMarker;
private AbstractMarkerSupport markerSupport;
+ private Listener visibilityListener;
/**
* Checks that the given uiControl is assignable to the the given type.
@@ -244,6 +250,22 @@ public abstract class AbstractSWTWidgetRidget extends AbstractRidget implements
* ridget.
*/
protected void installListeners() {
+ if (getUIControl() != null) {
+ if (visibilityListener == null) {
+ visibilityListener = new VisibilityListener();
+ }
+ addHierarchieVisibilityListener(getUIControl(), visibilityListener);
+ }
+ }
+
+ private void addHierarchieVisibilityListener(Widget widget, Listener listener) {
+ if (widget != null && !widget.isDisposed()) {
+ widget.addListener(SWT.Show, listener);
+ widget.addListener(SWT.Hide, listener);
+ }
+ if (widget instanceof Control) {
+ addHierarchieVisibilityListener(((Control) widget).getParent(), listener);
+ }
}
/**
@@ -251,6 +273,19 @@ public abstract class AbstractSWTWidgetRidget extends AbstractRidget implements
* unbound from the ridget.
*/
protected void uninstallListeners() {
+ if (getUIControl() != null && visibilityListener != null) {
+ removeHierarchieVisibilityListener(getUIControl(), visibilityListener);
+ }
+ }
+
+ private void removeHierarchieVisibilityListener(Widget widget, Listener listener) {
+ if (widget != null && !widget.isDisposed()) {
+ widget.removeListener(SWT.Show, listener);
+ widget.removeListener(SWT.Hide, listener);
+ }
+ if (widget instanceof Control) {
+ addHierarchieVisibilityListener(((Control) widget).getParent(), listener);
+ }
}
protected Image getManagedImage(String key) {
@@ -425,4 +460,44 @@ public abstract class AbstractSWTWidgetRidget extends AbstractRidget implements
}
}
+ // helping classes
+ // ////////////////
+
+ private class VisibilityListener implements Listener {
+
+ public void handleEvent(Event event) {
+ if (getUIControl() != null && isRelevant(event, getUIControl())) {
+ // visibility change of this Ridget in progress. Fire event
+ // when it is completed
+ getUIControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (getUIControl() != null && !getUIControl().isDisposed()) {
+ if (markerSupport == null) {
+ markerSupport = createMarkerSupport();
+ }
+ markerSupport.fireShowingPropertyChangeEvent();
+ }
+ }
+ });
+ }
+ }
+
+ private boolean isRelevant(Event event, Widget widget) {
+ if (widget.isDisposed()) {
+ return false;
+ }
+ if (event.widget == widget) {
+ return true;
+ }
+ if (widget instanceof Control) {
+ Composite parent = ((Control) widget).getParent();
+ if (parent != null) {
+ return isRelevant(event, parent);
+ }
+ }
+ return false;
+ }
+
+ }
+
}
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 c0bcc56..a8170d5 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
@@ -183,6 +183,11 @@ public abstract class AbstractMarkerSupport {
}
}
+ public void fireShowingPropertyChangeEvent() {
+ propertyChangeSupport.firePropertyChange(IRidget.PROPERTY_SHOWING, !ridget.isVisible(), ridget.isVisible());
+ updateMarkers();
+ }
+
protected boolean hasHiddenMarkers() {
return !getRidget().getMarkersOfType(HiddenMarker.class).isEmpty();
}
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 9d0c410..f4b2632 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
@@ -40,6 +40,16 @@ public interface IRidget {
String PROPERTY_ENABLED = "enabled"; //$NON-NLS-1$
/**
+ * The name of the PropertyChangeEvent that is fired when the actual
+ * visibility of the Ridget changes while the Ridget is bound to a widget -
+ * either the visibility of the Ridget itself or the visibility of a parent
+ * of the associated widget.
+ *
+ * @see IRidget#isVisible()
+ */
+ String PROPERTY_SHOWING = "showing"; //$NON-NLS-1$
+
+ /**
* @return Indicates whether the UI-control is visible.
*/
boolean isVisible();