org.apache.jmeter.gui

## Class UndoHistory

- java.lang.Object
- - org.apache.jmeter.gui.UndoHistory

- All Implemented Interfaces:
    java.io.Serializable, java.util.EventListener, javax.swing.event.TreeModelListener

      public class UndoHistory
      extends java.lang.Object
      implements javax.swing.event.TreeModelListener, java.io.Serializable

  This class serves storing Test Tree state and navigating through it to give the undo/redo ability for test plan changes
  Since:
    2.12
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `UndoHistory.HistoryListener` Interface to be implemented by components interested in UndoHistory

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UndoHistory()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(JMeterTreeModel treeModel, java.lang.String comment)` Add tree model copy to the history This method relies on the rule that the record in history made AFTER change has been made to test plan
    `boolean` | `canRedo()`
    `boolean` | `canUndo()`
    `void` | `clear()` Clears the undo history
    `static boolean` | `isEnabled()`
    `void` | `redo()`
    `void` | `registerHistoryListener(UndoHistory.HistoryListener listener)` Register HistoryListener
    `void` | `treeNodesChanged(javax.swing.event.TreeModelEvent tme)` Record the changes in the node as the undo step
    `void` | `treeNodesInserted(javax.swing.event.TreeModelEvent tme)` Record adding nodes as the undo step
    `void` | `treeNodesRemoved(javax.swing.event.TreeModelEvent tme)` Record deleting nodes as the undo step
    `void` | `treeStructureChanged(javax.swing.event.TreeModelEvent tme)` Record some other change
    `void` | `undo()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UndoHistory

          public UndoHistory()

  - ### Method Detail

    - #### clear

          public void clear()

      Clears the undo history

    - #### add

          public void add(JMeterTreeModel treeModel,
                          java.lang.String comment)

      Add tree model copy to the history

      This method relies on the rule that the record in history made AFTER change has been made to test plan

      Parameters:
        `treeModel` - JMeterTreeModel
        `comment` - String

    - #### undo

          public void undo()

    - #### redo

          public void redo()

    - #### canRedo

          public boolean canRedo()

      Returns:
        true if remaining items

    - #### canUndo

          public boolean canUndo()

      Returns:
        true if not at first element

    - #### treeNodesChanged

          public void treeNodesChanged(javax.swing.event.TreeModelEvent tme)

      Record the changes in the node as the undo step
      Specified by:
        `treeNodesChanged` in interface `javax.swing.event.TreeModelListener`
      Parameters:
        `tme` - `TreeModelEvent` with event details

    - #### treeNodesInserted

          public void treeNodesInserted(javax.swing.event.TreeModelEvent tme)

      Record adding nodes as the undo step
      Specified by:
        `treeNodesInserted` in interface `javax.swing.event.TreeModelListener`
      Parameters:
        `tme` - `TreeModelEvent` with event details

    - #### treeNodesRemoved

          public void treeNodesRemoved(javax.swing.event.TreeModelEvent tme)

      Record deleting nodes as the undo step
      Specified by:
        `treeNodesRemoved` in interface `javax.swing.event.TreeModelListener`
      Parameters:
        `tme` - `TreeModelEvent` with event details

    - #### treeStructureChanged

          public void treeStructureChanged(javax.swing.event.TreeModelEvent tme)

      Record some other change
      Specified by:
        `treeStructureChanged` in interface `javax.swing.event.TreeModelListener`
      Parameters:
        `tme` - `TreeModelEvent` with event details

    - #### isEnabled

          public static boolean isEnabled()

      Returns:
        true if history is enabled

    - #### registerHistoryListener

          public void registerHistoryListener(UndoHistory.HistoryListener listener)

      Register HistoryListener
      Parameters:
        `listener` - to add to our listeners

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.