summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-01-27 04:00:03 (EST)
committerCarsten Drossel2009-01-27 04:00:03 (EST)
commit23237ecffeb32d77f845ff824a57ad5a44cb6502 (patch)
treefadba98041b6c1db6e6388a0da34e2803a4511a5
parentf45c092ea5144df71d3f5808414c0efff127c372 (diff)
downloadorg.eclipse.riena-23237ecffeb32d77f845ff824a57ad5a44cb6502.zip
org.eclipse.riena-23237ecffeb32d77f845ff824a57ad5a44cb6502.tar.gz
org.eclipse.riena-23237ecffeb32d77f845ff824a57ad5a44cb6502.tar.bz2
Bug 262026
-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.java29
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java85
-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, 277 insertions, 87 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 229abe0..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,11 +230,16 @@ public class SubApplicationView implements INavigationNodeView<SubApplicationCon
}
public void unbind() {
- if (getNavigationNode() != null && getNavigationNode().getNavigationNodeController() instanceof IController) {
- IController controller = (IController) getNavigationNode().getNavigationNodeController();
- binding.unbind(controller);
- if (menuItemBindingManager != null) {
- menuItemBindingManager.unbind(controller, getUIControls());
+ 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());
+ }
}
}
}
@@ -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 037be19..6bd331c 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,9 +10,6 @@
*******************************************************************************/
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;
@@ -29,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;
@@ -56,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.
@@ -84,7 +79,6 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
*/
public SubModuleView() {
binding = createBinding();
- node2Controller = new HashMap<ISubModuleNode, C>();
}
/**
@@ -132,18 +126,21 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
/**
* @return the controller
*/
- public C getController() {
- return node2Controller.get(getNavigationNode());
+ public SubModuleController getController() {
+
+ if (getNavigationNode() != null
+ && getNavigationNode().getNavigationNodeController() instanceof SubModuleController) {
+ return (SubModuleController) getNavigationNode().getNavigationNodeController();
+ }
+ return null;
}
/**
- * @param controller
- * the controller to set
+ * @deprecated the controller is stored in the navigation node
+ * @see INavigationNode#setNavigationNodeController(org.eclipse.riena.navigation.INavigationNodeController)
*/
public void setController(C controller) {
- if (node2Controller.get(getNavigationNode()) == null) {
- node2Controller.put(getNavigationNode(), controller);
- }
+ // obsolete, the controller is stored in the node
}
@Override
@@ -151,11 +148,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();
@@ -201,8 +197,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);
@@ -212,13 +208,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() {
@@ -235,43 +231,45 @@ 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);
}
}
+ /**
+ * Invoked whenever any submodule is activated.
+ *
+ * @deprecated To do something whenever a submodule is activated a
+ * NavigationTreeObserver with an ISubModuleNodeListener may be
+ * used.
+ */
protected void activate(ISubModuleNode source) {
- SwtViewId id = SwtViewProviderAccessor.getViewProvider().getSwtViewId(source);
- if (getViewSite().getId().equals(id.getId())) {
- doBinding();
- }
+ // deprecated
}
- 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);
+ if (source.equals(getNavigationNode())) {
+ doBinding();
+ }
activate(source);
}
@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) {
@@ -293,8 +291,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());
@@ -337,6 +335,7 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
}
public void bind(SubModuleNode node) {
+
if (currentController != getController()) {
if (currentController != null) {
if (currentController.getNavigationNode().isDisposed()) {
@@ -344,7 +343,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) {
@@ -369,18 +368,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) {