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 156933 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 v05
bug295003-patch-v5.txt (text/plain), 13.56 KB, created by
Remy Suen
on 2010-01-22 08:47:30 EST
(
hide
)
Description:
EPartService v05
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2010-01-22 08:47:30 EST
Size:
13.56 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.10 >diff -u -r1.10 EPartServiceTest.java >--- src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 9 Jan 2010 21:24:20 -0000 1.10 >+++ src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 22 Jan 2010 13:46:05 -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 >@@ -23,6 +23,7 @@ > import org.eclipse.e4.ui.model.application.MPart; > import org.eclipse.e4.ui.model.application.MPartDescriptor; > import org.eclipse.e4.ui.model.application.MPartStack; >+import org.eclipse.e4.ui.model.application.MSaveablePart; > import org.eclipse.e4.ui.model.application.MWindow; > import org.eclipse.e4.ui.services.IServiceConstants; > import org.eclipse.e4.ui.workbench.swt.internal.E4Application; >@@ -682,6 +683,231 @@ > assertEquals(part, partService.getActivePart()); > } > >+ public void testShowPart_DefinedCategoryStackNotExists() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE >+ .createPartDescriptor(); >+ partDescriptor.setCategory("categoryId"); >+ partDescriptor.setId("partId"); >+ application.getDescriptors().add(partDescriptor); >+ >+ partDescriptor = MApplicationFactory.eINSTANCE.createPartDescriptor(); >+ partDescriptor.setCategory("categoryId"); >+ partDescriptor.setId("partId2"); >+ application.getDescriptors().add(partDescriptor); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ MPart part = partService.showPart("partId"); >+ >+ assertEquals(1, window.getChildren().size()); >+ assertTrue(window.getChildren().get(0) instanceof MPartStack); >+ >+ MPartStack stack = (MPartStack) window.getChildren().get(0); >+ assertEquals("categoryId", stack.getId()); >+ >+ assertEquals(1, stack.getChildren().size()); >+ assertEquals(part, stack.getChildren().get(0)); >+ >+ MPart part2 = partService.showPart("partId2"); >+ assertEquals(2, stack.getChildren().size()); >+ assertEquals(part, stack.getChildren().get(0)); >+ assertEquals(part2, stack.getChildren().get(1)); >+ } >+ >+ public void testShowPart_DefinedCategoryStackExists() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ >+ MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE >+ .createPartDescriptor(); >+ partDescriptor.setCategory("categoryId"); >+ partDescriptor.setId("partId"); >+ application.getDescriptors().add(partDescriptor); >+ >+ partDescriptor = MApplicationFactory.eINSTANCE.createPartDescriptor(); >+ partDescriptor.setCategory("categoryId"); >+ partDescriptor.setId("partId2"); >+ application.getDescriptors().add(partDescriptor); >+ >+ MPartStack stack = MApplicationFactory.eINSTANCE.createPartStack(); >+ stack.setId("categoryId"); >+ window.getChildren().add(stack); >+ >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ MPart part = partService.showPart("partId"); >+ assertEquals(1, stack.getChildren().size()); >+ assertEquals(part, stack.getChildren().get(0)); >+ >+ MPart part2 = partService.showPart("partId2"); >+ assertEquals(2, stack.getChildren().size()); >+ assertEquals(part, stack.getChildren().get(0)); >+ assertEquals(part2, stack.getChildren().get(1)); >+ } >+ >+ public void testGetSaveableParts() { >+ 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<MSaveablePart> saveableParts = partService >+ .getSaveableParts(); >+ assertNotNull(saveableParts); >+ assertEquals(0, saveableParts.size()); >+ } >+ >+ public void testGetSaveableParts2() { >+ MApplication application = createApplication("partId"); >+ MWindow window = application.getChildren().get(0); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ Collection<MSaveablePart> saveableParts = partService >+ .getSaveableParts(); >+ assertNotNull(saveableParts); >+ assertEquals(0, saveableParts.size()); >+ } >+ >+ public void testGetSaveableParts3() { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ MSaveablePart saveablePart = MApplicationFactory.eINSTANCE >+ .createSaveablePart(); >+ window.getChildren().add(saveablePart); >+ >+ // setup the context >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ Collection<MSaveablePart> saveableParts = partService >+ .getSaveableParts(); >+ assertNotNull(saveableParts); >+ assertEquals(1, saveableParts.size()); >+ } >+ >+ public void testGetDirtyParts() { >+ 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<MSaveablePart> dirtyParts = partService.getDirtyParts(); >+ assertNotNull(dirtyParts); >+ assertEquals(0, dirtyParts.size()); >+ } >+ >+ public void testGetDirtyParts2() { >+ MApplication application = createApplication("partId"); >+ MWindow window = application.getChildren().get(0); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ Collection<MSaveablePart> dirtyParts = partService.getDirtyParts(); >+ assertNotNull(dirtyParts); >+ assertEquals(0, dirtyParts.size()); >+ } >+ >+ private void testGetDirtyParts3(boolean before, boolean after) { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ MSaveablePart saveablePart = MApplicationFactory.eINSTANCE >+ .createSaveablePart(); >+ saveablePart.setDirty(before); >+ window.getChildren().add(saveablePart); >+ >+ // setup the context >+ applicationContext.set(MApplication.class.getName(), application); >+ application.setContext(applicationContext); >+ Workbench.processHierarchy(application); >+ ((Notifier) application).eAdapters().add( >+ new UIEventPublisher(applicationContext)); >+ >+ engine.createGui(window); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ Collection<MSaveablePart> dirtyParts = partService.getDirtyParts(); >+ assertNotNull(dirtyParts); >+ >+ if (before) { >+ assertEquals(1, dirtyParts.size()); >+ assertEquals(saveablePart, dirtyParts.iterator().next()); >+ } else { >+ assertEquals(0, dirtyParts.size()); >+ } >+ >+ saveablePart.setDirty(after); >+ dirtyParts = partService.getDirtyParts(); >+ >+ if (after) { >+ assertEquals(1, dirtyParts.size()); >+ assertEquals(saveablePart, dirtyParts.iterator().next()); >+ } else { >+ assertEquals(0, dirtyParts.size()); >+ } >+ } >+ >+ public void testGetDirtyParts3_TrueTrue() { >+ testGetDirtyParts3(true, true); >+ } >+ >+ public void testGetDirtyParts3_TrueFalse() { >+ testGetDirtyParts3(true, false); >+ } >+ >+ public void testGetDirtyParts3_FalseTrue() { >+ testGetDirtyParts3(false, true); >+ } >+ >+ public void testGetDirtyParts3_FalseFalse() { >+ testGetDirtyParts3(false, false); >+ } >+ > public void testSwitchWindows() { > // create an application with two windows > MApplication application = MApplicationFactory.eINSTANCE >#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.4 >diff -u -r1.4 EPartService.java >--- src/org/eclipse/e4/workbench/modeling/EPartService.java 8 Jan 2010 14:30:27 -0000 1.4 >+++ src/org/eclipse/e4/workbench/modeling/EPartService.java 22 Jan 2010 13:46:05 -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 >@@ -12,6 +12,7 @@ > > import java.util.Collection; > import org.eclipse.e4.ui.model.application.MPart; >+import org.eclipse.e4.ui.model.application.MSaveablePart; > > public interface EPartService { > public static final String PART_SERVICE_ROOT = "partServiceRoot"; //$NON-NLS-1$ >@@ -32,4 +33,8 @@ > > public MPart showPart(String id); > >+ 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.12 >diff -u -r1.12 PartServiceImpl.java >--- src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 12 Jan 2010 15:32:14 -0000 1.12 >+++ src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 22 Jan 2010 13:46:05 -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 >@@ -12,6 +12,7 @@ > > import java.util.ArrayList; > import java.util.Collection; >+import java.util.List; > import javax.inject.Inject; > import javax.inject.Named; > import org.eclipse.core.runtime.Assert; >@@ -26,6 +27,7 @@ > import org.eclipse.e4.ui.model.application.MPart; > import org.eclipse.e4.ui.model.application.MPartDescriptor; > import org.eclipse.e4.ui.model.application.MPartStack; >+import org.eclipse.e4.ui.model.application.MSaveablePart; > import org.eclipse.e4.ui.model.application.MUIElement; > import org.eclipse.e4.ui.model.application.MWindow; > import org.eclipse.e4.ui.services.IServiceConstants; >@@ -281,6 +283,7 @@ > ((MElementContainer<MPart>) container).getChildren().add(part); > } else { // wrap it in a stack > MPartStack stack = MApplicationFactory.eINSTANCE.createPartStack(); >+ stack.setId(descriptorMatch.getCategory()); > stack.getChildren().add(part); > rootContainer.getChildren().add(stack); > } >@@ -292,4 +295,34 @@ > activate(part); > return part; > } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.workbench.modeling.EPartService#getSaveableParts() >+ */ >+ public Collection<MSaveablePart> getSaveableParts() { >+ List<MSaveablePart> saveableParts = new ArrayList<MSaveablePart>(); >+ for (MPart part : getParts()) { >+ if (part instanceof MSaveablePart) { >+ saveableParts.add((MSaveablePart) part); >+ } >+ } >+ return saveableParts; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.workbench.modeling.EPartService#getDirtyParts() >+ */ >+ public Collection<MSaveablePart> getDirtyParts() { >+ List<MSaveablePart> dirtyParts = new ArrayList<MSaveablePart>(); >+ for (MSaveablePart part : getSaveableParts()) { >+ if (part.isDirty()) { >+ dirtyParts.add(part); >+ } >+ } >+ return dirtyParts; >+ } > }
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