summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-01-21 07:17:17 (EST)
committerCarsten Drossel2009-01-21 07:17:17 (EST)
commit6ff31f5695d6cdc42cf15b2ed17f91f336a467ea (patch)
tree6659dec9fb5d7c78cbddd30ba2ae0468e80cd791
parent7333b8ec2a20803ca5667455236bceb4103190e9 (diff)
downloadorg.eclipse.riena-6ff31f5695d6cdc42cf15b2ed17f91f336a467ea.zip
org.eclipse.riena-6ff31f5695d6cdc42cf15b2ed17f91f336a467ea.tar.gz
org.eclipse.riena-6ff31f5695d6cdc42cf15b2ed17f91f336a467ea.tar.bz2
robustness: checking for inconsistent usage of 'shared' with one view
-rw-r--r--org.eclipse.riena.example.client/plugin.xml5
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/SharedViewsNodeBuilder.java2
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtViewProvider.java13
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/viewprovider/SwtViewProviderTest.java17
4 files changed, 34 insertions, 3 deletions
diff --git a/org.eclipse.riena.example.client/plugin.xml b/org.eclipse.riena.example.client/plugin.xml
index 21b056c..be8f81a 100644
--- a/org.eclipse.riena.example.client/plugin.xml
+++ b/org.eclipse.riena.example.client/plugin.xml
@@ -36,6 +36,11 @@
name="org.eclipse.riena.example.client.views.SharedViewDemoSubModuleView">
</view>
<view allowMultiple="true"
+ class="org.eclipse.riena.example.client.views.SharedViewDemoSubModuleView"
+ id="org.eclipse.riena.example.client.views.SharedViewDemoSubModuleViewNotShared"
+ name="org.eclipse.riena.example.client.views.SharedViewDemoSubModuleViewNotShared">
+ </view>
+ <view allowMultiple="true"
class="org.eclipse.riena.example.client.views.RidgetsSubModuleView"
id="org.eclipse.riena.example.client.views.RidgetsSubModuleView"
name="org.eclipse.riena.example.client.views.RidgetsSubModuleView">
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/SharedViewsNodeBuilder.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/SharedViewsNodeBuilder.java
index 0ebf99e..b027a40 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/SharedViewsNodeBuilder.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/SharedViewsNodeBuilder.java
@@ -54,7 +54,7 @@ public class SharedViewsNodeBuilder extends NavigationNodeBuilder {
ISubModuleNode sharedViewSm2 = new SubModuleNode(new NavigationNodeId(
"org.eclipse.riena.example.sharedViewNotShared", "2"), "Node 2 (not shared)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
WorkareaManager.getInstance().registerDefinition(sharedViewSm2, SharedViewDemoSubModuleController.class,
- SharedViewDemoSubModuleView.ID, false);
+ SharedViewDemoSubModuleView.ID + "NotShared", false);
sharedViewModule.addChild(sharedViewSm2);
ISubModuleNode sharedViewSm3 = new SubModuleNode(new NavigationNodeId(
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtViewProvider.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtViewProvider.java
index ed5987f..97365cd 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtViewProvider.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtViewProvider.java
@@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.eclipse.riena.navigation.ApplicationModelFailure;
import org.eclipse.riena.navigation.INavigationNode;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.ui.workarea.IWorkareaDefinition;
@@ -90,7 +91,17 @@ public class SwtViewProvider {
if (viewId == null) {
throw new RuntimeException("viewId is null for nodeId " + submodule.getNodeId()); //$NON-NLS-1$
}
- viewShared.put(viewId, def.isViewShared());
+
+ if (viewShared.get(viewId) != null) {
+ if (def.isViewShared() != viewShared.get(viewId)) {
+ throw new ApplicationModelFailure(
+ "Inconsistent view usage. The view with the id \"" //$NON-NLS-1$
+ + viewId
+ + "\" is already used with a different 'shared' state. A view must be defined in all workarea definitions as either shared or not shared."); //$NON-NLS-1$
+ }
+ } else {
+ viewShared.put(viewId, def.isViewShared());
+ }
if (def.isViewShared()) {
if (views.get(submodule) == null) {
viewCounter.put(viewId, 0);
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/viewprovider/SwtViewProviderTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/viewprovider/SwtViewProviderTest.java
index e43110d..5ce1e16 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/viewprovider/SwtViewProviderTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/viewprovider/SwtViewProviderTest.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.riena.navigation.ui.swt.viewprovider;
+import org.eclipse.riena.navigation.ApplicationModelFailure;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.NavigationNodeId;
import org.eclipse.riena.navigation.model.SubModuleNode;
@@ -31,11 +32,11 @@ public class SwtViewProviderTest extends RienaTestCase {
super.setUp();
swtPresentationManager = new SwtViewProvider();
+ addPluginXml(SwtViewProviderTest.class, "SwtViewProviderTest.xml");
}
public void testGetSwtViewIdSharedView() throws Exception {
- addPluginXml(SwtViewProviderTest.class, "SwtViewProviderTest.xml");
ISubModuleNode node1 = new SubModuleNode(new NavigationNodeId("testSharedViewId", "testInstanceId1"));
ISubModuleNode node2 = new SubModuleNode(new NavigationNodeId("testSharedViewId", "testInstanceId2"));
@@ -66,4 +67,18 @@ public class SwtViewProviderTest extends RienaTestCase {
assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId1Again.getId());
assertEquals("1", swtViewId1Again.getSecondary());
}
+
+ public void testUnconsistentDefinitionWithAViewBothSharedAndNotShared() throws Exception {
+
+ ISubModuleNode node1 = new SubModuleNode(new NavigationNodeId("testSharedViewId", "testInstanceId1"));
+ ISubModuleNode node2 = new SubModuleNode(new NavigationNodeId("testNotSharedViewId", "testInstanceId2"));
+
+ swtPresentationManager.getSwtViewId(node1);
+ try {
+ swtPresentationManager.getSwtViewId(node2);
+ fail("ApplicationModelFailure expected");
+ } catch (ApplicationModelFailure expected) {
+ ok("ApplicationModelFailure expected");
+ }
+ }
}