summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2008-08-05 11:25:22 (EDT)
committerCarsten Drossel2008-08-05 11:25:22 (EDT)
commit9cea29e1145a31777ebff14b7cc75352617d594c (patch)
treed312a622c18738bcd6a449e03a680321ab2bc696
parent8b8b7bd4aa4ee23ed565da1c2744f8ccc4bef8df (diff)
downloadorg.eclipse.riena-9cea29e1145a31777ebff14b7cc75352617d594c.zip
org.eclipse.riena-9cea29e1145a31777ebff14b7cc75352617d594c.tar.gz
org.eclipse.riena-9cea29e1145a31777ebff14b7cc75352617d594c.tar.bz2
using 'shared' value when creating view id
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManager.java22
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.java40
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.xml11
3 files changed, 59 insertions, 14 deletions
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManager.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManager.java
index 9282aca..1d5cb35 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManager.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManager.java
@@ -56,12 +56,13 @@ public class SwtPresentationManager {
INavigationNodeId presentationId = pNode.getPresentationId();
if (presentationId != null) {
String viewId = getPresentationDefinitionService().getViewId(presentationId);
- // TODO use
- // getPresentationDefinitionService().isViewShared(
- // presentationId
- // )
- // instead of creating all views shared
- swtViewId = new SwtViewId(viewId, "shared");
+ String secondaryId = null;
+ if (getPresentationDefinitionService().isViewShared(presentationId)) {
+ secondaryId = "shared"; //$NON-NLS-1$
+ } else {
+ secondaryId = getNextSecondaryId(viewId);
+ }
+ swtViewId = new SwtViewId(viewId, secondaryId);
views.put(pNode, swtViewId);
}
}
@@ -118,8 +119,15 @@ public class SwtPresentationManager {
}
}
// classic way with one view per node
+ views.put(pNode, new SwtViewId(pViewId, getNextSecondaryId(pViewId)));
+ }
+
+ private String getNextSecondaryId(String pViewId) {
+ if (viewCounter.get(pViewId) == null) {
+ viewCounter.put(pViewId, 0);
+ }
viewCounter.put(pViewId, viewCounter.get(pViewId) + 1);
- views.put(pNode, new SwtViewId(pViewId, String.valueOf(viewCounter.get(pViewId))));
+ return String.valueOf(viewCounter.get(pViewId));
}
public void registerView(String viewId, boolean shared) {
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.java
index 5159824..b69877e 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.java
@@ -24,19 +24,47 @@ public class SwtPresentationManagerTest extends RienaTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
+
addPluginXml(SwtPresentationManagerTest.class, "SwtPresentationManagerTest.xml");
swtPresentationManager = new SwtPresentationManager();
+
}
- public void testGetSwtViewId() throws Exception {
+ public void testGetSwtViewIdSharedView() throws Exception {
+
+ SubModuleNode node1 = new SubModuleNode();
+ node1.setPresentationId(new NavigationNodeId("testSharedViewId", "testInstanceId1"));
+ SubModuleNode node2 = new SubModuleNode();
+ node2.setPresentationId(new NavigationNodeId("testSharedViewId", "testInstanceId2"));
+
+ SwtViewId swtViewId1 = swtPresentationManager.getSwtViewId(node1);
+ assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId1.getId());
+ assertEquals("shared", swtViewId1.getSecondary());
+
+ SwtViewId swtViewId2 = swtPresentationManager.getSwtViewId(node1);
+ assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId2.getId());
+ assertEquals("shared", swtViewId2.getSecondary());
+
+ }
+
+ public void testGetSwtViewIdNotSharedView() throws Exception {
+
+ SubModuleNode node1 = new SubModuleNode();
+ node1.setPresentationId(new NavigationNodeId("testNotSharedViewId", "testInstanceId1"));
+ SubModuleNode node2 = new SubModuleNode();
+ node2.setPresentationId(new NavigationNodeId("testNotSharedViewId", "testInstanceId2"));
- SubModuleNode node = new SubModuleNode();
- node.setPresentationId(new NavigationNodeId("testId"));
+ SwtViewId swtViewId1 = swtPresentationManager.getSwtViewId(node1);
+ assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId1.getId());
+ assertEquals("1", swtViewId1.getSecondary());
- SwtViewId swtViewId = swtPresentationManager.getSwtViewId(node);
+ SwtViewId swtViewId2 = swtPresentationManager.getSwtViewId(node2);
+ assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId2.getId());
+ assertEquals("2", swtViewId2.getSecondary());
- assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId.getId());
- assertEquals("shared", swtViewId.getSecondary());
+ SwtViewId swtViewId1Again = swtPresentationManager.getSwtViewId(node1);
+ assertEquals("org.eclipse.riena.navigation.ui.swt.views.TestView", swtViewId1Again.getId());
+ assertEquals("1", swtViewId1Again.getSecondary());
}
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.xml b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.xml
index 8b2440d..ce08b5a 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.xml
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/presentation/SwtPresentationManagerTest.xml
@@ -4,10 +4,19 @@
<extension
point="org.eclipse.riena.navigation.WorkAreaPresentation">
<workAreaPresentation
- presentationId="testId"
+ presentationId="testSharedViewId"
view="org.eclipse.riena.navigation.ui.swt.views.TestView"
viewController="org.eclipse.riena.navigation.ui.controllers.SubModuleController"
viewShared="true">
</workAreaPresentation>
</extension>
+ <extension
+ point="org.eclipse.riena.navigation.WorkAreaPresentation">
+ <workAreaPresentation
+ presentationId="testNotSharedViewId"
+ view="org.eclipse.riena.navigation.ui.swt.views.TestView"
+ viewController="org.eclipse.riena.navigation.ui.controllers.SubModuleController"
+ viewShared="false">
+ </workAreaPresentation>
+ </extension>
</plugin>