Class ObjectUndoContext
java.lang.Object
org.eclipse.core.commands.operations.UndoContext
org.eclipse.core.commands.operations.ObjectUndoContext
- All Implemented Interfaces:
IUndoContext
An undo context that can be used to represent any given object. Clients can add matching contexts to this context. This class may be instantiated by clients.
- Since:
- 3.1
-
Constructor Summary
ConstructorDescriptionObjectUndoContext
(Object object) Construct an operation context that represents the given object.ObjectUndoContext
(Object object, String label) Construct an operation context that represents the given object and has a specialized label. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMatch
(IUndoContext context) Add the specified context as a match of this context.getLabel()
Get the label that describes the undo context.Return the object that is represented by this context.boolean
matches
(IUndoContext context) Return whether the specified context is considered a match for the receiving context.void
removeMatch
(IUndoContext context) Remove the specified context as a match of this context.toString()
The string representation of this operation.
-
Constructor Details
-
ObjectUndoContext
Construct an operation context that represents the given object.- Parameters:
object
- the object to be represented.
-
ObjectUndoContext
Construct an operation context that represents the given object and has a specialized label.- Parameters:
object
- the object to be represented.label
- the label for the context
-
-
Method Details
-
getLabel
Description copied from class:UndoContext
Get the label that describes the undo context. The default implementation returns the empty String. Subclasses may override.
- Specified by:
getLabel
in interfaceIUndoContext
- Overrides:
getLabel
in classUndoContext
- Returns:
- the label for the context.
-
getObject
Return the object that is represented by this context.- Returns:
- the object represented by this context.
-
addMatch
Add the specified context as a match of this context. Contexts added as matches of this context will be interpreted as a match of this context when the history is filtered for a particular context. Adding a match allows components to create their own contexts for implementing specialized behavior, yet have their operations appear in a more global context.- Parameters:
context
- the context to be added as a match of this context
-
removeMatch
Remove the specified context as a match of this context. The context will no longer be interpreted as a match of this context when the history is filtered for a particular context. This method has no effect if the specified context was never previously added as a match.- Parameters:
context
- the context to be removed from the list of matches for this context
-
matches
Description copied from class:UndoContext
Return whether the specified context is considered a match for the receiving context. When a context matches another context, operations that have the context are considered to also have the matching context. The default implementation checks whether the supplied context is identical to this context. Subclasses may override.
- Specified by:
matches
in interfaceIUndoContext
- Overrides:
matches
in classUndoContext
- Parameters:
context
- the context to be checked against the receiving context.- Returns:
true
if the receiving context can be considered a match for the specified context, andfalse
if it cannot.
-
toString
The string representation of this operation. Used for debugging purposes only. This string should not be shown to an end user.
-