com.dlsc.flexgantt.command.treetable

## Class DefaultReassignNodesCommand

- java.lang.Object
- - com.dlsc.flexgantt.command.AbstractCommand
  - - com.dlsc.flexgantt.command.treetable.DefaultReassignNodesCommand

- All Implemented Interfaces:
    ICommand, Serializable

      public class DefaultReassignNodesCommand
      extends AbstractCommand

  The default command used to reassign nodes to a new parent node. This command can be used if the nodes are of type `MutableTreeNode` and the tree model is of type `DefaultTreeModel`.
  Since:
    1.1
  Version:
    $Revision: 1.8 $
  Author:
    Dirk Lemmermann
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultReassignNodesCommand(MutableTreeNode[] nodes, MutableTreeNode oldParent, int[] oldChildIndices, MutableTreeNode newParent, int[] newChildIndices, DefaultTreeModel model)` Constructs a new command.
    `DefaultReassignNodesCommand(String name, MutableTreeNode[] nodes, MutableTreeNode oldParent, int[] oldChildIndices, MutableTreeNode newParent, int[] newChildIndices, DefaultTreeModel model)` Constructs a new command.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `executeCommand(IProgressMonitor monitor)` Executes the command.
    `DefaultTreeModel` | `getModel()` Returns the model on which the command gets executed.
    `int[]` | `getNewChildIndices()` Returns the indices for the reassigned nodes within the list of the children of their new parent.
    `MutableTreeNode` | `getNewParent()` Returns the tree node, which will be the new parent of the reassigned nodes.
    `MutableTreeNode[]` | `getNodes()` Returns the reassigned tree nodes.
    `int[]` | `getOldChildIndices()` Returns the indices for the reassigned nodes within the list of the children of their old parent.
    `MutableTreeNode` | `getOldParent()` Returns the tree node, which is the current / old parent of the reassigned nodes.
    `void` | `undoCommand(IProgressMonitor monitor)` Undos the command.

    - ### Methods inherited from class com.dlsc.flexgantt.command.AbstractCommand

      `getName, isRedoable, isRelevant, isUndoable, redoCommand, setName`

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

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

- - ### Constructor Detail

    - #### DefaultReassignNodesCommand

          public DefaultReassignNodesCommand(String name,
                                             MutableTreeNode[] nodes,
                                             MutableTreeNode oldParent,
                                             int[] oldChildIndices,
                                             MutableTreeNode newParent,
                                             int[] newChildIndices,
                                             DefaultTreeModel model)

      Constructs a new command.
      Parameters:
        `name` - the name for the command (reassignment can be used in many different contexts, e.g. indentation)
        `nodes` - the nodes, which will be removed from the current (old) parent node and assigned to the new parent node
        `oldParent` - the old parent node
        `oldChildIndices` - the indices of the nodes when they still belonged to the old parent node
        `newParent` - the new parent node
        `newChildIndices` - the indices of the nodes once they belong to the new parent node
        `model` - the tree model in which the changes happen
      Since:
        1.1

    - #### DefaultReassignNodesCommand

          public DefaultReassignNodesCommand(MutableTreeNode[] nodes,
                                             MutableTreeNode oldParent,
                                             int[] oldChildIndices,
                                             MutableTreeNode newParent,
                                             int[] newChildIndices,
                                             DefaultTreeModel model)

      Constructs a new command.
      Parameters:
        `nodes` - the nodes, which will be removed from the current (old) parent node and assigned to the new parent node
        `oldParent` - the old parent node
        `oldChildIndices` - the indices of the nodes when they still belonged to the old parent node
        `newParent` - the new parent node
        `newChildIndices` - the indices of the nodes once they belong to the new parent node
        `model` - the tree model in which the changes happen
      Since:
        1.1

  - ### Method Detail

    - #### executeCommand

          public void executeCommand(IProgressMonitor monitor)
                              throws CommandException

      Description copied from interface: `ICommand`
      Executes the command.
      Parameters:
        `monitor` - a progress monitor
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong

    - #### undoCommand

          public void undoCommand(IProgressMonitor monitor)
                           throws CommandException

      Description copied from interface: `ICommand`
      Undos the command.
      Parameters:
        `monitor` - a progress monitor
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong

    - #### getModel

          public DefaultTreeModel getModel()

      Returns the model on which the command gets executed.
      Returns:
        the model, which will be modified by the command
      Since:
        1.1.3

    - #### getNewParent

          public MutableTreeNode getNewParent()

      Returns the tree node, which will be the new parent of the reassigned nodes.
      Returns:
        the new parent node
      Since:
        1.1.3

    - #### getOldParent

          public MutableTreeNode getOldParent()

      Returns the tree node, which is the current / old parent of the reassigned nodes.
      Returns:
        the old parent node
      Since:
        1.1.3

    - #### getNodes

          public MutableTreeNode[] getNodes()

      Returns the reassigned tree nodes.
      Returns:
        the reassigned tree nodes
      Since:
        1.1.3

    - #### getNewChildIndices

          public int[] getNewChildIndices()

      Returns the indices for the reassigned nodes within the list of the children of their new parent.
      Returns:
        the new child indices
      Since:
        1.1.3

    - #### getOldChildIndices

          public int[] getOldChildIndices()

      Returns the indices for the reassigned nodes within the list of the children of their old parent.
      Returns:
        the old child indices
      Since:
        1.1.3

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.