com.dlsc.flexgantt.command.treetable

## Class DefaultNodeDragAndDropCommand

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

- All Implemented Interfaces:
    ICommand, Serializable

      public class DefaultNodeDragAndDropCommand
      extends AbstractCommand

  A command that performs the necessary changes after a drag and drop event within the tree table. The command will reassign the dragged node to a new parent node after removing it from the current parent node. This command will only work in situations where the source and the target tree table model are instances of `DefaultTreeTableModel` and the old parent node, the new parent node, and the dragged node are all implementors of the `IMutableTreeTableNode` interface.
  Since:
    1.0
  Version:
    $Revision: 1.6 $
  Author:
    Dirk Lemmermann
  See Also:
    `INodeDragAndDropPolicy.getDragAndDropCommand(Object, Object, com.dlsc.flexgantt.model.treetable.ITreeTableModel, int, Object, com.dlsc.flexgantt.model.treetable.ITreeTableModel, int, int)`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultNodeDragAndDropCommand(IMutableTreeTableNode draggedNode, IMutableTreeTableNode oldParentNode, DefaultTreeTableModel oldModel, int oldChildIndex, IMutableTreeTableNode newParentNode, DefaultTreeTableModel newModel, int newChildIndex, int dropAction)` 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.
    `IMutableTreeTableNode` | `getDraggedNode()` Returns the dragged node.
    `int` | `getDropAction()` Returns the user drop action that was used when the command was triggered.
    `int` | `getNewChildIndex()` Returns the index of the dragged node within the list of children of the new parent node.
    `DefaultTreeTableModel` | `getNewModel()` Returns the model to which the dragged node belongs after the command gets executed.
    `IMutableTreeTableNode` | `getNewParent()` Returns the parent node to which the dragged node was / will be assigned by the command.
    `int` | `getOldChildIndex()` Returns the index of the dragged node within the list of children of the old parent node.
    `DefaultTreeTableModel` | `getOldModel()` Returns the model to which the dragged node belongs before the command gets executed.
    `IMutableTreeTableNode` | `getOldParent()` Returns the old parent node to which the dragged node belonged before the command was executed.
    `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

    - #### DefaultNodeDragAndDropCommand

          public DefaultNodeDragAndDropCommand(IMutableTreeTableNode draggedNode,
                                               IMutableTreeTableNode oldParentNode,
                                               DefaultTreeTableModel oldModel,
                                               int oldChildIndex,
                                               IMutableTreeTableNode newParentNode,
                                               DefaultTreeTableModel newModel,
                                               int newChildIndex,
                                               int dropAction)

      Constructs a new command.
      Parameters:
        `draggedNode` - the tree table node that gets dragged and dropped
        `oldParentNode` - the old parent node of the dragged node
        `oldModel` - the old model to which the old parent and the dragged node belong
        `oldChildIndex` - the old index of the dragged node within the list of children of the old parent node
        `newParentNode` - the new parent node to which the dragged node will be assigned
        `newModel` - the new model to which the new parent and the dragged node will belong
        `newChildIndex` - the new index of the dragged node within the list of children of the new parent node
        `dropAction` - the type of drop performed (possible values are listed in `DnDConstants`)
      Since:
        1.0

  - ### 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

    - #### getDraggedNode

          public IMutableTreeTableNode getDraggedNode()

      Returns the dragged node.
      Returns:
        the dragged node
      Since:
        1.0

    - #### getNewParent

          public IMutableTreeTableNode getNewParent()

      Returns the parent node to which the dragged node was / will be assigned by the command.
      Returns:
        the new parent node
      Since:
        1.0

    - #### getOldParent

          public IMutableTreeTableNode getOldParent()

      Returns the old parent node to which the dragged node belonged before the command was executed.
      Returns:
        the old parent node
      Since:
        1.0

    - #### getNewChildIndex

          public int getNewChildIndex()

      Returns the index of the dragged node within the list of children of the new parent node.
      Returns:
        the new child index
      Since:
        1.0

    - #### getOldChildIndex

          public int getOldChildIndex()

      Returns the index of the dragged node within the list of children of the old parent node.
      Returns:
        the old child index
      Since:
        1.0

    - #### getOldModel

          public DefaultTreeTableModel getOldModel()

      Returns the model to which the dragged node belongs before the command gets executed.
      Returns:
        the old tree table model
      Since:
        1.0

    - #### getNewModel

          public DefaultTreeTableModel getNewModel()

      Returns the model to which the dragged node belongs after the command gets executed.
      Returns:
        the new tree table model
      Since:
        1.0

    - #### getDropAction

          public int getDropAction()

      Returns the user drop action that was used when the command was triggered. The drop action can be used to determine whether the user intends to perform a move or a copy of the dragged tree node. The drop action value is based on the values defined in `DnDConstants`.
      Returns:
        the drop action (`DnDConstants.ACTION_MOVE` or `DnDConstants.ACTION_COPY`).
      Since:
        1.0
      See Also:
        `INodeDragAndDropPolicy.getDropActions(Object, Object, com.dlsc.flexgantt.model.treetable.ITreeTableModel, Object, com.dlsc.flexgantt.model.treetable.ITreeTableModel)`, `INodeDragAndDropPolicy.getDragAndDropCommand(Object, Object, com.dlsc.flexgantt.model.treetable.ITreeTableModel, int, Object, com.dlsc.flexgantt.model.treetable.ITreeTableModel, int, int)`

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