summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2008-09-01 10:08:07 (EDT)
committerCarsten Drossel2008-09-01 10:08:07 (EDT)
commite1634a9b1d774d83d30826c8ffc0bab09436a71b (patch)
tree29ce773f3eeb94678ba664cb1782e5fe5a504906
parent07534688d690e895fb91b90c97897957b9a671e5 (diff)
downloadorg.eclipse.riena-e1634a9b1d774d83d30826c8ffc0bab09436a71b.zip
org.eclipse.riena-e1634a9b1d774d83d30826c8ffc0bab09436a71b.tar.gz
org.eclipse.riena-e1634a9b1d774d83d30826c8ffc0bab09436a71b.tar.bz2
SCP bug #88: NullPointerException for views without controller
-rw-r--r--org.eclipse.riena.example.client/plugin.xml12
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeBuilder.java5
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/NoControllerSubModuleView.java39
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java19
4 files changed, 68 insertions, 7 deletions
diff --git a/org.eclipse.riena.example.client/plugin.xml b/org.eclipse.riena.example.client/plugin.xml
index e13894c..9ef1fdc 100644
--- a/org.eclipse.riena.example.client/plugin.xml
+++ b/org.eclipse.riena.example.client/plugin.xml
@@ -122,6 +122,13 @@
name="org.eclipse.riena.example.client.views.BlockingSubModuleView"
restorable="true">
</view>
+ <view
+ allowMultiple="true"
+ class="org.eclipse.riena.example.client.views.NoControllerSubModuleView"
+ id="org.eclipse.riena.example.client.views.NoControllerSubModuleView"
+ name="org.eclipse.riena.example.client.views.NoControllerSubModuleView"
+ restorable="true">
+ </view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
@@ -484,5 +491,10 @@
typeId="org.eclipse.riena.example.blocking"
view="org.eclipse.riena.example.client.views.BlockingSubModuleView">
</subModuleType>
+ <subModuleType
+ shared="false"
+ typeId="org.eclipse.riena.example.noController"
+ view="org.eclipse.riena.example.client.views.NoControllerSubModuleView">
+ </subModuleType>
</extension>
</plugin>
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeBuilder.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeBuilder.java
index 749dd6d..fc95b6a 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeBuilder.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeBuilder.java
@@ -14,7 +14,6 @@ import org.eclipse.riena.navigation.IModuleGroupNode;
import org.eclipse.riena.navigation.IModuleNode;
import org.eclipse.riena.navigation.INavigationNode;
import org.eclipse.riena.navigation.INavigationNodeBuilder;
-import org.eclipse.riena.navigation.NavigationNodeId;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.NavigationArgument;
import org.eclipse.riena.navigation.NavigationNodeId;
@@ -91,6 +90,10 @@ public class PlaygroundNodeBuilder implements INavigationNodeBuilder {
new NavigationNodeId("org.eclipse.riena.example.blocking"), "Blocking"); //$NON-NLS-1$ //$NON-NLS-2$
playgroundModule.addChild(blockingSubModule);
+ ISubModuleNode noControllerSubModule = new SubModuleNode(new NavigationNodeId(
+ "org.eclipse.riena.example.noController"), "View without Controller"); //$NON-NLS-1$ //$NON-NLS-2$
+ playgroundModule.addChild(noControllerSubModule);
+
return moduleGroup;
}
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/NoControllerSubModuleView.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/NoControllerSubModuleView.java
new file mode 100644
index 0000000..ff08e47
--- /dev/null
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/NoControllerSubModuleView.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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.example.client.views;
+
+import org.eclipse.riena.example.client.controllers.NavigateSubModuleController;
+import org.eclipse.riena.internal.example.client.utils.UIControlsFactory;
+import org.eclipse.riena.navigation.ui.swt.views.SubModuleView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Example for a view that has no controller. This could make sense for a
+ * submodule whose only purpose is to display some static text (like this one)
+ * or if the logic behind the UI widgets is really simple.
+ */
+public class NoControllerSubModuleView extends SubModuleView<NavigateSubModuleController> {
+
+ public static final String ID = NoControllerSubModuleView.class.getName();
+
+ @Override
+ protected void basicCreatePartControl(Composite parent) {
+ parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ parent.setLayout(new GridLayout(1, false));
+
+ UIControlsFactory.createLabel(parent, "This sentence no verb."); //$NON-NLS-1$
+ UIControlsFactory.createLabel(parent, "This view no controller."); //$NON-NLS-1$
+ }
+
+}
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 06f587a..7d30f45 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
@@ -135,8 +135,11 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
public void createPartControl(Composite parent) {
this.parentComposite = parent;
observeRoot();
- setController(createController(getNavigationNode()));
- setPartName(getController().getNavigationNode().getLabel());
+ C controller = createController(getNavigationNode());
+ setController(controller);
+ if (controller != null) {
+ setPartName(controller.getNavigationNode().getLabel());
+ }
Composite contentComposite = createContentComposite(parent);
basicCreatePartControl(contentComposite);
createViewFacade();
@@ -265,15 +268,19 @@ public abstract class SubModuleView<C extends SubModuleController> extends ViewP
if (!node2Controler.containsKey(getNavigationNode())) {
setController(createController(getNavigationNode()));
}
- binding.injectRidgets(getController());
- if (getController().getWindowRidget() == null) {
- getController().setWindowRidget((IWindowRidget) getController().getRidget(WINDOW_RIDGET));
+ if (getController() != null) {
+ binding.injectRidgets(getController());
+ if (getController().getWindowRidget() == null) {
+ getController().setWindowRidget((IWindowRidget) getController().getRidget(WINDOW_RIDGET));
+ }
}
}
protected C createController(ISubModuleNode pSubModuleNode) {
C controller = (C) getPresentationDefinitionService().provideController(pSubModuleNode);
- controller.setNavigationNode(pSubModuleNode);
+ if (controller != null) {
+ controller.setNavigationNode(pSubModuleNode);
+ }
return controller;
}