summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-01-27 07:13:11 (EST)
committerCarsten Drossel2009-01-27 07:13:11 (EST)
commitdf05954db2e8d4ae964db5df6f5cf7e76acb65ca (patch)
tree24bd667bc90f8fb573396f0f3a40a6d1fdf59266
parentfb791df9935989f6795924f1493cb3b33e6ba0cb (diff)
downloadorg.eclipse.riena-df05954db2e8d4ae964db5df6f5cf7e76acb65ca.zip
org.eclipse.riena-df05954db2e8d4ae964db5df6f5cf7e76acb65ca.tar.gz
org.eclipse.riena-df05954db2e8d4ae964db5df6f5cf7e76acb65ca.tar.bz2
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidget.java78
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupView.java8
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationView.java33
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java84
-rw-r--r--org.eclipse.riena.navigation.ui/src/org/eclipse/riena/internal/navigation/ui/marker/TypeHierarchyMarkerStrategy.java2
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidgetTest.java8
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidgetTest.java64
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupViewTest.java15
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationViewTest.java30
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleViewTest.java39
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidget.java2
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/uiprocess/UIProcessRidget.java4
12 files changed, 267 insertions, 100 deletions
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidget.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidget.java
index beaf8f2..18a6c18 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidget.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidget.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.riena.navigation.IApplicationNode;
import org.eclipse.riena.navigation.ISubApplicationNode;
+import org.eclipse.riena.navigation.listener.ApplicationNodeListener;
import org.eclipse.riena.navigation.listener.SubApplicationNodeListener;
import org.eclipse.riena.navigation.ui.swt.lnf.renderer.SubApplicationSwitcherRenderer;
import org.eclipse.riena.ui.core.marker.DisabledMarker;
@@ -41,6 +42,8 @@ public class SubApplicationSwitcherWidget extends Canvas {
private TabSelector tabSelector;
private PaintDelegation paintDelegation;
private Control control;
+ private ApplicationListener applicationListener;
+ private SubApplicationListener subApplicationListener;
/**
* Creates a new widget.
@@ -58,6 +61,8 @@ public class SubApplicationSwitcherWidget extends Canvas {
super(parent, style | SWT.DOUBLE_BUFFERED);
control = this;
items = new ArrayList<SubApplicationItem>();
+ applicationListener = new ApplicationListener();
+ subApplicationListener = new SubApplicationListener();
registerItems(application);
addListeners();
@@ -185,33 +190,35 @@ public class SubApplicationSwitcherWidget extends Canvas {
*/
private void registerItems(IApplicationNode applicationModel) {
+ applicationModel.addListener(applicationListener);
+
List<ISubApplicationNode> subApps = applicationModel.getChildren();
for (ISubApplicationNode subApp : subApps) {
- addListeners(subApp);
- SubApplicationItem item = new SubApplicationItem(this, subApp);
- item.setIcon(subApp.getIcon());
- item.setLabel(subApp.getLabel());
- getItems().add(item);
+ registerSubApplication(subApp);
}
}
- /**
- * Adds a listener to the given sub-application.
- *
- * @param subApp
- * - node of sub-application
- */
- private void addListeners(ISubApplicationNode subApp) {
+ private void registerSubApplication(ISubApplicationNode subApp) {
+ subApp.addListener(subApplicationListener);
+ SubApplicationItem item = new SubApplicationItem(this, subApp);
+ item.setIcon(subApp.getIcon());
+ item.setLabel(subApp.getLabel());
+ getItems().add(item);
+ }
- subApp.addListener(new SubApplicationNodeListener() {
- @Override
- public void markersChanged(ISubApplicationNode source) {
- super.markersChanged(source);
- redraw();
+ private void unregisterSubApplication(ISubApplicationNode subApp) {
+ subApp.removeListener(subApplicationListener);
+ SubApplicationItem itemToRemove = null;
+ for (SubApplicationItem item : getItems()) {
+ if (item.getSubApplicationNode().equals(subApp)) {
+ itemToRemove = item;
+ break;
}
- });
-
+ }
+ if (itemToRemove != null) {
+ getItems().remove(itemToRemove);
+ }
}
/**
@@ -233,4 +240,37 @@ public class SubApplicationSwitcherWidget extends Canvas {
super.dispose();
}
+ private final class SubApplicationListener extends SubApplicationNodeListener {
+
+ @Override
+ public void markersChanged(ISubApplicationNode source) {
+ redraw();
+ }
+
+ /**
+ * @see org.eclipse.riena.navigation.listener.NavigationNodeListener#disposed(org.eclipse.riena.navigation.INavigationNode)
+ */
+ @Override
+ public void disposed(ISubApplicationNode source) {
+ unregisterSubApplication(source);
+ redraw();
+ }
+ }
+
+ private final class ApplicationListener extends ApplicationNodeListener {
+
+ @Override
+ public void childRemoved(IApplicationNode source, ISubApplicationNode childRemoved) {
+ unregisterSubApplication(childRemoved);
+ redraw();
+ }
+
+ @Override
+ public void childAdded(IApplicationNode source, ISubApplicationNode childAdded) {
+ registerSubApplication(childAdded);
+ redraw();
+ }
+
+ }
+
}
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupView.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupView.java
index 8dd939b..0d9edeb 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupView.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupView.java
@@ -189,6 +189,7 @@ public class ModuleGroupView extends Composite implements INavigationNodeView<IC
@Override
public void disposed(IModuleGroupNode source) {
super.disposed(source);
+ unbind();
dispose();
}
@@ -198,8 +199,13 @@ public class ModuleGroupView extends Composite implements INavigationNodeView<IC
* @see org.eclipse.riena.navigation.ui.swt.views.INavigationNodeView#calculateBounds(int)
*/
public int calculateBounds(int positionHint) {
+
+ if (isDisposed()) {
+ return 0;
+ }
+
Point p = new Point(0, 0);
- if (this.getNavigationNode().isVisible()) {
+ if (getNavigationNode() != null && getNavigationNode().isVisible()) {
p = computeSize(SWT.DEFAULT, SWT.DEFAULT);
}
FormData fd = new FormData();
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationView.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationView.java
index 5f0e394..a357028 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationView.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationView.java
@@ -21,6 +21,7 @@ import org.eclipse.riena.internal.ui.ridgets.swt.uiprocess.UIProcessRidget;
import org.eclipse.riena.navigation.ISubApplicationNode;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.listener.NavigationTreeObserver;
+import org.eclipse.riena.navigation.listener.SubApplicationNodeListener;
import org.eclipse.riena.navigation.listener.SubModuleNodeListener;
import org.eclipse.riena.navigation.model.SubApplicationNode;
import org.eclipse.riena.navigation.ui.controllers.SubApplicationController;
@@ -67,6 +68,7 @@ public class SubApplicationView implements INavigationNodeView<SubApplicationCon
private AbstractViewBindingDelegate binding;
private SubApplicationController subApplicationController;
+ private SubApplicationListener subApplicationListener;
private SubApplicationNode subApplicationNode;
private List<Object> uiControls;
private static IBindingManager menuItemBindingManager;
@@ -114,6 +116,9 @@ public class SubApplicationView implements INavigationNodeView<SubApplicationCon
bindMenuAndToolItems(controller);
controller.afterBind();
}
+
+ subApplicationListener = new SubApplicationListener();
+ getNavigationNode().addListener(subApplicationListener);
}
private void bindMenuAndToolItems(IController controller) {
@@ -225,8 +230,18 @@ public class SubApplicationView implements INavigationNodeView<SubApplicationCon
}
public void unbind() {
- // TODO impl !!
+ if (getNavigationNode() != null) {
+
+ getNavigationNode().removeListener(subApplicationListener);
+ if (getNavigationNode().getNavigationNodeController() instanceof IController) {
+ IController controller = (IController) getNavigationNode().getNavigationNodeController();
+ binding.unbind(controller);
+ if (menuItemBindingManager != null) {
+ menuItemBindingManager.unbind(controller, getUIControls());
+ }
+ }
+ }
}
/**
@@ -426,13 +441,8 @@ public class SubApplicationView implements INavigationNodeView<SubApplicationCon
}
public void addUpdateListener(IComponentUpdateListener listener) {
- // TODO Auto-generated method stub
-
- }
+ throw new UnsupportedOperationException();
- public int calculateBounds(int positionHint) {
- // TODO Auto-generated method stub
- return 0;
}
public SubApplicationNode getNavigationNode() {
@@ -590,4 +600,13 @@ public class SubApplicationView implements INavigationNodeView<SubApplicationCon
return uiControls;
}
+ private class SubApplicationListener extends SubApplicationNodeListener {
+
+ @Override
+ public void disposed(ISubApplicationNode source) {
+ unbind();
+ }
+
+ }
+
}
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java
index 8a73e73..bc479fe 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java
@@ -10,16 +10,12 @@
*******************************************************************************/
package org.eclipse.riena.navigation.ui.swt.views;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.core.util.InvocationTargetFailure;
-import org.eclipse.riena.core.util.ListenerList;
import org.eclipse.riena.internal.navigation.ui.swt.Activator;
import org.eclipse.riena.navigation.IApplicationNode;
import org.eclipse.riena.navigation.INavigationNode;
@@ -30,7 +26,6 @@ import org.eclipse.riena.navigation.listener.SubModuleNodeListener;
import org.eclipse.riena.navigation.model.SubModuleNode;
import org.eclipse.riena.navigation.ui.controllers.ControllerUtils;
import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
-import org.eclipse.riena.navigation.ui.swt.presentation.SwtViewId;
import org.eclipse.riena.navigation.ui.swt.presentation.SwtViewProviderAccessor;
import org.eclipse.riena.ui.ridgets.swt.uibinding.AbstractViewBindingDelegate;
import org.eclipse.riena.ui.ridgets.swt.uibinding.DefaultSwtBindingDelegate;
@@ -57,9 +52,8 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
private final static Logger LOGGER = Activator.getDefault().getLogger(SubModuleView.class.getName());
- private Map<ISubModuleNode, C> node2Controller;
private AbstractViewBindingDelegate binding;
- private C currentController;
+ private SubModuleController currentController;
/**
* This node is used when creating this ViewPart inside an RCP application.
@@ -72,7 +66,6 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
/** The title bar at the top of the view. May be null if running in RCP */
private EmbeddedTitleBar title;
- private ListenerList<IComponentUpdateListener> updateListeners;
private Composite parentComposite;
private Composite contentComposite;
@@ -86,8 +79,6 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
*/
public SubModuleView() {
binding = createBinding();
- node2Controller = new HashMap<ISubModuleNode, C>();
- updateListeners = new ListenerList<IComponentUpdateListener>(IComponentUpdateListener.class);
}
/**
@@ -135,18 +126,13 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
/**
* @return the controller
*/
- public C getController() {
- return node2Controller.get(getNavigationNode());
- }
+ public SubModuleController getController() {
- /**
- * @param controller
- * the controller to set
- */
- public void setController(C controller) {
- if (node2Controller.get(getNavigationNode()) == null) {
- node2Controller.put(getNavigationNode(), controller);
+ if (getNavigationNode() != null
+ && getNavigationNode().getNavigationNodeController() instanceof SubModuleController) {
+ return (SubModuleController) getNavigationNode().getNavigationNodeController();
}
+ return null;
}
@Override
@@ -154,11 +140,10 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
this.parentComposite = parent;
observeRoot();
C controller = createController(getNavigationNode());
- setController(controller);
if (controller != null) {
setPartName(controller.getNavigationNode().getLabel());
}
- Composite contentComposite = createContentComposite(parent);
+ contentComposite = createContentComposite(parent);
basicCreatePartControl(contentComposite);
createViewFacade();
doBinding();
@@ -204,8 +189,8 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
title.setLayoutData(formData);
}
- contentComposite = new Composite(parent, SWT.DOUBLE_BUFFERED);
- contentComposite.setBackground(bgColor);
+ Composite composite = new Composite(parent, SWT.DOUBLE_BUFFERED);
+ composite.setBackground(bgColor);
FormData formData = new FormData();
if (title != null) {
formData.top = new FormAttachment(title, 0, 0);
@@ -215,13 +200,13 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
formData.left = new FormAttachment(0, 0);
formData.bottom = new FormAttachment(100);
formData.right = new FormAttachment(100);
- contentComposite.setLayoutData(formData);
+ composite.setLayoutData(formData);
// initialize cursors
cursorWait = createWaitCursor();
cursorArrow = createArrowCursor();
- return contentComposite;
+ return composite;
}
protected Cursor createArrowCursor() {
@@ -238,43 +223,33 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
node = node.getParent();
}
NavigationTreeObserver navigationTreeObserver = new NavigationTreeObserver();
- navigationTreeObserver.addListener(new MySubModuleNodeListener());
+ navigationTreeObserver.addListener(new SubModuleNodesListener());
IApplicationNode appNode = node.getTypecastedAdapter(IApplicationNode.class);
if (appNode != null) {
navigationTreeObserver.addListenerTo(appNode);
}
}
- protected void activate(ISubModuleNode source) {
- SwtViewId id = SwtViewProviderAccessor.getViewProvider().getSwtViewId(source);
- if (getViewSite().getId().equals(id.getId())) {
- doBinding();
- }
- }
-
- private final class MySubModuleNodeListener extends SubModuleNodeListener {
+ /**
+ * A listener for all submodules in the navigation tree! Needed i.e. to
+ * support shared views. When adding a method be sure to check the node.
+ */
+ private final class SubModuleNodesListener extends SubModuleNodeListener {
@Override
public void activated(ISubModuleNode source) {
- super.activated(source);
- activate(source);
+ if (source.equals(getNavigationNode())) {
+ doBinding();
+ }
}
@Override
public void block(ISubModuleNode source, boolean block) {
- super.block(source, block);
if (source.equals(getNavigationNode())) {
ControllerUtils.blockRidgets(getController().getRidgets(), block);
blockView(block);
}
}
- @Override
- public void afterActivated(ISubModuleNode source) {
-
- super.afterActivated(source);
-
- }
-
}
protected void blockView(boolean block) {
@@ -296,8 +271,8 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
}
protected void createViewFacade() {
- if (!node2Controller.containsKey(getNavigationNode())) {
- setController(createController(getNavigationNode()));
+ if (getController() == null) {
+ createController(getNavigationNode());
}
if (getController() != null) {
binding.injectRidgets(getController());
@@ -336,10 +311,11 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
}
public void addUpdateListener(IComponentUpdateListener listener) {
- updateListeners.add(listener);
+ throw new UnsupportedOperationException();
}
public void bind(SubModuleNode node) {
+
if (currentController != getController()) {
if (currentController != null) {
if (currentController.getNavigationNode().isDisposed()) {
@@ -347,7 +323,7 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
}
binding.unbind(currentController);
}
- if ((getNavigationNode() != null) && (node2Controller.get(getNavigationNode()) == null)) {
+ if ((getNavigationNode() != null) && (getController() == null)) {
createViewFacade();
}
if (getController() != null) {
@@ -372,18 +348,10 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
}
public void unbind() {
-
- SubModuleNode node = getNavigationNode();
- if (node == null) {
- return;
- }
-
- C controller = node2Controller.get(node);
+ SubModuleController controller = getController();
if (controller != null) {
binding.unbind(controller);
- node2Controller.remove(node);
}
-
}
/**
diff --git a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/internal/navigation/ui/marker/TypeHierarchyMarkerStrategy.java b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/internal/navigation/ui/marker/TypeHierarchyMarkerStrategy.java
index 7218bd3..ec5d3f7 100644
--- a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/internal/navigation/ui/marker/TypeHierarchyMarkerStrategy.java
+++ b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/internal/navigation/ui/marker/TypeHierarchyMarkerStrategy.java
@@ -38,7 +38,7 @@ public class TypeHierarchyMarkerStrategy implements IUIProcessMarkupStrategy {
this.marker = marker;
INavigationNode<?> node = baseNode;
Set<Class<?>> markedTyped = new HashSet<Class<?>>();
- while (node.isDeactivated()) {
+ while (node != null && node.isDeactivated()) {
if (!nodeTypeMarked(markedTyped, node.getClass())) {
addNavigationNodeMarker(node);
observeNodeActivity(node);
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidgetTest.java
index e12e2b2..59a6127 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidgetTest.java
@@ -49,12 +49,8 @@ public class MenuRidgetTest extends RienaTestCase {
public void testCheckUIControl() {
MyMenuRidget ridget = new MyMenuRidget();
- try {
- ridget.checkUIControl(null);
- fail("BindingException was expected");
- } catch (BindingException e) {
- ok("BindingException was expected");
- }
+ ridget.checkUIControl(null);
+ ok("no BindingException expected");
Menu menu = new Menu(shell);
MenuItem menuItem = new MenuItem(menu, SWT.NONE);
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidgetTest.java
index a555897..9fdab71 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/SubApplicationSwitcherWidgetTest.java
@@ -157,4 +157,68 @@ public class SubApplicationSwitcherWidgetTest extends TestCase {
}
+ @SuppressWarnings("restriction")
+ public void testDisposeSubApplication() throws Exception {
+
+ IApplicationNode node = new ApplicationNode();
+ SubApplicationNode subNode1 = new SubApplicationNode("sub1");
+ subNode1.setIcon("icon1");
+ node.addChild(subNode1);
+ SubApplicationNode subNode2 = new SubApplicationNode("sub2");
+ subNode2.setIcon("icon2");
+ node.addChild(subNode2);
+ switcher = new SubApplicationSwitcherWidget(shell, SWT.NONE, node);
+ List<SubApplicationItem> items = ReflectionUtils.invokeHidden(switcher, "getItems", (Object[]) null);
+
+ subNode1.dispose();
+
+ assertEquals(1, items.size());
+
+ subNode2.dispose();
+
+ assertTrue(items.isEmpty());
+ }
+
+ @SuppressWarnings("restriction")
+ public void testRemoveSubApplication() throws Exception {
+
+ IApplicationNode node = new ApplicationNode();
+ SubApplicationNode subNode1 = new SubApplicationNode("sub1");
+ subNode1.setIcon("icon1");
+ node.addChild(subNode1);
+ SubApplicationNode subNode2 = new SubApplicationNode("sub2");
+ subNode2.setIcon("icon2");
+ node.addChild(subNode2);
+ switcher = new SubApplicationSwitcherWidget(shell, SWT.NONE, node);
+ List<SubApplicationItem> items = ReflectionUtils.invokeHidden(switcher, "getItems", (Object[]) null);
+
+ node.removeChild(subNode1);
+
+ assertEquals(1, items.size());
+
+ node.removeChild(subNode2);
+
+ assertTrue(items.isEmpty());
+ }
+
+ @SuppressWarnings("restriction")
+ public void testAddSubApplication() throws Exception {
+
+ IApplicationNode node = new ApplicationNode();
+ SubApplicationNode subNode1 = new SubApplicationNode("sub1");
+ subNode1.setIcon("icon1");
+ node.addChild(subNode1);
+ SubApplicationNode subNode2 = new SubApplicationNode("sub2");
+ subNode2.setIcon("icon2");
+ node.addChild(subNode2);
+ switcher = new SubApplicationSwitcherWidget(shell, SWT.NONE, node);
+ List<SubApplicationItem> items = ReflectionUtils.invokeHidden(switcher, "getItems", (Object[]) null);
+
+ SubApplicationNode subNode3 = new SubApplicationNode("sub3");
+ subNode2.setIcon("icon3");
+ node.addChild(subNode3);
+
+ assertEquals(3, items.size());
+ }
+
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupViewTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupViewTest.java
index 54ab209..de7522c 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupViewTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/ModuleGroupViewTest.java
@@ -10,8 +10,12 @@
*******************************************************************************/
package org.eclipse.riena.navigation.ui.swt.views;
+import java.util.List;
+
import junit.framework.TestCase;
+import org.eclipse.riena.core.util.ReflectionUtils;
+import org.eclipse.riena.navigation.listener.ModuleGroupNodeListener;
import org.eclipse.riena.navigation.model.ModuleGroupNode;
import org.eclipse.riena.navigation.model.ModuleNode;
import org.eclipse.riena.navigation.model.NavigationProcessor;
@@ -81,6 +85,17 @@ public class ModuleGroupViewTest extends TestCase {
}
+ public void testUnbind() throws Exception {
+
+ List<ModuleGroupNodeListener> listeners = ReflectionUtils.getHidden(node, "listeners");
+
+ assertEquals(1, listeners.size());
+
+ node.dispose();
+
+ assertTrue(listeners.isEmpty());
+ }
+
private static class MyLnF extends RienaDefaultLnf {
@Override
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationViewTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationViewTest.java
index ef0efbb..5e154c8 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationViewTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubApplicationViewTest.java
@@ -18,6 +18,9 @@ import org.eclipse.jface.action.ContributionItem;
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.internal.ui.ridgets.swt.MenuItemRidget;
import org.eclipse.riena.internal.ui.ridgets.swt.ToolItemRidget;
+import org.eclipse.riena.navigation.listener.ModuleGroupNodeListener;
+import org.eclipse.riena.navigation.model.NavigationProcessor;
+import org.eclipse.riena.navigation.model.SubApplicationNode;
import org.eclipse.riena.navigation.ui.swt.component.MenuCoolBarComposite;
import org.eclipse.riena.tests.collect.UITestCase;
import org.eclipse.riena.ui.ridgets.IActionRidget;
@@ -42,13 +45,18 @@ public class SubApplicationViewTest extends TestCase {
private Shell shell;
private SubApplicationView view;
+ private SubApplicationNode node;
@Override
protected void setUp() throws Exception {
- view = new SubApplicationView();
+ view = new TestSubApplicationView();
shell = new Shell();
SWTBindingPropertyLocator locator = SWTBindingPropertyLocator.getInstance();
locator.setBindingProperty(shell, ApplicationViewAdvisor.SHELL_RIDGET_PROPERTY);
+
+ node = new SubApplicationNode();
+ node.setNavigationProcessor(new NavigationProcessor());
+ view.bind(node);
}
@Override
@@ -250,6 +258,17 @@ public class SubApplicationViewTest extends TestCase {
}
+ public void testUnbind() throws Exception {
+
+ List<ModuleGroupNodeListener> listeners = ReflectionUtils.getHidden(node, "listeners");
+
+ assertEquals(1, listeners.size());
+
+ node.dispose();
+
+ assertTrue(listeners.isEmpty());
+ }
+
private static class MyContributionItem extends ContributionItem {
}
@@ -261,4 +280,13 @@ public class SubApplicationViewTest extends TestCase {
}
+ private class TestSubApplicationView extends SubApplicationView {
+
+ @Override
+ public SubApplicationNode getNavigationNode() {
+ return node;
+ }
+
+ }
+
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleViewTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleViewTest.java
index dae3f5b..d4657b3 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleViewTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleViewTest.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.riena.navigation.ui.swt.views;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.navigation.IModuleNode;
-import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.NavigationNodeId;
import org.eclipse.riena.navigation.model.ApplicationNode;
import org.eclipse.riena.navigation.model.ModuleGroupNode;
@@ -37,6 +39,9 @@ public class SubModuleViewTest extends RienaTestCase {
private SubModuleView<SubModuleController> subModuleNodeView;
private SubModuleNode node;
+ private SubModuleNode anotherNode;
+ private SubModuleNode anotherNodeSameView;
+ private List<SubModuleNode> nodesBoundToView;
@Override
protected void setUp() throws Exception {
@@ -51,6 +56,12 @@ public class SubModuleViewTest extends RienaTestCase {
IModuleNode parent = new ModuleNode(null, "TestModuleLabel");
mgNode.addChild(parent);
+ anotherNode = new SubModuleNode(new NavigationNodeId("testId2"), "TestSubModuleLabel2");
+ parent.addChild(anotherNode);
+ anotherNodeSameView = new SubModuleNode(new NavigationNodeId("testId"), "TestSubModuleLabel3");
+ parent.addChild(anotherNodeSameView);
+ nodesBoundToView = new ArrayList<SubModuleNode>();
+
subModuleNodeView = new TestView();
node = new SubModuleNode(new NavigationNodeId("testId"), "TestSubModuleLabel");
parent.setNavigationNodeController(new ModuleController(parent));
@@ -76,12 +87,34 @@ public class SubModuleViewTest extends RienaTestCase {
assertSame(arrowCursor, parentComposite.getCursor());
}
+ public void testBindOnActivate() throws Exception {
+
+ nodesBoundToView.clear();
+
+ anotherNode.activate();
+
+ assertTrue(nodesBoundToView.isEmpty());
+
+ anotherNodeSameView.activate();
+
+ assertTrue(nodesBoundToView.isEmpty());
+
+ node.activate();
+ assertEquals(1, nodesBoundToView.size());
+ assertSame(node, nodesBoundToView.get(0));
+ }
+
private Cursor waitCursor;
private Cursor arrowCursor;
private class TestView extends SubModuleView<SubModuleController> {
@Override
+ public void bind(SubModuleNode node) {
+ nodesBoundToView.add(node);
+ }
+
+ @Override
protected Cursor createWaitCursor() {
waitCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_WAIT);
return waitCursor;
@@ -99,10 +132,6 @@ public class SubModuleViewTest extends RienaTestCase {
}
@Override
- protected void activate(ISubModuleNode source) {
- }
-
- @Override
protected void basicCreatePartControl(Composite parent) {
}
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidget.java
index 7c24b36..77b0ec9 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MenuRidget.java
@@ -37,7 +37,7 @@ public class MenuRidget extends MenuItemRidget implements IMenuRidget {
@Override
protected void checkUIControl(Object uiControl) {
assertType(uiControl, MenuItem.class);
- if (!isMenu((MenuItem) uiControl)) {
+ if (uiControl != null && !isMenu((MenuItem) uiControl)) {
throw new BindingException("Menu item is not a cascade menu item!"); //$NON-NLS-1$
}
}
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 78e53bc..e77a7dd 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
@@ -170,7 +170,9 @@ public class UIProcessRidget extends AbstractRidget implements IUIProcessRidget
}
protected void bindUIControl() {
- uiProcessControl.addCancelListener(cancelListener);
+ if (getUIControl() != null) {
+ uiProcessControl.addCancelListener(cancelListener);
+ }
}
public void setUIControl(Object uiControl) {