Class NFEBlockUndoableEdit

  • All Implemented Interfaces:
    java.io.Serializable, java.util.EventListener, javax.swing.undo.UndoableEdit, NFEModelListener

    public class NFEBlockUndoableEdit
    extends javax.swing.undo.AbstractUndoableEdit
    implements NFEModelListener
    Undoable Edit implementation which contains multiple actions that should be executed altogether in a undo/redo operation. An instance of this class will contain one or more instances of NFEAttomicUndoableEdit. Once an undoable block is open, it will catch every model event fired at the same execution thread associated to the block and will assign an undoable edit to manage the undo/redo for that event.
    See Also:
    Serialized Form
    • Constructor Detail

      • NFEBlockUndoableEdit

        public NFEBlockUndoableEdit​(java.lang.String presentationName,
                                    NFEModel model)
        Allocates a new undoable block
        Parameters:
        presentationName - a user-friendly name that describes the actions performed in the block
        model - the current NFE model
    • Method Detail

      • openBlock

        public void openBlock()
        Sets the block ready to listen for new actions performed in the NFE model. Every NFE model event with a corresponding NFEAtomicUndoableEdit implementation will be managed by the current block. During this state, the block's undo/redo methods should not be called
      • isBlockEmpty

        public boolean isBlockEmpty()
        Tells whether the block is empty, that is, it does not contain actions
        Returns:
      • closeBlock

        public void closeBlock()
        Sets the block to stop listening events. Once this state is set, no actions will be added to the block and it is ready to perform undo/redo actions.
      • getThreadId

        public long getThreadId()
        Gets the id of the execution thread assigned to this block.
        Returns:
      • setThreadId

        public void setThreadId​(long threadId)
        Sets the id of the execution thread for the block. All the NFE model events fired from the execution thread with the given id, will be cached by the block.
        Parameters:
        threadId - an execution thread's id
      • isOpen

        public boolean isOpen()
        Tells whether the block is listening to events
        Returns:
        true if the model is listening to events
      • modelObjectsAdded

        public void modelObjectsAdded​(NFEModelObjectsEvent event)
        Description copied from interface: NFEModelListener
        Invoked when one or more model objects have been added
        Specified by:
        modelObjectsAdded in interface NFEModelListener
        Parameters:
        event - contains a collection of references to the model objects that have been added
      • modelObjectsRemoved

        public void modelObjectsRemoved​(NFEModelObjectsEvent event)
        Description copied from interface: NFEModelListener
        Invoked when one or more model objects have been removed
        Specified by:
        modelObjectsRemoved in interface NFEModelListener
        Parameters:
        event - contains a collection of references to the model objects that have been removed
      • getPresentationName

        public java.lang.String getPresentationName()
        Specified by:
        getPresentationName in interface javax.swing.undo.UndoableEdit
        Overrides:
        getPresentationName in class javax.swing.undo.AbstractUndoableEdit
      • undo

        public void undo()
                  throws javax.swing.undo.CannotUndoException
        Specified by:
        undo in interface javax.swing.undo.UndoableEdit
        Overrides:
        undo in class javax.swing.undo.AbstractUndoableEdit
        Throws:
        javax.swing.undo.CannotUndoException
      • redo

        public void redo()
                  throws javax.swing.undo.CannotRedoException
        Specified by:
        redo in interface javax.swing.undo.UndoableEdit
        Overrides:
        redo in class javax.swing.undo.AbstractUndoableEdit
        Throws:
        javax.swing.undo.CannotRedoException