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 116700 Details for
Bug 240775
ResourceUndoContext should be more flexible regarding affected resource policy
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]
Proposed API for resource undo-context policy
resource-undo-context-policy.patch (text/plain), 26.51 KB, created by
Christian Damus
on 2008-11-01 15:41:34 EDT
(
hide
)
Description:
Proposed API for resource undo-context policy
Filename:
MIME Type:
Creator:
Christian Damus
Created:
2008-11-01 15:41:34 EDT
Size:
26.51 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.workspace >Index: src/org/eclipse/emf/workspace/ResourceUndoContext.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.transaction/plugins/org.eclipse.emf.workspace/src/org/eclipse/emf/workspace/ResourceUndoContext.java,v >retrieving revision 1.6 >diff -u -r1.6 ResourceUndoContext.java >--- src/org/eclipse/emf/workspace/ResourceUndoContext.java 4 Feb 2008 14:26:18 -0000 1.6 >+++ src/org/eclipse/emf/workspace/ResourceUndoContext.java 1 Nov 2008 19:32:28 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., 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 >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - Bug 240775 > * > * </copyright> > * >@@ -16,7 +17,6 @@ > */ > package org.eclipse.emf.workspace; > >-import java.util.Collection; > import java.util.Collections; > import java.util.List; > import java.util.Set; >@@ -24,8 +24,6 @@ > import org.eclipse.core.commands.operations.IUndoContext; > import org.eclipse.core.commands.operations.IUndoableOperation; > import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.transaction.TransactionalEditingDomain; > import org.eclipse.emf.workspace.internal.l10n.Messages; >@@ -123,49 +121,27 @@ > * Analyzes a list of notifications to extract the set of {@link Resource}s > * affected by the changes. > * >- * @param notifications a list of {@link Notification}s indicating changes >- * in a resource set >- * >- * @return the resources affected by the specified notifications. >- * The resulting set should be treated as unmodifiable >+ * @param notifications >+ * a list of {@link Notification}s indicating changes in a >+ * resource set >+ * >+ * @return the resources affected by the specified notifications. The >+ * resulting set should be treated as unmodifiable >+ * >+ * @deprecated Since the 1.3 release, use the >+ * {@link IResourceUndoContextPolicy#getContextResources(IUndoableOperation, List)} >+ * method of the editing domain's resource undo-context policy, >+ * instead > */ > public static Set<Resource> getAffectedResources( > List<? extends Notification> notifications) { >- >- Set<Resource> result; >- >- if (notifications.isEmpty()) { >- result = Collections.emptySet(); >- } else { >- result = new java.util.HashSet<Resource>(); >- >- for (Notification next : notifications) { >- Object notifier = next.getNotifier(); >- >- if (notifier instanceof Resource) { >- result.add((Resource) notifier); >- } else if (notifier instanceof EObject) { >- EObject eobj = (EObject) notifier; >- Resource resource = eobj.eResource(); >- >- if (resource != null) { >- result.add(resource); >- } >- >- // if the reference has an opposite, then we will get the >- // notification from the other end, anyway >- final Object feature = next.getFeature(); >- if ((feature instanceof EReference) >- && (((EReference) feature).getEOpposite() == null)) { >- handleCrossResourceReference(result, next); >- } >- } >- } >- } >- >- return result; >+ >+ // the default implementation never considers the operation, so a >+ // null value will not hurt it >+ return IResourceUndoContextPolicy.DEFAULT.getContextResources(null, >+ notifications); > } >- >+ > /** > * Extracts the set of EMF {@link Resource}s affected by the specified > * operation, from the <code>ResourceUndoContext</code>s attached to it. >@@ -194,78 +170,6 @@ > return result; > } > >- /** >- * Handles notifications that can potentially represent cross-resource >- * references. Helper to the {@link #getAffectedResources(List)} method. >- * >- * @param resources collects the affected resources >- * @param notification a potential cross-resource reference change notification >- */ >- private static void handleCrossResourceReference( >- Set<Resource> resources, >- Notification notification) { >- >- Object oldValue = notification.getOldValue(); >- Object newValue = notification.getNewValue(); >- Resource resource; >- >- switch (notification.getEventType()) { >- case Notification.SET: >- case Notification.UNSET: >- if (oldValue != null) { >- resource = ((EObject) oldValue).eResource(); >- >- if (resource != null) { >- resources.add(resource); >- } >- } >- if (newValue != null) { >- resource = ((EObject) newValue).eResource(); >- >- if (resource != null) { >- resources.add(resource); >- } >- } >- break; >- case Notification.ADD: >- resource = ((EObject) newValue).eResource(); >- >- if (resource != null) { >- resources.add(resource); >- } >- break; >- case Notification.ADD_MANY: { >- @SuppressWarnings("unchecked") >- Collection<EObject> newReferences = (Collection<EObject>) newValue; >- for (EObject next : newReferences) { >- resource = next.eResource(); >- >- if (resource != null) { >- resources.add(resource); >- } >- } >- break;} >- case Notification.REMOVE: >- resource = ((EObject) oldValue).eResource(); >- >- if (resource != null) { >- resources.add(resource); >- } >- break; >- case Notification.REMOVE_MANY: { >- @SuppressWarnings("unchecked") >- Collection<EObject> oldReferences = (Collection<EObject>) oldValue; >- for (EObject next : oldReferences) { >- resource = next.eResource(); >- >- if (resource != null) { >- resources.add(resource); >- } >- } >- break;} >- } >- } >- > @Override > public String toString() { > return getLabel(); >Index: src/org/eclipse/emf/workspace/WorkspaceEditingDomainFactory.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.transaction/plugins/org.eclipse.emf.workspace/src/org/eclipse/emf/workspace/WorkspaceEditingDomainFactory.java,v >retrieving revision 1.4 >diff -u -r1.4 WorkspaceEditingDomainFactory.java >--- src/org/eclipse/emf/workspace/WorkspaceEditingDomainFactory.java 14 Nov 2007 18:14:08 -0000 1.4 >+++ src/org/eclipse/emf/workspace/WorkspaceEditingDomainFactory.java 1 Nov 2008 19:32:28 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligoft Inc., 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 >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - Bug 240775 > * > * </copyright> > * >@@ -25,9 +26,17 @@ > import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl; > > /** >- * Factory for creating transactional editing domains that delegate >- * command execution, undo, and redo to an {@link IOperationHistory}. >- * >+ * <p> >+ * Factory for creating transactional editing domains that delegate command >+ * execution, undo, and redo to an {@link IOperationHistory}. >+ * </p> >+ * <p> >+ * Since the 1.3 release, the determination of how {@link ResourceUndoContext}s >+ * are attached to undoable operations is >+ * {@linkplain #getResourceUndoContextPolicy() customizable} using the new >+ * {@link IResourceUndoContextPolicy} API. >+ * </p> >+ * > * @author Christian W. Damus (cdamus) > */ > public class WorkspaceEditingDomainFactory extends TransactionalEditingDomainImpl.FactoryImpl { >@@ -52,7 +61,7 @@ > * @return the new editing domain > */ > @Override >- public TransactionalEditingDomain createEditingDomain() { >+ public synchronized TransactionalEditingDomain createEditingDomain() { > return createEditingDomain(OperationHistoryFactory.getOperationHistory()); > } > >@@ -65,7 +74,7 @@ > * @return the new editing domain > */ > @Override >- public TransactionalEditingDomain createEditingDomain(ResourceSet rset) { >+ public synchronized TransactionalEditingDomain createEditingDomain(ResourceSet rset) { > return createEditingDomain( > rset, > OperationHistoryFactory.getOperationHistory()); >@@ -81,6 +90,7 @@ > */ > public TransactionalEditingDomain createEditingDomain(IOperationHistory history) { > WorkspaceCommandStackImpl stack = new WorkspaceCommandStackImpl(history); >+ stack.setResourceUndoContextPolicy(getResourceUndoContextPolicy()); > > TransactionalEditingDomain result = new TransactionalEditingDomainImpl( > new ComposedAdapterFactory( >@@ -103,6 +113,7 @@ > */ > public TransactionalEditingDomain createEditingDomain(ResourceSet rset, IOperationHistory history) { > WorkspaceCommandStackImpl stack = new WorkspaceCommandStackImpl(history); >+ stack.setResourceUndoContextPolicy(getResourceUndoContextPolicy()); > > TransactionalEditingDomain result = new TransactionalEditingDomainImpl( > new ComposedAdapterFactory( >@@ -114,4 +125,18 @@ > > return result; > } >+ >+ /** >+ * Obtains a resource undo-context policy to apply to the editing domain, to >+ * determine how to attach {@link ResourceUndoContext}s to operations in the >+ * associated history. May be overridden by clients to supply a non-default >+ * implementation. >+ * >+ * @return the resource undo-context policy >+ * >+ * @since 1.3 >+ */ >+ protected IResourceUndoContextPolicy getResourceUndoContextPolicy() { >+ return IResourceUndoContextPolicy.DEFAULT; >+ } > } >Index: src/org/eclipse/emf/workspace/impl/WorkspaceCommandStackImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.transaction/plugins/org.eclipse.emf.workspace/src/org/eclipse/emf/workspace/impl/WorkspaceCommandStackImpl.java,v >retrieving revision 1.15 >diff -u -r1.15 WorkspaceCommandStackImpl.java >--- src/org/eclipse/emf/workspace/impl/WorkspaceCommandStackImpl.java 4 Oct 2008 18:16:52 -0000 1.15 >+++ src/org/eclipse/emf/workspace/impl/WorkspaceCommandStackImpl.java 1 Nov 2008 19:32:28 -0000 >@@ -11,7 +11,7 @@ > * IBM - Initial API and implementation > * Fabrice Dubach - Bug 214325 Fix isSaveNeeded() logic > * IBM - Bug 24465 >- * Zeligsoft - Bug 244654 (Update for J2SE 5.0) >+ * Zeligsoft - Bugs 244654 (Update for J2SE 5.0), 240775 > * > * </copyright> > * >@@ -50,6 +50,7 @@ > import org.eclipse.emf.transaction.impl.TriggerCommandTransaction; > import org.eclipse.emf.transaction.util.TriggerCommand; > import org.eclipse.emf.workspace.EMFCommandOperation; >+import org.eclipse.emf.workspace.IResourceUndoContextPolicy; > import org.eclipse.emf.workspace.IWorkspaceCommandStack; > import org.eclipse.emf.workspace.ResourceUndoContext; > import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory; >@@ -75,7 +76,10 @@ > > private final IOperationHistory history; > private DomainListener domainListener; >- private Set<Resource> historyAffectedResources; >+ >+ private IResourceUndoContextPolicy undoContextPolicy = IResourceUndoContextPolicy.DEFAULT; >+ private IUndoableOperation currentOperation; >+ private Set<Resource> historyAffectedResources; > > private final IUndoContext defaultContext = new UndoContext() { > @Override >@@ -435,6 +439,29 @@ > historyAffectedResources = null; > mostRecentOperation = null; > } >+ >+ /** >+ * Obtains my resource undo-context policy. >+ * >+ * @return my resource undo-context policy >+ * >+ * @since 1.3 >+ */ >+ public IResourceUndoContextPolicy getResourceUndoContextPolicy() { >+ return undoContextPolicy; >+ } >+ >+ /** >+ * Sets my resource undo-context policy. >+ * >+ * @param policy >+ * my new policy, or <code>null</code> to restore the default >+ * >+ * @since 1.3 >+ */ >+ public void setResourceUndoContextPolicy(IResourceUndoContextPolicy policy) { >+ this.undoContextPolicy = policy; >+ } > > /** > * A listener on the editing domain and operation history that tracks >@@ -454,6 +481,7 @@ > case OperationHistoryEvent.ABOUT_TO_EXECUTE : > // set up to remember affected resources in case we make EMF > // changes >+ currentOperation = operation; > historyAffectedResources = new java.util.HashSet<Resource>(); > break; > case OperationHistoryEvent.DONE : >@@ -469,6 +497,7 @@ > } > } > >+ currentOperation = null; > historyAffectedResources = null; > > if (operation.hasContext(getDefaultUndoContext())) { >@@ -478,6 +507,7 @@ > case OperationHistoryEvent.OPERATION_NOT_OK : > // just forget about the context because this operation > // failed >+ currentOperation = null; > historyAffectedResources = null; > break; > case OperationHistoryEvent.UNDONE : >@@ -498,20 +528,8 @@ > public void resourceSetChanged(ResourceSetChangeEvent event) { > IUndoableOperation operation = null; > >- Transaction tx = event.getTransaction(); >- if (tx != null) { >- operation = (IUndoableOperation) tx.getOptions().get( >- EMFWorkspacePlugin.OPTION_OWNING_OPERATION); >- } >- >- Set<Resource> affectedResources = ResourceUndoContext.getAffectedResources( >- event.getNotifications()); >- > Set<Resource> unloaded = getUnloadedResources(event.getNotifications()); > if (unloaded != null) { >- // don't add these resources to the operation >- affectedResources.removeAll(unloaded); >- > // dispose their undo contexts > for (Resource next : unloaded) { > getOperationHistory().dispose( >@@ -519,25 +537,46 @@ > true, true, true); > } > } >+ >+ Transaction tx = event.getTransaction(); >+ if (tx != null) { >+ operation = (IUndoableOperation) tx.getOptions().get( >+ EMFWorkspacePlugin.OPTION_OWNING_OPERATION); >+ } > >- if ((operation != null) && !affectedResources.isEmpty()) { >- // add any resource undo contexts to this operation that are >- // not already applied >- for (Resource next : affectedResources) { >- ResourceUndoContext ctx = new ResourceUndoContext( >- getDomain(), next); >- >- if (!operation.hasContext(ctx)) { >- operation.addContext(ctx); >- } >- } >+ if (operation == null) { >+ operation = currentOperation; > } > >- if (historyAffectedResources != null) { >- // there is an operation executing on our history that is >- // affecting my editing domain. Remember the affected resources. >- historyAffectedResources.addAll(affectedResources); >- } >+ if (operation != null) { >+ Set<Resource> affectedResources = getResourceUndoContextPolicy() >+ .getContextResources(operation, event.getNotifications()); >+ >+ if (unloaded != null) { >+ // don't add these resources to the operation >+ affectedResources.removeAll(unloaded); >+ } >+ >+ if (!affectedResources.isEmpty()) { >+ // add any resource undo contexts to this operation that are >+ // not already applied >+ for (Resource next : affectedResources) { >+ ResourceUndoContext ctx = new ResourceUndoContext( >+ getDomain(), next); >+ >+ if (!operation.hasContext(ctx)) { >+ operation.addContext(ctx); >+ } >+ } >+ } >+ >+ if (historyAffectedResources != null) { >+ // there is an operation executing on our history that is >+ // affecting my editing domain. Remember the affected >+ // resources. >+ historyAffectedResources.addAll(affectedResources); >+ } >+ } > } > > /** >Index: src/org/eclipse/emf/workspace/AbstractResourceUndoContextPolicy.java >=================================================================== >RCS file: src/org/eclipse/emf/workspace/AbstractResourceUndoContextPolicy.java >diff -N src/org/eclipse/emf/workspace/AbstractResourceUndoContextPolicy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/workspace/AbstractResourceUndoContextPolicy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,226 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. 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: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.emf.workspace; >+ >+import java.util.Collection; >+import java.util.Collections; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.commands.operations.IUndoableOperation; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EReference; >+import org.eclipse.emf.ecore.resource.Resource; >+ >+/** >+ * <p> >+ * The default implementation of the resource undo-context policy, suitable for >+ * clients to extend/override as required. The default policy is to consider any >+ * resource as affected by an operation if either >+ * </p> >+ * <ol> >+ * <li>A non-touch {@link Notification} is received from a contained object or >+ * from the resource, itself, or</li> >+ * <li>A notification matching (1) is received from a uni-directional >+ * {@link EReference} (i.e., one having no opposite) has an old value or a new >+ * value in the resource >+ * </ol> >+ * <p> >+ * In the first case, above, a subclass can choose to include only changes to a >+ * resource's contents-list and URI as being significant (other resource >+ * properties not affecting the serialization of the resource). >+ * </p> >+ * <p> >+ * The second case, above, is intended for applications that use >+ * {@link ResourceUndoContext}s to manage the Undo menus of their editors. It is >+ * a pessimistic assumption that the referenced resource may either have derived >+ * attributes whose values influenced precursor or successor operations, or that >+ * such operations are influenced by the references incoming to the resource. >+ * Thus, the concern is not so much with the dirty state of the resource as it >+ * is with the integrity of the undo history for the associated editor and the >+ * dependencies between successive operations. Subclasses can disable this case >+ * by overriding the {@link #pessimisticCrossReferences()} method. >+ * </p> >+ * >+ * @author Christian W. Damus (cdamus) >+ * @since 1.3 >+ * >+ * @see #pessimisticCrossReferences() >+ * @see #considerAllResourceChanges() >+ */ >+public abstract class AbstractResourceUndoContextPolicy >+ implements IResourceUndoContextPolicy { >+ >+ /** >+ * Initializes me. >+ */ >+ protected AbstractResourceUndoContextPolicy() { >+ super(); >+ } >+ >+ public Set<Resource> getContextResources(IUndoableOperation operation, >+ List<? extends Notification> notifications) { >+ >+ Set<Resource> result; >+ >+ if (notifications.isEmpty()) { >+ result = Collections.emptySet(); >+ } else { >+ result = new java.util.HashSet<Resource>(); >+ >+ for (Notification next : notifications) { >+ if (next.isTouch()) { >+ continue; >+ } >+ >+ Object notifier = next.getNotifier(); >+ >+ if (notifier instanceof Resource) { >+ if (considerAllResourceChanges() >+ || (next.getFeatureID(Resource.class) == Resource.RESOURCE__CONTENTS) >+ || (next.getFeatureID(Resource.class) == Resource.RESOURCE__URI)) { >+ >+ result.add((Resource) notifier); >+ } >+ } else if (notifier instanceof EObject) { >+ EObject eobj = (EObject) notifier; >+ Resource resource = eobj.eResource(); >+ >+ if (resource != null) { >+ result.add(resource); >+ } >+ >+ if (pessimisticCrossReferences()) { >+ // if the reference has an opposite, then we will get >+ // the >+ // notification from the other end, anyway >+ final Object feature = next.getFeature(); >+ if ((feature instanceof EReference) >+ && (((EReference) feature).getEOpposite() == null)) { >+ handleCrossResourceReference(result, next); >+ } >+ } >+ } >+ } >+ } >+ >+ return result; >+ } >+ >+ /** >+ * May be overridden by subclasses to disable pessimistic handling of >+ * cross-resource references. The default implementation returns >+ * <code>true</code> always. >+ * >+ * @return whether to consider changes to directed cross-resource references >+ * as affecting the referenced resource >+ */ >+ protected boolean pessimisticCrossReferences() { >+ return true; >+ } >+ >+ /** >+ * May be overridden by subclasses to consider changes to any feature of a >+ * resource, not just its contents-list or URI, as affecting it. >+ * >+ * @return <code>true</code> if all changes to a resource are considered as >+ * affecting it for the purposes of undo context; <code>false</code> >+ * if only the contents-list and URI are >+ */ >+ protected boolean considerAllResourceChanges() { >+ return false; >+ } >+ >+ /** >+ * Handles notifications that can potentially represent cross-resource >+ * references. Helper to the >+ * {@link #getContextResources(IUndoableOperation, List)} method. >+ * >+ * @param resources >+ * collects the affected resources >+ * @param notification >+ * a potential cross-resource reference change notification >+ */ >+ protected void handleCrossResourceReference(Set<Resource> resources, >+ Notification notification) { >+ >+ Object oldValue = notification.getOldValue(); >+ Object newValue = notification.getNewValue(); >+ Resource resource; >+ >+ switch (notification.getEventType()) { >+ case Notification.SET : >+ case Notification.UNSET : >+ if (oldValue != null) { >+ resource = ((EObject) oldValue).eResource(); >+ >+ if (resource != null) { >+ resources.add(resource); >+ } >+ } >+ if (newValue != null) { >+ resource = ((EObject) newValue).eResource(); >+ >+ if (resource != null) { >+ resources.add(resource); >+ } >+ } >+ break; >+ case Notification.ADD : >+ resource = ((EObject) newValue).eResource(); >+ >+ if (resource != null) { >+ resources.add(resource); >+ } >+ break; >+ case Notification.ADD_MANY : { >+ @SuppressWarnings("unchecked") >+ Collection<EObject> newReferences = (Collection<EObject>) newValue; >+ for (EObject next : newReferences) { >+ resource = next.eResource(); >+ >+ if (resource != null) { >+ resources.add(resource); >+ } >+ } >+ break; >+ } >+ case Notification.REMOVE : >+ resource = ((EObject) oldValue).eResource(); >+ >+ if (resource != null) { >+ resources.add(resource); >+ } >+ break; >+ case Notification.REMOVE_MANY : { >+ @SuppressWarnings("unchecked") >+ Collection<EObject> oldReferences = (Collection<EObject>) oldValue; >+ for (EObject next : oldReferences) { >+ resource = next.eResource(); >+ >+ if (resource != null) { >+ resources.add(resource); >+ } >+ } >+ break; >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/emf/workspace/IResourceUndoContextPolicy.java >=================================================================== >RCS file: src/org/eclipse/emf/workspace/IResourceUndoContextPolicy.java >diff -N src/org/eclipse/emf/workspace/IResourceUndoContextPolicy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/workspace/IResourceUndoContextPolicy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. 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: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.emf.workspace; >+ >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.commands.operations.IUndoableOperation; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.ecore.resource.Resource; >+ >+/** >+ * <p> >+ * A rule determining the resources for which an {@link IUndoableOperation} >+ * should be tagged with {@link ResourceUndoContext}s. In general, these are the >+ * resources that >+ * </p> >+ * <ul> >+ * <li>are modified by the operation, such that they are become dirty, and/or</li> >+ * <li>whose editors should show the operation in their Undo menu</li> >+ * </ul> >+ * <p> >+ * Clients may implement this interface, but it is recommended to extend the >+ * {@link AbstractResourceUndoContextPolicy} class whenever possible. >+ * </p> >+ * >+ * @author Christian W. Damus (cdamus) >+ * @since 1.3 >+ * >+ * @see AbstractResourceUndoContextPolicy >+ */ >+public interface IResourceUndoContextPolicy { >+ >+ /** >+ * The default undo-context policy used by editing domains for which none is >+ * assigned by the client application. >+ */ >+ IResourceUndoContextPolicy DEFAULT = new AbstractResourceUndoContextPolicy() { >+ }; >+ >+ /** >+ * Determines the resources in the undo context of the specified >+ * <tt>operation</tt>, during which execution the changes indicated by the >+ * given <tt>notifications</tt> occurred. This operation may be called >+ * several times for the same operation, but always with different >+ * notifications. >+ * >+ * @param operation >+ * the operation. It may or may not have finished executing. Must >+ * not be <code>null</code> >+ * @param notifications >+ * a list of notifications of changes caused by the operation >+ * during its execution, in the order in which they occurred. >+ * This may be an empty list, but never <code>null</code> >+ * >+ * @return the resources that are the undo context of this operation, or an >+ * empty list if none. Never ruterns <code>null</code> >+ */ >+ Set<Resource> getContextResources(IUndoableOperation operation, >+ List<? extends Notification> notifications); >+}
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
Flags:
give.a.damus
:
review?
Actions:
View
|
Diff
Attachments on
bug 240775
: 116700