Class 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 Detail

      • ObjectUndoContext

        public ObjectUndoContext​(Object object)
        Construct an operation context that represents the given object.
        Parameters:
        object - the object to be represented.
      • ObjectUndoContext

        public ObjectUndoContext​(Object object,
                                 String label)
        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 Detail

      • getLabel

        public String 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 interface IUndoContext
        Overrides:
        getLabel in class UndoContext
        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: 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 interface IUndoContext
        Overrides:
        matches in class UndoContext
        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, and false if it cannot.
      • toString

        public String toString()
        The string representation of this operation. Used for debugging purposes only. This string should not be shown to an end user.
        Overrides:
        toString in class Object
        Returns:
        The string representation.