Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 157181 Details for
Bug 295003
[UI] Design and implement a EPartService API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
EPartService v06
bug295003-patch-v6.txt (text/plain), 44.02 KB, created by
Remy Suen
on 2010-01-25 16:31:43 EST
(
hide
)
Description:
EPartService v06
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2010-01-25 16:31:43 EST
Size:
44.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.tests >Index: src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java,v >retrieving revision 1.12 >diff -u -r1.12 EPartServiceTest.java >--- src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 22 Jan 2010 17:36:24 -0000 1.12 >+++ src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 25 Jan 2010 21:27:54 -0000 >@@ -43,15 +43,6 @@ > protected void setUp() throws Exception { > applicationContext = E4Application.createDefaultContext(); > >- IContributionFactory contributionFactory = (IContributionFactory) applicationContext >- .get(IContributionFactory.class.getName()); >- Object newEngine = contributionFactory.create(getEngineURI(), >- applicationContext); >- assertTrue(newEngine instanceof IPresentationEngine); >- applicationContext.set(IPresentationEngine.class.getName(), newEngine); >- >- engine = (IPresentationEngine) newEngine; >- > super.setUp(); > } > >@@ -67,11 +58,27 @@ > } > } > >+ private IPresentationEngine getEngine() { >+ if (engine == null) { >+ IContributionFactory contributionFactory = (IContributionFactory) applicationContext >+ .get(IContributionFactory.class.getName()); >+ Object newEngine = contributionFactory.create(getEngineURI(), >+ applicationContext); >+ assertTrue(newEngine instanceof IPresentationEngine); >+ applicationContext.set(IPresentationEngine.class.getName(), >+ newEngine); >+ >+ engine = (IPresentationEngine) newEngine; >+ } >+ >+ return engine; >+ } >+ > public void testFindPart_PartInWindow() { > MApplication application = createApplication("partId"); > > MWindow window = application.getChildren().get(0); >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -89,7 +96,7 @@ > MApplication application = createApplication("partId"); > > MWindow window = application.getChildren().get(0); >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -105,8 +112,8 @@ > MWindow window1 = application.getChildren().get(0); > MWindow window2 = application.getChildren().get(1); > >- engine.createGui(window1); >- engine.createGui(window2); >+ getEngine().createGui(window1); >+ getEngine().createGui(window2); > > EPartService partService = (EPartService) window1.getContext().get( > EPartService.class.getName()); >@@ -137,7 +144,7 @@ > MPart partFront = partStack.getChildren().get(0); > partStack.setActiveChild(partFront); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -154,7 +161,7 @@ > MPart partFront = partStack.getChildren().get(0); > partStack.setActiveChild(partFront); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) partFront.getContext().get( > EPartService.class.getName()); >@@ -172,7 +179,7 @@ > MPart partBack = partStack.getChildren().get(1); > partStack.setActiveChild(partFront); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -190,7 +197,7 @@ > MPart partBack = partStack.getChildren().get(1); > partStack.setActiveChild(partFront); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) partFront.getContext().get( > EPartService.class.getName()); >@@ -216,8 +223,8 @@ > MPart partBackB = partStackB.getChildren().get(1); > partStackB.setActiveChild(partFrontB); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) windowA.getContext().get( > EPartService.class.getName()); >@@ -258,12 +265,12 @@ > MPart partBackB = partStackB.getChildren().get(1); > partStackB.setActiveChild(partFrontB); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) partFrontA.getContext().get( > EPartService.class.getName()); >- EPartService partServiceB = (EPartService) partBackB.getContext().get( >+ EPartService partServiceB = (EPartService) partFrontB.getContext().get( > EPartService.class.getName()); > > partServiceA.bringToTop(partBackB); >@@ -287,7 +294,7 @@ > MApplication application = createApplication(1, new String[1][0]); > MWindow window = application.getChildren().get(0); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -301,7 +308,7 @@ > MWindow window = application.getChildren().get(0); > MPartStack partStack = (MPartStack) window.getChildren().get(0); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -318,8 +325,8 @@ > MWindow windowA = application.getChildren().get(0); > MWindow windowB = application.getChildren().get(1); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) windowA.getContext().get( > EPartService.class.getName()); >@@ -353,7 +360,7 @@ > MPart part = partStack.getChildren().get(0); > partStack.setActiveChild(part); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -368,7 +375,7 @@ > MPart part = partStack.getChildren().get(0); > partStack.setActiveChild(part); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) part.getContext().get( > EPartService.class.getName()); >@@ -382,7 +389,7 @@ > MPartStack partStack = (MPartStack) window.getChildren().get(0); > partStack.setActiveChild(partStack.getChildren().get(0)); > >- engine.createGui(window); >+ getEngine().createGui(window); > > MPart part = partStack.getChildren().get(1); > >@@ -398,13 +405,24 @@ > MPartStack partStack = (MPartStack) window.getChildren().get(0); > partStack.setActiveChild(partStack.getChildren().get(0)); > >- engine.createGui(window); >+ getEngine().createGui(window); > >- MPart part = partStack.getChildren().get(1); >+ MPart part1 = partStack.getChildren().get(0); >+ MPart part2 = partStack.getChildren().get(1); > >- EPartService partService = (EPartService) part.getContext().get( >+ EPartService partService1 = (EPartService) part1.getContext().get( > EPartService.class.getName()); >- assertFalse(partService.isPartVisible(part)); >+ assertTrue(partService1.isPartVisible(part1)); >+ assertFalse(partService1.isPartVisible(part2)); >+ >+ partService1.activate(part2); >+ >+ EPartService partService2 = (EPartService) part2.getContext().get( >+ EPartService.class.getName()); >+ assertFalse(partService1.isPartVisible(part1)); >+ assertTrue(partService1.isPartVisible(part2)); >+ assertFalse(partService2.isPartVisible(part1)); >+ assertTrue(partService2.isPartVisible(part2)); > } > > public void testIsVisible_ViewInAnotherWindow() { >@@ -424,8 +442,8 @@ > MPart partBackB = partStackB.getChildren().get(1); > partStackB.setActiveChild(partFrontB); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) windowA.getContext().get( > EPartService.class.getName()); >@@ -460,8 +478,8 @@ > MPart partBackB = partStackB.getChildren().get(1); > partStackB.setActiveChild(partFrontB); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) partFrontA.getContext().get( > EPartService.class.getName()); >@@ -486,17 +504,24 @@ > MPartStack partStack = (MPartStack) window.getChildren().get(0); > partStack.setActiveChild(partStack.getChildren().get(0)); > >- engine.createGui(window); >+ getEngine().createGui(window); > >- MPart part = partStack.getChildren().get(1); >+ MPart part1 = partStack.getChildren().get(0); >+ MPart part2 = partStack.getChildren().get(1); > >- EPartService partService = (EPartService) part.getContext().get( >+ EPartService partService1 = (EPartService) part1.getContext().get( > EPartService.class.getName()); >- assertFalse(partService.isPartVisible(part)); >+ assertTrue(partService1.isPartVisible(part1)); >+ assertFalse(partService1.isPartVisible(part2)); > >- partService.activate(part); >- assertTrue(partService.isPartVisible(part)); >- assertEquals(part, partService.getActivePart()); >+ partService1.activate(part2); >+ >+ EPartService partService2 = (EPartService) part2.getContext().get( >+ EPartService.class.getName()); >+ assertFalse(partService1.isPartVisible(part1)); >+ assertTrue(partService1.isPartVisible(part2)); >+ assertFalse(partService2.isPartVisible(part1)); >+ assertTrue(partService2.isPartVisible(part2)); > } > > public void testActivate_partService_twoWindows() { >@@ -509,15 +534,19 @@ > MPart partFrontA = partStackA.getChildren().get(0); > MPart partBackA = partStackA.getChildren().get(1); > partStackA.setActiveChild(partFrontA); >+ windowA.setActiveChild(partStackA); > > MWindow windowB = application.getChildren().get(1); > MPartStack partStackB = (MPartStack) windowB.getChildren().get(0); > MPart partFrontB = partStackB.getChildren().get(0); > MPart partBackB = partStackB.getChildren().get(1); > partStackB.setActiveChild(partFrontB); >+ windowB.setActiveChild(partStackB); >+ >+ application.setActiveChild(windowA); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) partFrontA.getContext().get( > EPartService.class.getName()); >@@ -570,8 +599,8 @@ > MPart partBackB = partStackB.getChildren().get(1); > partStackB.setActiveChild(partFrontB); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) partFrontA.getContext().get( > EPartService.class.getName()); >@@ -618,8 +647,8 @@ > MPart partFrontB = partStackB.getChildren().get(0); > MPart partBackB = partStackB.getChildren().get(1); > >- engine.createGui(windowA); >- engine.createGui(windowB); >+ getEngine().createGui(windowA); >+ getEngine().createGui(windowB); > > EPartService partServiceA = (EPartService) partFrontA.getContext().get( > EPartService.class.getName()); >@@ -650,7 +679,7 @@ > partDescriptor.setId("partId"); > application.getDescriptors().add(partDescriptor); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -669,7 +698,7 @@ > partDescriptor.setId("partId"); > application.getDescriptors().add(partDescriptor); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -706,7 +735,7 @@ > ((Notifier) application).eAdapters().add( > new UIEventPublisher(applicationContext)); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -756,7 +785,7 @@ > ((Notifier) application).eAdapters().add( > new UIEventPublisher(applicationContext)); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -772,11 +801,344 @@ > assertEquals(part2, stack.getActiveChild()); > } > >+ public void testShowPart_CREATE() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); >+ MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); >+ window.getChildren().add(partStackA); >+ window.getChildren().add(partStackB); >+ >+ MPart partA1 = MApplicationFactory.eINSTANCE.createPart(); >+ MPart partA2 = MApplicationFactory.eINSTANCE.createPart(); >+ partA1.setId("partA1"); >+ partA2.setId("partA2"); >+ partStackA.getChildren().add(partA1); >+ partStackA.getChildren().add(partA2); >+ >+ MPart partB1 = MApplicationFactory.eINSTANCE.createPart(); >+ MPart partB2 = MApplicationFactory.eINSTANCE.createPart(); >+ partB1.setId("partB1"); >+ partB2.setId("partB2"); >+ partStackB.getChildren().add(partB1); >+ partStackB.getChildren().add(partB2); >+ >+ partStackA.setActiveChild(partA1); >+ partStackB.setActiveChild(partB1); >+ window.setActiveChild(partStackA); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ getEngine().createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ partService.activate(partA1); >+ assertEquals(partA1, partService.getActivePart()); >+ >+ assertEquals(null, partA2.getContext()); >+ assertEquals(null, partB2.getContext()); >+ >+ MPart shownPart = partService.showPart("partA2", >+ EPartService.PartState.CREATE); >+ assertTrue(partService.isPartVisible(partA1)); >+ assertTrue(partService.isPartVisible(partB1)); >+ assertEquals(partA1, partService.getActivePart()); >+ assertEquals(shownPart, partA2); >+ assertNotNull( >+ "The part should have been created so it should have a context", >+ partA2.getContext()); >+ assertEquals( >+ "This part has not been instantiated yet, it should have no context", >+ null, partB2.getContext()); >+ >+ shownPart = partService.showPart("partB2", >+ EPartService.PartState.CREATE); >+ assertTrue(partService.isPartVisible(partA1)); >+ assertTrue(partService.isPartVisible(partB1)); >+ assertEquals(partA1, partService.getActivePart()); >+ assertEquals(shownPart, partB2); >+ assertNotNull( >+ "The part should have been created so it should have a context", >+ partA2.getContext()); >+ assertNotNull( >+ "The part should have been created so it should have a context", >+ partB2.getContext()); >+ } >+ >+ public void testShowPart_CREATE2() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE >+ .createPartDescriptor(); >+ partDescriptor.setId("partB"); >+ partDescriptor.setCategory("aCategory"); >+ application.getDescriptors().add(partDescriptor); >+ >+ MPartStack partStack = MApplicationFactory.eINSTANCE.createPartStack(); >+ partStack.setId("aCategory"); >+ window.getChildren().add(partStack); >+ >+ MPart partA = MApplicationFactory.eINSTANCE.createPart(); >+ partA.setId("partA"); >+ partStack.getChildren().add(partA); >+ >+ partStack.setActiveChild(partA); >+ window.setActiveChild(partStack); >+ application.setActiveChild(window); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ getEngine().createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ partService.activate(partA); >+ assertEquals(partA, partService.getActivePart()); >+ >+ MPart partB = partService.showPart("partB", >+ EPartService.PartState.CREATE); >+ >+ assertEquals(2, partStack.getChildren().size()); >+ assertEquals( >+ "Only creating the part, the active part should not have changed", >+ partA, partService.getActivePart()); >+ assertNotNull("The shown part should have a context", partB >+ .getContext()); >+ assertFalse(partService.isPartVisible(partB)); >+ } >+ >+ public void testShowPart_CREATE3() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE >+ .createPartDescriptor(); >+ partDescriptor.setId("partB"); >+ partDescriptor.setCategory("aCategory"); >+ application.getDescriptors().add(partDescriptor); >+ >+ MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); >+ window.getChildren().add(partStackA); >+ MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); >+ partStackB.setId("aCategory"); >+ window.getChildren().add(partStackB); >+ >+ MPart partA = MApplicationFactory.eINSTANCE.createPart(); >+ partA.setId("partA"); >+ partStackA.getChildren().add(partA); >+ >+ partStackA.setActiveChild(partA); >+ window.setActiveChild(partStackA); >+ application.setActiveChild(window); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ getEngine().createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ partService.activate(partA); >+ assertEquals(partA, partService.getActivePart()); >+ >+ MPart partB = partService.showPart("partB", >+ EPartService.PartState.CREATE); >+ >+ assertEquals(1, partStackA.getChildren().size()); >+ assertEquals( >+ "Only creating the part, the active part should not have changed", >+ partA, partService.getActivePart()); >+ assertNotNull("The shown part should have a context", partB >+ .getContext()); >+ assertTrue( >+ "The part is the only one in the stack, it should be visible", >+ partService.isPartVisible(partB)); >+ } >+ >+ public void testShowPart_VISIBLE() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); >+ MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); >+ window.getChildren().add(partStackA); >+ window.getChildren().add(partStackB); >+ >+ MPart partA1 = MApplicationFactory.eINSTANCE.createPart(); >+ MPart partA2 = MApplicationFactory.eINSTANCE.createPart(); >+ partA1.setId("partA1"); >+ partA2.setId("partA2"); >+ partStackA.getChildren().add(partA1); >+ partStackA.getChildren().add(partA2); >+ >+ MPart partB1 = MApplicationFactory.eINSTANCE.createPart(); >+ MPart partB2 = MApplicationFactory.eINSTANCE.createPart(); >+ partB1.setId("partB1"); >+ partB2.setId("partB2"); >+ partStackB.getChildren().add(partB1); >+ partStackB.getChildren().add(partB2); >+ >+ partStackA.setActiveChild(partA1); >+ partStackB.setActiveChild(partB1); >+ window.setActiveChild(partStackA); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ getEngine().createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ partService.activate(partA1); >+ assertEquals(partA1, partService.getActivePart()); >+ >+ MPart shownPart = partService.showPart("partB1", >+ EPartService.PartState.VISIBLE); >+ assertTrue(partService.isPartVisible(partA1)); >+ assertTrue(partService.isPartVisible(partB1)); >+ assertEquals(partA1, partService.getActivePart()); >+ assertEquals(partB1, shownPart); >+ >+ shownPart = partService.showPart("partB2", >+ EPartService.PartState.VISIBLE); >+ assertTrue(partService.isPartVisible(partA1)); >+ assertTrue(partService.isPartVisible(partB2)); >+ assertEquals(partA1, partService.getActivePart()); >+ assertEquals(partB2, shownPart); >+ } >+ >+ public void testShowPart_VISIBLE2() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE >+ .createPartDescriptor(); >+ partDescriptor.setId("partB"); >+ partDescriptor.setCategory("aCategory"); >+ application.getDescriptors().add(partDescriptor); >+ >+ MPartStack partStack = MApplicationFactory.eINSTANCE.createPartStack(); >+ partStack.setId("aCategory"); >+ window.getChildren().add(partStack); >+ >+ MPart partA = MApplicationFactory.eINSTANCE.createPart(); >+ partA.setId("partA"); >+ partStack.getChildren().add(partA); >+ >+ partStack.setActiveChild(partA); >+ window.setActiveChild(partStack); >+ application.setActiveChild(window); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ getEngine().createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ partService.activate(partA); >+ assertEquals(partA, partService.getActivePart()); >+ >+ MPart partB = partService.showPart("partB", >+ EPartService.PartState.VISIBLE); >+ >+ assertEquals(2, partStack.getChildren().size()); >+ assertEquals( >+ "The part is in the same stack as the active part, so the active part should change", >+ partB, partService.getActivePart()); >+ assertNotNull("The shown part should have a context", partB >+ .getContext()); >+ assertTrue(partService.isPartVisible(partB)); >+ } >+ >+ public void testShowPart_VISIBLE3() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE >+ .createPartDescriptor(); >+ partDescriptor.setId("partB"); >+ partDescriptor.setCategory("aCategory"); >+ application.getDescriptors().add(partDescriptor); >+ >+ MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); >+ window.getChildren().add(partStackA); >+ MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); >+ partStackB.setId("aCategory"); >+ window.getChildren().add(partStackB); >+ >+ MPart partA = MApplicationFactory.eINSTANCE.createPart(); >+ partA.setId("partA"); >+ partStackA.getChildren().add(partA); >+ >+ partStackA.setActiveChild(partA); >+ window.setActiveChild(partStackA); >+ application.setActiveChild(window); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ getEngine().createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ partService.activate(partA); >+ assertEquals(partA, partService.getActivePart()); >+ >+ MPart partB = partService.showPart("partB", >+ EPartService.PartState.VISIBLE); >+ >+ assertEquals(1, partStackA.getChildren().size()); >+ assertEquals( >+ "Only creating the part, the active part should not have changed", >+ partA, partService.getActivePart()); >+ assertNotNull("The shown part should have a context", partB >+ .getContext()); >+ assertTrue( >+ "The part is the only one in the stack, it should be visible", >+ partService.isPartVisible(partB)); >+ } >+ > public void testGetSaveableParts() { > MApplication application = createApplication(1, new String[1][0]); > MWindow window = application.getChildren().get(0); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -790,7 +1152,7 @@ > MApplication application = createApplication("partId"); > MWindow window = application.getChildren().get(0); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -817,7 +1179,7 @@ > ((Notifier) application).eAdapters().add( > new UIEventPublisher(applicationContext)); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -831,7 +1193,7 @@ > MApplication application = createApplication(1, new String[1][0]); > MWindow window = application.getChildren().get(0); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -844,7 +1206,7 @@ > MApplication application = createApplication("partId"); > MWindow window = application.getChildren().get(0); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -871,7 +1233,7 @@ > ((Notifier) application).eAdapters().add( > new UIEventPublisher(applicationContext)); > >- engine.createGui(window); >+ getEngine().createGui(window); > > EPartService partService = (EPartService) window.getContext().get( > EPartService.class.getName()); >@@ -920,10 +1282,12 @@ > MWindow window2 = MApplicationFactory.eINSTANCE.createWindow(); > application.getChildren().add(window1); > application.getChildren().add(window2); >+ application.setActiveChild(window1); > > // place a part in the first window > MPart part = MApplicationFactory.eINSTANCE.createPart(); > window1.getChildren().add(part); >+ window1.setActiveChild(part); > > // setup the context > applicationContext.set(MApplication.class.getName(), application); >@@ -933,8 +1297,8 @@ > new UIEventPublisher(applicationContext)); > > // render the windows >- engine.createGui(window1); >- engine.createGui(window2); >+ getEngine().createGui(window1); >+ getEngine().createGui(window2); > > EPartService windowService1 = (EPartService) window1.getContext().get( > EPartService.class.getName()); >@@ -964,7 +1328,7 @@ > // activate the part > windowService2.activate(part); > >- assertNull("No parts in this window, this should be null", >+ assertEquals("No parts in this window, this should be null", null, > windowService1.getActivePart()); > assertEquals("We activated it just now, this should be active", part, > windowService2.getActivePart()); >Index: src/org/eclipse/e4/ui/tests/application/HeadlessApplicationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/HeadlessApplicationTest.java,v >retrieving revision 1.8 >diff -u -r1.8 HeadlessApplicationTest.java >--- src/org/eclipse/e4/ui/tests/application/HeadlessApplicationTest.java 10 Dec 2009 18:23:20 -0000 1.8 >+++ src/org/eclipse/e4/ui/tests/application/HeadlessApplicationTest.java 25 Jan 2010 21:27:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 IBM Corporation 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 >@@ -33,9 +33,7 @@ > import org.eclipse.e4.ui.model.application.MUIElement; > import org.eclipse.e4.ui.model.application.MWindow; > import org.eclipse.e4.ui.services.IServiceConstants; >-import org.eclipse.e4.ui.services.events.IEventBroker; > import org.eclipse.e4.workbench.ui.IPresentationEngine; >-import org.eclipse.e4.workbench.ui.UIEvents; > import org.eclipse.e4.workbench.ui.internal.Workbench; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.common.util.TreeIterator; >@@ -44,8 +42,6 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.osgi.service.event.Event; >-import org.osgi.service.event.EventHandler; > > public abstract class HeadlessApplicationTest extends > HeadlessApplicationElementTest { >@@ -54,36 +50,16 @@ > > protected IPresentationEngine renderer; > >- private EventHandler eventHandler = new EventHandler() { >- public void handleEvent(Event event) { >- if (event.getProperty(UIEvents.EventTags.ATTNAME).equals( >- UIEvents.ElementContainer.ACTIVECHILD)) { >- Object oldPart = event >- .getProperty(UIEvents.EventTags.OLD_VALUE); >- Object newPart = event >- .getProperty(UIEvents.EventTags.NEW_VALUE); >- if (oldPart instanceof MContext) { >- IEclipseContext context = (IEclipseContext) ((MContext) oldPart) >- .getContext().get(IContextConstants.PARENT); >- context.set(IContextConstants.ACTIVE_CHILD, >- newPart == null ? null : ((MContext) newPart) >- .getContext()); >- } else if (newPart instanceof MContext) { >- IEclipseContext context = (IEclipseContext) ((MContext) newPart) >- .getContext().get(IContextConstants.PARENT); >- context.set(IContextConstants.ACTIVE_CHILD, >- ((MContext) newPart).getContext()); >- } >- } >- } >- }; >- > @Override > protected void setUp() throws Exception { > super.setUp(); > > application = (MApplication) applicationElement; > >+ for (MWindow wbw : application.getChildren()) { >+ createGUI(wbw); >+ } >+ > if (needsActiveChildEventHandling()) { > addActiveChildEventHandling(); > } >@@ -91,10 +67,6 @@ > > @Override > protected void tearDown() throws Exception { >- IEventBroker eventBroker = (IEventBroker) application.getContext().get( >- IEventBroker.class.getName()); >- eventBroker.unsubscribe(eventHandler); >- > for (MWindow window : application.getChildren()) { > renderer.removeGui(window); > } >@@ -107,11 +79,6 @@ > } > > private void addActiveChildEventHandling() { >- IEventBroker eventBroker = (IEventBroker) application.getContext().get( >- IEventBroker.class.getName()); >- eventBroker.subscribe(UIEvents >- .buildTopic(UIEvents.ElementContainer.TOPIC), null, >- eventHandler, true); > } > > public void testGet_ActiveContexts() throws Exception { >@@ -349,10 +316,6 @@ > > renderer = createPresentationEngine(getEngineURI()); > >- for (MWindow wbw : windows) { >- createGUI(wbw); >- } >- > return application; > } > >Index: src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java,v >retrieving revision 1.8 >diff -u -r1.8 HeadlessContextPresentationEngine.java >--- src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java 9 Jan 2010 21:24:20 -0000 1.8 >+++ src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java 25 Jan 2010 21:27:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 IBM Corporation 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 >@@ -11,6 +11,8 @@ > > package org.eclipse.e4.ui.tests.application; > >+import java.util.List; >+ > import javax.inject.Inject; > > import org.eclipse.e4.core.services.IDisposable; >@@ -21,6 +23,8 @@ > import org.eclipse.e4.ui.model.application.MApplicationElement; > import org.eclipse.e4.ui.model.application.MContext; > import org.eclipse.e4.ui.model.application.MElementContainer; >+import org.eclipse.e4.ui.model.application.MPart; >+import org.eclipse.e4.ui.model.application.MPartStack; > import org.eclipse.e4.ui.model.application.MUIElement; > import org.eclipse.e4.ui.services.events.IEventBroker; > import org.eclipse.e4.workbench.ui.IPresentationEngine; >@@ -35,6 +39,9 @@ > @Inject > private IEventBroker eventBroker; > >+ private EventHandler childHandler; >+ private EventHandler activeChildHandler; >+ > private static IEclipseContext getParentContext(MUIElement element) { > MElementContainer<MUIElement> parent = element.getParent(); > IEclipseContext context = null; >@@ -62,9 +69,34 @@ > > @PostConstruct > void postConstruct() { >+ childHandler = new EventHandler() { >+ public void handleEvent(Event event) { >+ if (UIEvents.EventTypes.ADD.equals(event >+ .getProperty(UIEvents.EventTags.TYPE))) { >+ Object element = event >+ .getProperty(UIEvents.EventTags.NEW_VALUE); >+ if (element instanceof MUIElement) { >+ Object parent = event >+ .getProperty(UIEvents.EventTags.ELEMENT); >+ createGui((MUIElement) element, parent); >+ >+ if (parent instanceof MPartStack) { >+ MPartStack stack = (MPartStack) parent; >+ List<MPart> children = stack.getChildren(); >+ if (children.size() == 1) { >+ stack.setActiveChild((MPart) element); >+ } >+ } >+ } >+ } >+ } >+ }; >+ > eventBroker.subscribe(UIEvents.buildTopic( > UIEvents.ElementContainer.TOPIC, >- UIEvents.ElementContainer.CHILDREN), new EventHandler() { >+ UIEvents.ElementContainer.CHILDREN), childHandler); >+ >+ activeChildHandler = new EventHandler() { > public void handleEvent(Event event) { > Object element = event > .getProperty(UIEvents.EventTags.NEW_VALUE); >@@ -74,7 +106,11 @@ > createGui((MUIElement) element, parent); > } > } >- }); >+ }; >+ >+ eventBroker.subscribe(UIEvents.buildTopic( >+ UIEvents.ElementContainer.TOPIC, >+ UIEvents.ElementContainer.ACTIVECHILD), activeChildHandler); > } > > /* >@@ -103,22 +139,31 @@ > > mcontext.setContext(createdContext); > } >- if (element instanceof MElementContainer<?>) { >- boolean active = false; >+ >+ if (element instanceof MPartStack) { >+ MPartStack container = (MPartStack) element; >+ MPart active = container.getActiveChild(); >+ if (active != null) { >+ createGui(active, container); >+ IEclipseContext childContext = ((MContext) active).getContext(); >+ IEclipseContext parentContext = getParentContext(active); >+ parentContext.set(IContextConstants.ACTIVE_CHILD, childContext); >+ } else { >+ List<MPart> children = container.getChildren(); >+ if (!children.isEmpty()) { >+ container.setActiveChild(children.get(0)); >+ } >+ } >+ } else if (element instanceof MElementContainer<?>) { > for (Object child : ((MElementContainer<?>) element).getChildren()) { > if (child instanceof MUIElement) { > createGui((MUIElement) child, element); >- if (!active) { >- active = true; >- ((MElementContainer) element) >- .setActiveChild((MUIElement) child); >- if (child instanceof MContext) { >- IEclipseContext childContext = ((MContext) child) >- .getContext(); >- IEclipseContext parentContext = getParentContext((MUIElement) child); >- parentContext.set(IContextConstants.ACTIVE_CHILD, >- childContext); >- } >+ if (child instanceof MContext) { >+ IEclipseContext childContext = ((MContext) child) >+ .getContext(); >+ IEclipseContext parentContext = getParentContext((MUIElement) child); >+ parentContext.set(IContextConstants.ACTIVE_CHILD, >+ childContext); > } > } > } >Index: src/org/eclipse/e4/ui/tests/application/HeadlessPhotoDemoTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/HeadlessPhotoDemoTest.java,v >retrieving revision 1.3 >diff -u -r1.3 HeadlessPhotoDemoTest.java >--- src/org/eclipse/e4/ui/tests/application/HeadlessPhotoDemoTest.java 7 Jan 2010 12:48:58 -0000 1.3 >+++ src/org/eclipse/e4/ui/tests/application/HeadlessPhotoDemoTest.java 25 Jan 2010 21:27:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 IBM Corporation 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 >@@ -22,12 +22,12 @@ > > @Override > protected MPart getFirstPart() { >- return (MPart) findElement("ExifView"); >+ return (MPart) findElement("ThumbnailsView"); > } > > @Override > protected MPart getSecondPart() { >- return (MPart) findElement("ThumbnailsView"); >+ return (MPart) findElement("ExifView"); > } > > } >Index: src/org/eclipse/e4/ui/tests/application/UIPhotoDemoTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/UIPhotoDemoTest.java,v >retrieving revision 1.3 >diff -u -r1.3 UIPhotoDemoTest.java >--- src/org/eclipse/e4/ui/tests/application/UIPhotoDemoTest.java 7 Jan 2010 12:48:58 -0000 1.3 >+++ src/org/eclipse/e4/ui/tests/application/UIPhotoDemoTest.java 25 Jan 2010 21:27:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 IBM Corporation 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 >@@ -22,12 +22,12 @@ > > @Override > protected MPart getFirstPart() { >- return (MPart) findElement("ExifView"); >+ return (MPart) findElement("ThumbnailsView"); > } > > @Override > protected MPart getSecondPart() { >- return (MPart) findElement("ThumbnailsView"); >+ return (MPart) findElement("ExifView"); > } > > } >#P org.eclipse.e4.ui.workbench >Index: src/org/eclipse/e4/workbench/modeling/EPartService.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/modeling/EPartService.java,v >retrieving revision 1.5 >diff -u -r1.5 EPartService.java >--- src/org/eclipse/e4/workbench/modeling/EPartService.java 22 Jan 2010 13:47:55 -0000 1.5 >+++ src/org/eclipse/e4/workbench/modeling/EPartService.java 25 Jan 2010 21:27:56 -0000 >@@ -14,7 +14,37 @@ > import org.eclipse.e4.ui.model.application.MPart; > import org.eclipse.e4.ui.model.application.MSaveablePart; > >+/** >+ * The part service provides clients with the functionalities of showing and hiding parts. Part >+ * events can also be tracked via the part service. >+ * >+ * @since 1.0 >+ */ > public interface EPartService { >+ >+ /** >+ * Applicable states that a part can be in. This will be used in conjunction with >+ * {@link EPartService#showPart(String, PartState)}. >+ */ >+ public enum PartState { >+ >+ /** >+ * Part state that indicates the part should be made visible and activated. >+ */ >+ ACTIVATE, >+ >+ /** >+ * Part state that indicates the part should be made visible though it may not necessarily >+ * be granted focus. >+ */ >+ VISIBLE, >+ >+ /** >+ * Part state that indicates the part should be created but not necessarily made visible. >+ */ >+ CREATE >+ } >+ > public static final String PART_SERVICE_ROOT = "partServiceRoot"; //$NON-NLS-1$ > > public void activate(MPart part); >@@ -25,14 +55,35 @@ > > public MPart findPart(String id); > >+ /** >+ * Returns a collection of all the parts that are being managed by this part service. >+ * >+ * @return a collection of parts that are being managed by this service, never <code>null</code> >+ */ > public Collection<MPart> getParts(); > >+ /** >+ * Returns the active part. >+ * >+ * @return an active part within the scope of this service, or <code>null</code> if no part is >+ * currently active >+ */ > public MPart getActivePart(); > > public boolean isPartVisible(MPart part); > >+ /** >+ * Shows the part that is identified by the given id and grant it focus. >+ * >+ * @param id >+ * the identifier of the part, must not be <code>null</code> >+ * @return the shown part, or <code>null</code> if no parts or part descriptors can be found >+ * that match the specified id >+ */ > public MPart showPart(String id); > >+ public MPart showPart(String id, PartState partState); >+ > public Collection<MSaveablePart> getSaveableParts(); > > public Collection<MSaveablePart> getDirtyParts(); >Index: src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java,v >retrieving revision 1.14 >diff -u -r1.14 PartServiceImpl.java >--- src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 25 Jan 2010 18:39:30 -0000 1.14 >+++ src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 25 Jan 2010 21:27:56 -0000 >@@ -33,6 +33,7 @@ > import org.eclipse.e4.ui.services.IServiceConstants; > import org.eclipse.e4.ui.services.events.IEventBroker; > import org.eclipse.e4.workbench.modeling.EPartService; >+import org.eclipse.e4.workbench.ui.IPresentationEngine; > import org.eclipse.e4.workbench.ui.UIEvents; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.util.EcoreUtil; >@@ -68,6 +69,9 @@ > private MElementContainer<MUIElement> rootContainer; > > @Inject >+ private IPresentationEngine engine; >+ >+ @Inject > void setPart(@Optional @Named(IServiceConstants.ACTIVE_PART) MPart p) { > activePart = p; > } >@@ -253,11 +257,25 @@ > } > > public MPart showPart(String id) { >+ return showPart(id, PartState.ACTIVATE); >+ } >+ >+ public MPart showPart(String id, PartState partState) { > Assert.isNotNull(id); > > MPart part = findPart(id); > if (part != null) { >- activate(part); >+ switch (partState) { >+ case ACTIVATE: >+ activate(part); >+ return part; >+ case VISIBLE: >+ bringToTop(part); >+ return part; >+ case CREATE: >+ engine.createGui(part); >+ return part; >+ } > return part; > } > >@@ -294,7 +312,14 @@ > } > > // 3) make it visible / active / re-layout >- activate(part); >+ switch (partState) { >+ case ACTIVATE: >+ activate(part); >+ return part; >+ case VISIBLE: >+ bringToTop(part); >+ return part; >+ } > return part; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 295003
:
153159
|
153273
|
153815
|
155410
|
155599
|
155880
|
156933
| 157181 |
157513
|
157542