org.eclipse.emf.workspace
Class AbstractResourceUndoContextPolicy
java.lang.Object
org.eclipse.emf.workspace.AbstractResourceUndoContextPolicy
-
All Implemented Interfaces:
-
IResourceUndoContextPolicy
-
public abstract class AbstractResourceUndoContextPolicy
- extends
Object
- implements
IResourceUndoContextPolicy
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
- A non-touch
Notification
is received from a contained object or
from the resource, itself, or
- A notification matching (1) is received from a uni-directional
EReference
(i.e., one having no opposite) has an old value or a new
value in the resource
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).
The second case, above, is intended for applications that use
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
pessimisticCrossReferences()
method.
-
Since:
- 1.3
-
See Also:
-
pessimisticCrossReferences()
,
considerAllResourceChanges()
Method Summary
|
protected boolean
|
considerAllResourceChanges
()
May be overridden by subclasses to consider changes to any feature of a
resource, not just its contents-list or URI, as affecting it. |
protected void
|
crossResourceReference
(
Set<
Resource> resources,
EObject owner,
Notification notification)
Handles notifications that can potentially represent cross-resource
references. |
Set<
Resource>
|
getContextResources
(
IUndoableOperation operation,
List<? extends
Notification> notifications)
Determines the resources in the undo context of the specified
operation, during which execution the changes indicated by the
given notifications occurred. |
protected boolean
|
isAbstractChange
(
Notification notification)
Queries whether the specified notification signals an abstract
change to a resource, which would potentially put that resource into the
operation context. |
protected void
|
objectChange
(
Set<
Resource> resources,
EObject object,
Notification notification)
Adds to the collection of resources any that are affected by the
specified notification from an object. |
protected boolean
|
pessimisticCrossReferences
()
May be overridden by subclasses to disable pessimistic handling of
cross-resource references. |
protected void
|
resourceChange
(
Set<
Resource> resources,
Resource resource,
Notification notification)
Adds to the collection of resources any that are affected by the
specified notification from a resource. |
protected void
|
resourceSetChange
(
Set<
Resource> resources,
ResourceSet resourceSet,
Notification notification)
Adds to the collection of resources any that are affected by the
specified notification from a resourceSet. |
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
AbstractResourceUndoContextPolicy
protected AbstractResourceUndoContextPolicy()
- Initializes me.
getContextResources
public
Set<
Resource> getContextResources(
IUndoableOperation operation,
List<? extends
Notification> notifications)
-
Description copied from interface:
IResourceUndoContextPolicy
- Determines the resources in the undo context of the specified
operation, during which execution the changes indicated by the
given notifications occurred. This operation may be called
several times for the same operation, but always with different
notifications.
-
-
Specified by:
-
getContextResources
in interface
IResourceUndoContextPolicy
-
-
Parameters:
-
operation
- the operation. It may or may not have finished executing. Must
not be null
-
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 null
-
Returns:
- the resources that are the undo context of this operation, or an
empty list if none. Never ruterns
null
isAbstractChange
protected boolean isAbstractChange(
Notification notification)
- Queries whether the specified notification signals an abstract
change to a resource, which would potentially put that resource into the
operation context. Subclasses may override or extend as needed.
-
-
-
Parameters:
-
notification
- a notification of some concrete change in the resource set
-
Returns:
- whether this change is an abstract change to some resource, for
the purpose of tracking undo context
pessimisticCrossReferences
protected boolean pessimisticCrossReferences()
- May be overridden by subclasses to disable pessimistic handling of
cross-resource references. The default implementation returns
true
always.
-
-
-
Returns:
- whether to consider changes to directed cross-resource references
as affecting the referenced resource
considerAllResourceChanges
protected boolean considerAllResourceChanges()
- May be overridden by subclasses to consider changes to any feature of a
resource, not just its contents-list or URI, as affecting it.
-
-
-
Returns:
-
true
if all changes to a resource are considered as
affecting it for the purposes of undo context; false
if only the contents-list and URI are
resourceChange
protected void resourceChange(
Set<
Resource> resources,
Resource resource,
Notification notification)
- Adds to the collection of resources any that are affected by the
specified notification from a resource.
-
-
-
Parameters:
-
resources
- collects the affected resources -
resource
- a resource that sent a notification -
notification
- the notification sent by the resource
objectChange
protected void objectChange(
Set<
Resource> resources,
EObject object,
Notification notification)
- Adds to the collection of resources any that are affected by the
specified notification from an object.
-
-
-
Parameters:
-
resources
- collects the affected resources -
object
- a object that sent a notification -
notification
- the notification sent by the object
resourceSetChange
protected void resourceSetChange(
Set<
Resource> resources,
ResourceSet resourceSet,
Notification notification)
- Adds to the collection of resources any that are affected by the
specified notification from a resourceSet.
-
-
-
Parameters:
-
resources
- collects the affected resources -
resourceSet
- a resource set that sent a notification -
notification
- the notification sent by the resource set
crossResourceReference
protected void crossResourceReference(
Set<
Resource> resources,
EObject owner,
Notification notification)
- Handles notifications that can potentially represent cross-resource
references. Helper to the
objectChange(Set, EObject, Notification)
method.
-
-
-
Parameters:
-
resources
- collects the affected resources -
owner
- the owner of the reference that changed -
notification
- a potential cross-resource reference change notification