Class ObjectUndoContext
- java.lang.Object
-
- org.eclipse.core.commands.operations.UndoContext
-
- org.eclipse.core.commands.operations.ObjectUndoContext
-
- All Implemented Interfaces:
IUndoContext
public final class ObjectUndoContext extends UndoContext
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
Constructors Constructor Description ObjectUndoContext(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMatch(IUndoContext context)Add the specified context as a match of this context.StringgetLabel()Get the label that describes the undo context.ObjectgetObject()Return the object that is represented by this context.booleanmatches(IUndoContext context)Return whether the specified context is considered a match for the receiving context.voidremoveMatch(IUndoContext context)Remove the specified context as a match of this context.StringtoString()The string representation of this operation.
-
-
-
Constructor Detail
-
ObjectUndoContext
public ObjectUndoContext(Object object)
Construct an operation context that represents the given object.- Parameters:
object- the object to be represented.
-
-
Method Detail
-
getLabel
public String getLabel()
Description copied from class:UndoContextGet the label that describes the undo context. The default implementation returns the empty String. Subclasses may override.
- Specified by:
getLabelin interfaceIUndoContext- Overrides:
getLabelin classUndoContext- Returns:
- the label for the context.
-
getObject
public Object getObject()
Return the object that is represented by this context.- Returns:
- the object represented by this context.
-
addMatch
public void addMatch(IUndoContext context)
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
public void removeMatch(IUndoContext context)
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
public boolean matches(IUndoContext context)
Description copied from class:UndoContextReturn 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:
matchesin interfaceIUndoContext- Overrides:
matchesin classUndoContext- Parameters:
context- the context to be checked against the receiving context.- Returns:
trueif the receiving context can be considered a match for the specified context, andfalseif it cannot.
-
-