org.eclipse.emf.workspace
Class ResourceUndoContext
java.lang.Object
org.eclipse.emf.workspace.ResourceUndoContext
-
All Implemented Interfaces:
-
IUndoContext
-
public final class ResourceUndoContext
- extends
Object
- implements
IUndoContext
An
IUndoContext
that tags an EMF operation with a resource affected by it.
Two resource contexts match if and only if they reference the same
Resource
instance. An operation may have any number of distinct resource contexts.
The determination of which resource is affected by any atomic EMF change is
obvious, except for the case of cross-resource reference changes. When a
cross-resource reference is added or removed, then both the referencing and
referenced resources are considered to be affected, even if the reference is
unidirectional. The assumption is that even without the back-reference, there
is an implicit dependency in that direction.
ResourceUndoContext
public ResourceUndoContext(
TransactionalEditingDomain domain,
Resource resource)
- Initializes me with the editing domain that owns a resource and the
resource that I represent.
-
Parameters:
-
domain
- the editing domain -
resource
- the resource that I represent
getLabel
public
String getLabel()
-
-
Specified by:
-
getLabel
in interface
IUndoContext
-
matches
public boolean matches(
IUndoContext context)
- I match another
context
if it is a
ResourceUndoContext
representing the same resource as I.
-
-
Specified by:
-
matches
in interface
IUndoContext
-
equals
public boolean equals(
Object o)
- I am equal to other
ResourceUndoContexts
on the same
resource as mine.
-
-
Overrides:
-
equals
in class
Object
-
hashCode
public int hashCode()
-
-
Overrides:
-
hashCode
in class
Object
-
getResource
public
Resource getResource()
- Obtains the resource that I represent.
-
-
-
Returns:
- my resource
getEditingDomain
public final
TransactionalEditingDomain getEditingDomain()
- Obtains the editing domain that manages my resource.
-
-
-
Returns:
- my editing domain
getAffectedResources
public static
Set<
Resource> getAffectedResources(
List<? extends
Notification> notifications)
-
Deprecated. Since the 1.3 release, use the
IResourceUndoContextPolicy.getContextResources(IUndoableOperation, List)
method of the editing domain's resource undo-context policy,
instead
- Analyzes a list of notifications to extract the set of
Resource
s
affected by the changes.
-
-
-
Parameters:
-
notifications
- a list of
Notification
s indicating changes in a
resource set
-
Returns:
- the resources affected by the specified notifications. The
resulting set should be treated as unmodifiable
getAffectedResources
public static
Set<
Resource> getAffectedResources(
IUndoableOperation operation)
- Extracts the set of EMF
Resource
s affected by the specified
operation, from the ResourceUndoContext
s attached to it.
-
-
-
Parameters:
-
operation
- an undoable operation
-
Returns:
- the
Resource
s that it affects, or an empty set if none.
The resulting set should be treated as unmodifiable
toString
public
String toString()
-
-
Overrides:
-
toString
in class
Object
-