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 157513 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 v07
bug295003-patch-v7.txt (text/plain), 23.61 KB, created by
Remy Suen
on 2010-01-28 07:48:13 EST
(
hide
)
Description:
EPartService v07
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2010-01-28 07:48:13 EST
Size:
23.61 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.tests >Index: src/org/eclipse/e4/ui/tests/application/ClientEditor.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/application/ClientEditor.java >diff -N src/org/eclipse/e4/ui/tests/application/ClientEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/application/ClientEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.e4.ui.tests.application; >+ >+import javax.inject.Inject; >+ >+import org.eclipse.e4.ui.model.application.MSaveablePart; >+ >+public class ClientEditor { >+ >+ @Inject >+ private MSaveablePart saveablePart; >+ >+ private boolean saveCalled = false; >+ >+ private boolean throwException = false; >+ >+ public void setThrowException(boolean throwException) { >+ this.throwException = throwException; >+ } >+ >+ void doSave() { >+ saveCalled = true; >+ if (throwException) { >+ throw new RuntimeException(); >+ } >+ >+ saveablePart.setDirty(false); >+ } >+ >+ public boolean wasSaveCalled() { >+ return saveCalled; >+ } >+ >+} >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.13 >diff -u -r1.13 EPartServiceTest.java >--- src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 27 Jan 2010 12:52:05 -0000 1.13 >+++ src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java 28 Jan 2010 12:46:45 -0000 >@@ -10,6 +10,7 @@ > ******************************************************************************/ > package org.eclipse.e4.ui.tests.application; > >+import java.util.Arrays; > import java.util.Collection; > > import junit.framework.TestCase; >@@ -28,6 +29,8 @@ > import org.eclipse.e4.ui.services.IServiceConstants; > import org.eclipse.e4.ui.workbench.swt.internal.E4Application; > import org.eclipse.e4.workbench.modeling.EPartService; >+import org.eclipse.e4.workbench.modeling.ISaveHandler; >+import org.eclipse.e4.workbench.modeling.ISaveHandler.Save; > import org.eclipse.e4.workbench.ui.IPresentationEngine; > import org.eclipse.e4.workbench.ui.internal.UIEventPublisher; > import org.eclipse.e4.workbench.ui.internal.Workbench; >@@ -830,11 +833,7 @@ > 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)); >+ initialize(applicationContext, application); > > getEngine().createGui(window); > >@@ -897,11 +896,7 @@ > 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)); >+ initialize(applicationContext, application); > > getEngine().createGui(window); > >@@ -948,11 +943,7 @@ > 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)); >+ initialize(applicationContext, application); > > getEngine().createGui(window); > >@@ -1004,11 +995,7 @@ > 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)); >+ initialize(applicationContext, application); > > getEngine().createGui(window); > >@@ -1056,11 +1043,7 @@ > 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)); >+ initialize(applicationContext, application); > > getEngine().createGui(window); > >@@ -1107,11 +1090,7 @@ > 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)); >+ initialize(applicationContext, application); > > getEngine().createGui(window); > >@@ -1274,6 +1253,259 @@ > testGetDirtyParts3(false, false); > } > >+ private void testSavePart(final Save returnValue, boolean confirm, >+ boolean beforeDirty, boolean afterDirty, boolean success, >+ boolean saveCalled, boolean throwException) { >+ MApplication application = MApplicationFactory.eINSTANCE >+ .createApplication(); >+ >+ MWindow window = MApplicationFactory.eINSTANCE.createWindow(); >+ application.getChildren().add(window); >+ MSaveablePart saveablePart = MApplicationFactory.eINSTANCE >+ .createSaveablePart(); >+ saveablePart.setDirty(beforeDirty); >+ saveablePart >+ .setURI("platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.application.ClientEditor"); >+ 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)); >+ >+ getEngine().createGui(window); >+ >+ ClientEditor editor = (ClientEditor) saveablePart.getObject(); >+ editor.setThrowException(throwException); >+ >+ window.getContext().set(ISaveHandler.class.getName(), >+ new ISaveHandler() { >+ public Save[] promptToSave( >+ Collection<MSaveablePart> saveablePart) { >+ return null; >+ } >+ >+ public Save promptToSave(MSaveablePart saveablePart) { >+ return returnValue; >+ } >+ }); >+ >+ EPartService partService = (EPartService) window.getContext().get( >+ EPartService.class.getName()); >+ if (beforeDirty) { >+ assertEquals(success, partService.savePart(saveablePart, confirm)); >+ } else { >+ assertTrue( >+ "The part is not dirty, the save operation should complete successfully", >+ partService.savePart(saveablePart, confirm)); >+ } >+ >+ assertEquals(afterDirty, saveablePart.isDirty()); >+ assertEquals(saveCalled, editor.wasSaveCalled()); >+ } >+ >+ private void testSavePart(Save returnValue, boolean confirm, >+ boolean beforeDirty, boolean throwException) { >+ switch (returnValue) { >+ case YES: >+ if (throwException) { >+ if (beforeDirty) { >+ testSavePart(ISaveHandler.Save.YES, confirm, beforeDirty, >+ beforeDirty, false, true, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.YES, confirm, beforeDirty, >+ beforeDirty, true, false, throwException); >+ } >+ } else if (beforeDirty) { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.YES, confirm, beforeDirty, >+ false, true, true, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.YES, confirm, beforeDirty, >+ false, true, true, throwException); >+ } >+ } else { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.YES, confirm, beforeDirty, >+ false, true, false, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.YES, confirm, beforeDirty, >+ false, true, false, throwException); >+ } >+ } >+ break; >+ case NO: >+ if (throwException) { >+ if (beforeDirty) { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.NO, confirm, >+ beforeDirty, beforeDirty, true, false, >+ throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.NO, confirm, >+ beforeDirty, beforeDirty, false, true, >+ throwException); >+ } >+ } else { >+ testSavePart(ISaveHandler.Save.NO, confirm, beforeDirty, >+ beforeDirty, true, false, throwException); >+ } >+ } else if (beforeDirty) { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.NO, confirm, beforeDirty, >+ true, true, false, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.NO, confirm, beforeDirty, >+ false, true, true, throwException); >+ } >+ } else { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.NO, confirm, beforeDirty, >+ false, true, false, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.NO, confirm, beforeDirty, >+ false, true, false, throwException); >+ } >+ } >+ break; >+ case CANCEL: >+ if (throwException) { >+ if (beforeDirty) { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, beforeDirty, false, false, >+ throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, beforeDirty, false, true, >+ throwException); >+ } >+ } else { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, beforeDirty, true, false, >+ throwException); >+ } >+ } else if (beforeDirty) { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, true, false, false, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, false, true, true, throwException); >+ } >+ } else { >+ if (confirm) { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, false, true, false, throwException); >+ } else { >+ testSavePart(ISaveHandler.Save.CANCEL, confirm, >+ beforeDirty, false, true, false, throwException); >+ } >+ } >+ break; >+ default: >+ fail("Unknown expected return value set: " + returnValue); >+ } >+ } >+ >+ public void testSavePart_YesTrueTrueTrue() { >+ testSavePart(ISaveHandler.Save.YES, true, true, true); >+ } >+ >+ public void testSavePart_YesTrueTrueFalse() { >+ testSavePart(ISaveHandler.Save.YES, true, true, false); >+ } >+ >+ public void testSavePart_YesTrueFalseTrue() { >+ testSavePart(ISaveHandler.Save.YES, true, false, true); >+ } >+ >+ public void testSavePart_YesTrueFalseFalse() { >+ testSavePart(ISaveHandler.Save.YES, true, false, false); >+ } >+ >+ public void testSavePart_YesFalseTrueTrue() { >+ testSavePart(ISaveHandler.Save.YES, false, true, true); >+ } >+ >+ public void testSavePart_YesFalseTrueFalse() { >+ testSavePart(ISaveHandler.Save.YES, false, true, false); >+ } >+ >+ public void testSavePart_YesFalseFalseTrue() { >+ testSavePart(ISaveHandler.Save.YES, false, false, true); >+ } >+ >+ public void testSavePart_YesFalseFalseFalse() { >+ testSavePart(ISaveHandler.Save.YES, false, false, false); >+ } >+ >+ public void testSavePart_NoTrueTrueTrue() { >+ testSavePart(ISaveHandler.Save.NO, true, true, true); >+ } >+ >+ public void testSavePart_NoTrueTrueFalse() { >+ testSavePart(ISaveHandler.Save.NO, true, true, false); >+ } >+ >+ public void testSavePart_NoTrueFalseTrue() { >+ testSavePart(ISaveHandler.Save.NO, true, false, true); >+ } >+ >+ public void testSavePart_NoTrueFalseFalse() { >+ testSavePart(ISaveHandler.Save.NO, true, false, false); >+ } >+ >+ public void testSavePart_NoFalseTrueTrue() { >+ testSavePart(ISaveHandler.Save.NO, false, true, true); >+ } >+ >+ public void testSavePart_NoFalseTrueFalse() { >+ testSavePart(ISaveHandler.Save.NO, false, true, false); >+ } >+ >+ public void testSavePart_NoFalseFalseTrue() { >+ testSavePart(ISaveHandler.Save.NO, false, false, true); >+ } >+ >+ public void testSavePart_NoFalseFalseFalse() { >+ testSavePart(ISaveHandler.Save.NO, false, false, false); >+ } >+ >+ public void testSavePart_CancelTrueTrueTrue() { >+ testSavePart(ISaveHandler.Save.CANCEL, true, true, true); >+ } >+ >+ public void testSavePart_CancelTrueTrueFalse() { >+ testSavePart(ISaveHandler.Save.CANCEL, true, true, false); >+ } >+ >+ public void testSavePart_CancelTrueFalseTrue() { >+ testSavePart(ISaveHandler.Save.CANCEL, true, false, true); >+ } >+ >+ public void testSavePart_CancelTrueFalseFalse() { >+ testSavePart(ISaveHandler.Save.CANCEL, true, false, false); >+ } >+ >+ public void testSavePart_CancelFalseTrueTrue() { >+ testSavePart(ISaveHandler.Save.CANCEL, false, true, true); >+ } >+ >+ public void testSavePart_CancelFalseTrueFalse() { >+ testSavePart(ISaveHandler.Save.CANCEL, false, true, false); >+ } >+ >+ public void testSavePart_CancelFalseFalseTrue() { >+ testSavePart(ISaveHandler.Save.CANCEL, false, false, true); >+ } >+ >+ public void testSavePart_CancelFalseFalseFalse() { >+ testSavePart(ISaveHandler.Save.CANCEL, false, false, false); >+ } >+ > public void testSwitchWindows() { > // create an application with two windows > MApplication application = MApplicationFactory.eINSTANCE >@@ -1290,11 +1522,7 @@ > window1.setActiveChild(part); > > // setup the context >- applicationContext.set(MApplication.class.getName(), application); >- application.setContext(applicationContext); >- Workbench.processHierarchy(application); >- ((Notifier) application).eAdapters().add( >- new UIEventPublisher(applicationContext)); >+ initialize(applicationContext, application); > > // render the windows > getEngine().createGui(window1); >@@ -1365,12 +1593,31 @@ > } > } > >+ initialize(applicationContext, application); >+ >+ return application; >+ } >+ >+ private void initialize(IEclipseContext applicationContext, >+ MApplication application) { > applicationContext.set(MApplication.class.getName(), application); > application.setContext(applicationContext); > Workbench.processHierarchy(application); > ((Notifier) application).eAdapters().add( > new UIEventPublisher(applicationContext)); > >- return application; >+ applicationContext.set(ISaveHandler.class.getName(), >+ new ISaveHandler() { >+ public Save[] promptToSave( >+ Collection<MSaveablePart> saveablePart) { >+ Save[] ret = new Save[saveablePart.size()]; >+ Arrays.fill(ret, ISaveHandler.Save.YES); >+ return ret; >+ } >+ >+ public Save promptToSave(MSaveablePart saveablePart) { >+ return ISaveHandler.Save.YES; >+ } >+ }); > } > } >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.9 >diff -u -r1.9 HeadlessContextPresentationEngine.java >--- src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java 27 Jan 2010 12:52:05 -0000 1.9 >+++ src/org/eclipse/e4/ui/tests/application/HeadlessContextPresentationEngine.java 28 Jan 2010 12:46:45 -0000 >@@ -15,6 +15,7 @@ > > import javax.inject.Inject; > >+import org.eclipse.e4.core.services.IContributionFactory; > import org.eclipse.e4.core.services.IDisposable; > import org.eclipse.e4.core.services.annotations.PostConstruct; > import org.eclipse.e4.core.services.context.EclipseContextFactory; >@@ -22,6 +23,7 @@ > import org.eclipse.e4.core.services.context.spi.IContextConstants; > import org.eclipse.e4.ui.model.application.MApplicationElement; > import org.eclipse.e4.ui.model.application.MContext; >+import org.eclipse.e4.ui.model.application.MContribution; > import org.eclipse.e4.ui.model.application.MElementContainer; > import org.eclipse.e4.ui.model.application.MPart; > import org.eclipse.e4.ui.model.application.MPartStack; >@@ -39,6 +41,9 @@ > @Inject > private IEventBroker eventBroker; > >+ @Inject >+ private IContributionFactory contributionFactory; >+ > private EventHandler childHandler; > private EventHandler activeChildHandler; > >@@ -138,6 +143,16 @@ > } > > mcontext.setContext(createdContext); >+ >+ if (element instanceof MContribution) { >+ MContribution contribution = (MContribution) element; >+ String uri = contribution.getURI(); >+ if (uri != null) { >+ Object clientObject = contributionFactory.create(uri, >+ createdContext); >+ contribution.setObject(clientObject); >+ } >+ } > } > > if (element instanceof MPartStack) { >#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.7 >diff -u -r1.7 EPartService.java >--- src/org/eclipse/e4/workbench/modeling/EPartService.java 27 Jan 2010 13:43:27 -0000 1.7 >+++ src/org/eclipse/e4/workbench/modeling/EPartService.java 28 Jan 2010 12:46:46 -0000 >@@ -132,8 +132,37 @@ > */ > public MPart showPart(String id, PartState partState); > >+ /** >+ * Returns a collection of all the saveable parts that are being managed by this service. >+ * >+ * >+ * @return a collection of saveable parts that are being managed by this service, never >+ * <code>null</code> >+ */ > public Collection<MSaveablePart> getSaveableParts(); > >+ /** >+ * Returns a collection of all the dirty saveable parts that are being managed by this service. >+ * >+ * >+ * @return a collection of dirty saveable parts that are being managed by this service, never >+ * <code>null</code> >+ */ > public Collection<MSaveablePart> getDirtyParts(); > >+ /** >+ * Saves the contents of the part if it is dirty and returns whether the operation completed. >+ * >+ * @param part >+ * the part to save >+ * @param confirm >+ * <code>true</code> if the user should be prompted prior to saving the changes, and >+ * <code>false</code> to save changes without asking >+ * @return <code>true</code> if the operation completed successfully, <code>false</code> if the >+ * user canceled the operation or if an error occurred while saving the changes >+ */ >+ public boolean savePart(MSaveablePart part, boolean confirm); >+ >+ public boolean saveAll(boolean confirm); >+ > } >Index: src/org/eclipse/e4/workbench/modeling/ISaveHandler.java >=================================================================== >RCS file: src/org/eclipse/e4/workbench/modeling/ISaveHandler.java >diff -N src/org/eclipse/e4/workbench/modeling/ISaveHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/workbench/modeling/ISaveHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * 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.MSaveablePart; >+ >+public interface ISaveHandler { >+ >+ public enum Save { >+ YES, NO, CANCEL >+ } >+ >+ public Save promptToSave(MSaveablePart saveablePart); >+ >+ public Save[] promptToSave(Collection<MSaveablePart> saveablePart); >+ >+} >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.16 >diff -u -r1.16 PartServiceImpl.java >--- src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 27 Jan 2010 13:43:27 -0000 1.16 >+++ src/org/eclipse/e4/workbench/ui/internal/PartServiceImpl.java 28 Jan 2010 12:46:46 -0000 >@@ -10,14 +10,18 @@ > ******************************************************************************/ > package org.eclipse.e4.workbench.ui.internal; > >+import java.lang.reflect.InvocationTargetException; > 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; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.e4.core.services.Logger; > import org.eclipse.e4.core.services.annotations.Optional; > import org.eclipse.e4.core.services.context.IEclipseContext; >+import org.eclipse.e4.core.services.context.spi.ContextInjectionFactory; > import org.eclipse.e4.core.services.context.spi.IContextConstants; > import org.eclipse.e4.ui.model.application.MApplication; > import org.eclipse.e4.ui.model.application.MApplicationElement; >@@ -34,6 +38,7 @@ > import org.eclipse.e4.ui.services.events.IEventBroker; > import org.eclipse.e4.workbench.modeling.EModelService; > import org.eclipse.e4.workbench.modeling.EPartService; >+import org.eclipse.e4.workbench.modeling.ISaveHandler; > import org.eclipse.e4.workbench.ui.IPresentationEngine; > import org.eclipse.e4.workbench.ui.UIEvents; > import org.eclipse.emf.ecore.EObject; >@@ -42,6 +47,7 @@ > import org.osgi.service.event.EventHandler; > > public class PartServiceImpl implements EPartService { >+ > public static void addListener(IEventBroker broker) { > EventHandler windowHandler = new EventHandler() { > public void handleEvent(Event event) { >@@ -76,6 +82,12 @@ > private EModelService modelService; > > @Inject >+ private Logger logger; >+ >+ @Inject >+ private ISaveHandler saveHandler; >+ >+ @Inject > void setPart(@Optional @Named(IServiceConstants.ACTIVE_PART) MPart p) { > activePart = p; > } >@@ -335,4 +347,45 @@ > } > return dirtyParts; > } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.workbench.modeling.EPartService#save(org.eclipse.e4.ui.model.application. >+ * MSaveablePart, boolean) >+ */ >+ public boolean savePart(MSaveablePart part, boolean confirm) { >+ if (!part.isDirty()) { >+ return true; >+ } >+ >+ if (confirm && saveHandler != null) { >+ switch (saveHandler.promptToSave(part)) { >+ case NO: >+ return true; >+ case CANCEL: >+ return false; >+ } >+ } >+ >+ Object client = part.getObject(); >+ try { >+ ContextInjectionFactory.invoke(client, "doSave", part.getContext()); //$NON-NLS-1$ >+ } catch (InvocationTargetException e) { >+ if (logger != null) { >+ logger.error(e.getCause()); >+ } >+ return false; >+ } catch (CoreException e) { >+ if (logger != null) { >+ logger.error(e.getStatus().getException()); >+ } >+ return false; >+ } >+ return true; >+ } >+ >+ public boolean saveAll(boolean confirm) { >+ return false; >+ } > }
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