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 153273 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 v02
partService-v01.txt (text/plain), 26.77 KB, created by
Paul Webster
on 2009-11-27 15:15:40 EST
(
hide
)
Description:
EPartService v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2009-11-27 15:15:40 EST
Size:
26.77 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: src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java >diff -N src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,369 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.ui.tests.application; >+ >+import java.util.Collection; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.e4.core.services.IContributionFactory; >+import org.eclipse.e4.core.services.IDisposable; >+import org.eclipse.e4.core.services.context.IEclipseContext; >+import org.eclipse.e4.ui.model.application.MApplication; >+import org.eclipse.e4.ui.model.application.MApplicationFactory; >+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.MWindow; >+import org.eclipse.e4.ui.workbench.swt.internal.E4Application; >+import org.eclipse.e4.workbench.modeling.EPartService; >+import org.eclipse.e4.workbench.ui.IPresentationEngine; >+ >+public class EPartServiceTest extends TestCase { >+ >+ private IEclipseContext applicationContext; >+ >+ private IPresentationEngine engine; >+ >+ @Override >+ 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(); >+ } >+ >+ protected String getEngineURI() { >+ return "platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.application.HeadlessContextPresentationEngine"; //$NON-NLS-1$ >+ } >+ >+ @Override >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ if (applicationContext instanceof IDisposable) { >+ ((IDisposable) applicationContext).dispose(); >+ } >+ } >+ >+ public void testFindPart_PartInWindow() { >+ MApplication application = createApplication("partId"); >+ >+ MWindow window = application.getChildren().get(0); >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ MPart part = partService.findPart("partId"); >+ assertNotNull(part); >+ >+ MPartStack partStack = (MPartStack) window.getChildren().get(0); >+ assertEquals(partStack.getChildren().get(0), part); >+ >+ part = partService.findPart("invalidPartId"); >+ assertNull(part); >+ } >+ >+ public void testFindPart_PartNotInWindow() { >+ MApplication application = createApplication("partId"); >+ >+ MWindow window = application.getChildren().get(0); >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ MPart part = partService.findPart("invalidPartId"); >+ assertNull(part); >+ } >+ >+ public void testFindPart_PartInAnotherWindow() { >+ MApplication application = createApplication( >+ new String[] { "partInWindow1" }, >+ new String[] { "partInWindow2" }); >+ >+ MWindow window1 = application.getChildren().get(0); >+ MWindow window2 = application.getChildren().get(1); >+ >+ engine.createGui(window1); >+ engine.createGui(window2); >+ >+ EPartService partService = (EPartService) window1.getContext().get( >+ EPartService.class.getName()); >+ MPart part = partService.findPart("partInWindow2"); >+ assertNull(part); >+ part = partService.findPart("partInWindow1"); >+ assertNotNull(part); >+ >+ MPartStack partStack = (MPartStack) window1.getChildren().get(0); >+ assertEquals(partStack.getChildren().get(0), part); >+ >+ partService = (EPartService) window2.getContext().get( >+ EPartService.class.getName()); >+ part = partService.findPart("partInWindow1"); >+ assertNull(part); >+ part = partService.findPart("partInWindow2"); >+ assertNotNull(part); >+ >+ partStack = (MPartStack) window2.getChildren().get(0); >+ assertEquals(partStack.getChildren().get(0), part); >+ } >+ >+ public void testBringToTop_PartOnTop() { >+ MApplication application = createApplication("partFront", "partBack"); >+ >+ MWindow window = application.getChildren().get(0); >+ MPartStack partStack = (MPartStack) window.getChildren().get(0); >+ MPart partFront = partStack.getChildren().get(0); >+ partStack.setActiveChild(partFront); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ >+ partService.bringToTop(partFront); >+ assertEquals(partStack.getActiveChild(), partFront); >+ } >+ >+ public void testBringToTop_PartNotOnTop() { >+ MApplication application = createApplication("partFront", "partBack"); >+ >+ MWindow window = application.getChildren().get(0); >+ MPartStack partStack = (MPartStack) window.getChildren().get(0); >+ MPart partFront = partStack.getChildren().get(0); >+ MPart partBack = partStack.getChildren().get(1); >+ partStack.setActiveChild(partFront); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ >+ partService.bringToTop(partBack); >+ assertEquals(partStack.getActiveChild(), partBack); >+ } >+ >+ public void testBringToTop_PartInAnotherWindow() { >+ MApplication application = createApplication(new String[] { >+ "partFrontA", "partBackA" }, new String[] { "partFrontB", >+ "partBackB" }); >+ >+ MWindow windowA = application.getChildren().get(0); >+ MPartStack partStackA = (MPartStack) windowA.getChildren().get(0); >+ MPart partFrontA = partStackA.getChildren().get(0); >+ MPart partBackA = partStackA.getChildren().get(1); >+ partStackA.setActiveChild(partFrontA); >+ >+ 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); >+ >+ engine.createGui(windowA); >+ engine.createGui(windowB); >+ >+ EPartService partServiceA = (EPartService) windowA.getContext().get( >+ EPartService.class.getName()); >+ EPartService partServiceB = (EPartService) windowB.getContext().get( >+ EPartService.class.getName()); >+ >+ partServiceA.bringToTop(partBackB); >+ assertEquals(partStackA.getActiveChild(), partFrontA); >+ assertEquals(partStackB.getActiveChild(), partFrontB); >+ >+ partServiceB.bringToTop(partBackA); >+ assertEquals(partStackA.getActiveChild(), partFrontA); >+ assertEquals(partStackB.getActiveChild(), partFrontB); >+ >+ partServiceA.bringToTop(partBackA); >+ assertEquals(partStackA.getActiveChild(), partBackA); >+ assertEquals(partStackB.getActiveChild(), partFrontB); >+ >+ partServiceB.bringToTop(partBackB); >+ assertEquals(partStackA.getActiveChild(), partBackA); >+ assertEquals(partStackB.getActiveChild(), partBackB); >+ } >+ >+ public void testGetParts_Empty() { >+ MApplication application = createApplication(1, new String[1][0]); >+ MWindow window = application.getChildren().get(0); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ Collection<MPart> parts = partService.getParts(); >+ assertNotNull(parts); >+ assertEquals(0, parts.size()); >+ } >+ >+ public void testGetParts_OneWindow() { >+ MApplication application = createApplication("partId", "partId2"); >+ MWindow window = application.getChildren().get(0); >+ MPartStack partStack = (MPartStack) window.getChildren().get(0); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ Collection<MPart> parts = partService.getParts(); >+ assertNotNull(parts); >+ assertEquals(2, parts.size()); >+ assertTrue(parts.containsAll(partStack.getChildren())); >+ } >+ >+ public void testGetParts_TwoWindows() { >+ MApplication application = createApplication(new String[] { "partId", >+ "partId2" }, new String[] { "partIA", "partIdB", "partIdC" }); >+ >+ MWindow windowA = application.getChildren().get(0); >+ MWindow windowB = application.getChildren().get(1); >+ >+ engine.createGui(windowA); >+ engine.createGui(windowB); >+ >+ EPartService partServiceA = (EPartService) windowA.getContext().get( >+ EPartService.class.getName()); >+ EPartService partServiceB = (EPartService) windowB.getContext().get( >+ EPartService.class.getName()); >+ >+ MPartStack partStackA = (MPartStack) windowA.getChildren().get(0); >+ MPartStack partStackB = (MPartStack) windowB.getChildren().get(0); >+ >+ Collection<MPart> partsA = partServiceA.getParts(); >+ Collection<MPart> partsB = partServiceB.getParts(); >+ >+ assertNotNull(partsA); >+ assertEquals(2, partsA.size()); >+ assertTrue(partsA.containsAll(partStackA.getChildren())); >+ >+ assertNotNull(partsB); >+ assertEquals(3, partsB.size()); >+ assertTrue(partsB.containsAll(partStackB.getChildren())); >+ >+ for (MPart partA : partsA) { >+ assertFalse(partsB.contains(partA)); >+ } >+ } >+ >+ public void testIsVisible_ViewVisible() { >+ MApplication application = createApplication("partId"); >+ >+ MWindow window = application.getChildren().get(0); >+ MPartStack partStack = (MPartStack) window.getChildren().get(0); >+ MPart part = partStack.getChildren().get(0); >+ partStack.setActiveChild(part); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ assertTrue(partService.isPartVisible(part)); >+ } >+ >+ public void testIsVisible_ViewNotVisible() { >+ MApplication application = createApplication("partId", "partId2"); >+ >+ MWindow window = application.getChildren().get(0); >+ MPartStack partStack = (MPartStack) window.getChildren().get(0); >+ partStack.setActiveChild(partStack.getChildren().get(0)); >+ >+ engine.createGui(window); >+ >+ MPart part = partStack.getChildren().get(1); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ assertFalse(partService.isPartVisible(part)); >+ } >+ >+ public void testIsVisible_ViewInAnotherWindow() { >+ MApplication application = createApplication(new String[] { >+ "partFrontA", "partBackA" }, new String[] { "partFrontB", >+ "partBackB" }); >+ >+ MWindow windowA = application.getChildren().get(0); >+ MPartStack partStackA = (MPartStack) windowA.getChildren().get(0); >+ MPart partFrontA = partStackA.getChildren().get(0); >+ MPart partBackA = partStackA.getChildren().get(1); >+ partStackA.setActiveChild(partFrontA); >+ >+ 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); >+ >+ engine.createGui(windowA); >+ engine.createGui(windowB); >+ >+ EPartService partServiceA = (EPartService) windowA.getContext().get( >+ EPartService.class.getName()); >+ EPartService partServiceB = (EPartService) windowB.getContext().get( >+ EPartService.class.getName()); >+ >+ assertTrue(partServiceA.isPartVisible(partFrontA)); >+ assertFalse(partServiceA.isPartVisible(partBackA)); >+ assertFalse(partServiceA.isPartVisible(partFrontB)); >+ assertFalse(partServiceA.isPartVisible(partBackB)); >+ >+ assertFalse(partServiceB.isPartVisible(partFrontA)); >+ assertFalse(partServiceB.isPartVisible(partBackA)); >+ assertTrue(partServiceB.isPartVisible(partFrontB)); >+ assertFalse(partServiceB.isPartVisible(partBackB)); >+ } >+ >+ private MApplication createApplication(String partId) { >+ return createApplication(new String[] { partId }); >+ } >+ >+ private MApplication createApplication(String... partIds) { >+ return createApplication(new String[][] { partIds }); >+ } >+ >+ private MApplication createApplication(String[]... partIds) { >+ return createApplication(partIds.length, partIds); >+ } >+ >+ private MApplication createApplication(int windows, String[][] partIds) { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ >+ for (int i = 0; i < windows; i++) { >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartStack partStack = MApplicationFactory.eINSTANCE >+ .createPartStack(); >+ window.getChildren().add(partStack); >+ >+ for (int j = 0; j < partIds[i].length; j++) { >+ MPart part = MApplicationFactory.eINSTANCE.createPart(); >+ part.setId(partIds[i][j]); >+ partStack.getChildren().add(part); >+ } >+ } >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ applicationContext.set(MElementContainer.class.getName(), application); >+ application.setContext(applicationContext); >+ >+ 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.5 >diff -u -r1.5 HeadlessContextPresentationEngine.java >--- src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java 16 Nov 2009 18:44:04 -0000 1.5 >+++ src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java 27 Nov 2009 20:14:27 -0000 >@@ -112,6 +112,9 @@ > createdContext.declareModifiable(variable); > } > >+ if (element instanceof MElementContainer<?>) { >+ createdContext.set(MElementContainer.class.getName(), element); >+ } > mcontext.setContext(createdContext); > } > >Index: src/org/eclipse/e4/ui/tests/application/StartupTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/StartupTestSuite.java,v >retrieving revision 1.2 >diff -u -r1.2 StartupTestSuite.java >--- src/org/eclipse/e4/ui/tests/application/StartupTestSuite.java 23 Oct 2009 15:04:10 -0000 1.2 >+++ src/org/eclipse/e4/ui/tests/application/StartupTestSuite.java 27 Nov 2009 20:14:27 -0000 >@@ -19,6 +19,7 @@ > public static Test suite() { > TestSuite suite = new StartupTestSuite(); > >+ suite.addTestSuite(EPartServiceTest.class); > suite.addTestSuite(HeadlessContactsDemoTest.class); > suite.addTestSuite(HeadlessPhotoDemoTest.class); > >#P org.eclipse.e4.ui.workbench >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench/META-INF/MANIFEST.MF,v >retrieving revision 1.27 >diff -u -r1.27 MANIFEST.MF >--- META-INF/MANIFEST.MF 4 Nov 2009 19:31:00 -0000 1.27 >+++ META-INF/MANIFEST.MF 27 Nov 2009 20:14:28 -0000 >@@ -25,5 +25,5 @@ > org.eclipse.e4.workbench.ui.behaviors, > org.eclipse.e4.workbench.ui.internal;x-friends:="org.eclipse.e4.ui.workbench.fragment,org.eclipse.e4.ui.workbench.renderers.swt" > Bundle-Activator: org.eclipse.e4.workbench.ui.internal.Activator >-Service-Component: OSGI-INF/progress.xml >+Service-Component: OSGI-INF/progress.xml, OSGI-INF/partService.xml > Import-Package: javax.inject;version="1.0.0" >Index: OSGI-INF/partService.xml >=================================================================== >RCS file: OSGI-INF/partService.xml >diff -N OSGI-INF/partService.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ OSGI-INF/partService.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.e4.ui.workbench.partService"> >+ <implementation class="org.eclipse.e4.workbench.ui.internal.PartServiceCreationFunction"/> >+ <service> >+ <provide interface="org.eclipse.e4.core.services.context.IContextFunction"/> >+ </service> >+ <property name="service.context.key" type="String" value="org.eclipse.e4.workbench.modeling.EPartService"/> >+</scr:component> >\ No newline at end of file >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench/build.properties,v >retrieving revision 1.5 >diff -u -r1.5 build.properties >--- build.properties 30 Jul 2009 21:28:14 -0000 1.5 >+++ build.properties 27 Nov 2009 20:14:28 -0000 >@@ -4,5 +4,5 @@ > plugin.xml,\ > .options,\ > OSGI-INF/ >-source.. = src/ > src.includes = schema/ >+source.. = src/ >Index: src/org/eclipse/e4/workbench/modeling/EPartService.java >=================================================================== >RCS file: src/org/eclipse/e4/workbench/modeling/EPartService.java >diff -N src/org/eclipse/e4/workbench/modeling/EPartService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/workbench/modeling/EPartService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.workbench.modeling; >+ >+import java.util.Collection; >+import org.eclipse.e4.ui.model.application.MPart; >+ >+public interface EPartService { >+ >+ public void activate(MPart part); >+ >+ public void bringToTop(MPart part); >+ >+ public MPart findPart(String id); >+ >+ public Collection<MPart> getParts(); >+ >+ public MPart getActivePart(); >+ >+ public boolean isPartVisible(MPart part); >+ >+ // public MPart showPart(String id); >+ // >+ // public MPart showPart(MPart part); >+ >+} >Index: src/org/eclipse/e4/workbench/ui/internal/PartServiceCreationFunction.java >=================================================================== >RCS file: src/org/eclipse/e4/workbench/ui/internal/PartServiceCreationFunction.java >diff -N src/org/eclipse/e4/workbench/ui/internal/PartServiceCreationFunction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/workbench/ui/internal/PartServiceCreationFunction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.e4.workbench.ui.internal; >+ >+import org.eclipse.e4.core.services.context.IEclipseContext; >+import org.eclipse.e4.core.services.context.spi.ContextFunction; >+import org.eclipse.e4.core.services.context.spi.ContextInjectionFactory; >+ >+/** >+ * >+ */ >+public class PartServiceCreationFunction extends ContextFunction { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.e4.core.services.context.spi.ContextFunction#compute(org.eclipse.e4.core.services >+ * .context.IEclipseContext, java.lang.Object[]) >+ */ >+ @Override >+ public Object compute(IEclipseContext context, Object[] arguments) { >+ return ContextInjectionFactory.make(PartServiceImpl.class, context); >+ } >+ >+} >Index: src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java >=================================================================== >RCS file: src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java >diff -N src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,137 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.workbench.ui.internal; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import javax.inject.Inject; >+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.MUIElement; >+import org.eclipse.e4.workbench.modeling.EPartService; >+ >+public class PartServiceImpl implements EPartService { >+ >+ @Inject >+ private MElementContainer<MUIElement> elementContainer; >+ >+ protected MContext getParentWithContext(MUIElement part) { >+ MElementContainer<MUIElement> parent = part.getParent(); >+ while (parent != null) { >+ if (parent instanceof MContext) { >+ if (((MContext) parent).getContext() != null) >+ return (MContext) parent; >+ } >+ parent = parent.getParent(); >+ } >+ return null; >+ } >+ >+ public void bringToTop(MPart part) { >+ if (isInContainer(part)) { >+ internalBringToTop(part); >+ } >+ } >+ >+ private void internalBringToTop(MPart part) { >+ MElementContainer<MUIElement> parent = part.getParent(); >+ if (parent.getActiveChild() != part) { >+ parent.setActiveChild(part); >+ } >+ } >+ >+ public MPart findPart(String id) { >+ return findPart(elementContainer, id); >+ } >+ >+ public Collection<MPart> getParts() { >+ return getParts(new ArrayList<MPart>(), elementContainer); >+ } >+ >+ private Collection<MPart> getParts(Collection<MPart> parts, >+ MElementContainer<?> elementContainer) { >+ for (Object child : elementContainer.getChildren()) { >+ if (child instanceof MPart) { >+ parts.add((MPart) child); >+ } else if (child instanceof MElementContainer<?>) { >+ getParts(parts, (MElementContainer<?>) child); >+ } >+ } >+ return parts; >+ } >+ >+ public boolean isPartVisible(MPart part) { >+ if (isInContainer(part)) { >+ MElementContainer<MUIElement> parent = part.getParent(); >+ return parent.getActiveChild() == part; >+ } >+ return false; >+ } >+ >+ private MPart findPart(MElementContainer<?> container, String id) { >+ for (Object object : container.getChildren()) { >+ if (object instanceof MPart) { >+ MPart part = (MPart) object; >+ if (id.equals(part.getId())) { >+ return part; >+ } >+ } else if (object instanceof MElementContainer<?>) { >+ MPart part = findPart((MElementContainer<?>) object, id); >+ if (part != null) { >+ return part; >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ private boolean isInContainer(MPart part) { >+ return isInContainer(elementContainer, part); >+ } >+ >+ private boolean isInContainer(MElementContainer<?> container, MPart part) { >+ for (Object object : container.getChildren()) { >+ if (object == part) { >+ return true; >+ } else if (object instanceof MElementContainer<?>) { >+ if (isInContainer((MElementContainer<?>) object, part)) { >+ return true; >+ } >+ } >+ } >+ >+ return false; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.e4.workbench.modeling.EPartService#activate(org.eclipse.e4.ui.model.application >+ * .MPart) >+ */ >+ public void activate(MPart part) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.workbench.modeling.EPartService#getActivePart() >+ */ >+ public MPart getActivePart() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+} >#P org.eclipse.e4.ui.workbench.renderers.swt >Index: src/org/eclipse/e4/workbench/ui/renderers/swt/WBWRenderer.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/workbench/ui/renderers/swt/WBWRenderer.java,v >retrieving revision 1.13 >diff -u -r1.13 WBWRenderer.java >--- src/org/eclipse/e4/workbench/ui/renderers/swt/WBWRenderer.java 27 Nov 2009 18:40:30 -0000 1.13 >+++ src/org/eclipse/e4/workbench/ui/renderers/swt/WBWRenderer.java 27 Nov 2009 20:14:28 -0000 >@@ -109,8 +109,7 @@ > } > }; > >- eventBroker.subscribe(UIEvents.buildTopic( >- UIEvents.UIItem.TOPIC, >+ eventBroker.subscribe(UIEvents.buildTopic(UIEvents.UIItem.TOPIC, > UIEvents.ALL_ATTRIBUTES), shellUpdater); > } > >@@ -148,6 +147,7 @@ > // set up context > IEclipseContext localContext = getContext(wbwModel); > localContext.set(IContextConstants.DEBUG_STRING, "MWindow"); //$NON-NLS-1$ >+ localContext.set(MElementContainer.class.getName(), wbwModel); > parentContext.set(IContextConstants.ACTIVE_CHILD, localContext); > > // Add the shell into the WBW's context >#P org.eclipse.e4.ui.workbench.swt >Index: src/org/eclipse/e4/ui/workbench/swt/internal/E4Application.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/E4Application.java,v >retrieving revision 1.4 >diff -u -r1.4 E4Application.java >--- src/org/eclipse/e4/ui/workbench/swt/internal/E4Application.java 27 Nov 2009 16:25:46 -0000 1.4 >+++ src/org/eclipse/e4/ui/workbench/swt/internal/E4Application.java 27 Nov 2009 20:14:29 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.e4.core.services.context.spi.IContextConstants; > import org.eclipse.e4.ui.internal.services.ActiveContextsFunction; > import org.eclipse.e4.ui.model.application.MApplication; >+import org.eclipse.e4.ui.model.application.MElementContainer; > import org.eclipse.e4.ui.model.application.MPart; > import org.eclipse.e4.ui.services.IServiceConstants; > import org.eclipse.e4.ui.services.IStylingEngine; >@@ -65,6 +66,7 @@ > > // Set the app's context after adding itself > appContext.set(MApplication.class.getName(), appModel); >+ appContext.set(MElementContainer.class.getName(), appModel); > appModel.setContext(appContext); > > // Parse out parameters from both the command line and/or the product
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