com.dlsc.flexgantt.command.layer

## Class AbstractDragAndDropCommand

- java.lang.Object
- - com.dlsc.flexgantt.command.AbstractCommand
  - - com.dlsc.flexgantt.command.layer.AbstractDragAndDropCommand

- All Implemented Interfaces:
    ICommand, Serializable
  Direct Known Subclasses:
    DefaultDragAndDropCommand, DefaultMultiDragAndDropCommand

      public abstract class AbstractDragAndDropCommand
      extends AbstractCommand

  A command that moves a given timeline object from one tree / hierarchy node to another. Additionally the timeline object's time span can be changed at the same time. This command can only be used in situations where the model is an instance of `DefaultGanttChartModel`, the old and the new tree node implement the `IGanttChartNode` interface, and the timeline object implements the `ITimelineObject` interface.
  Since:
    1.0
  Version:
    $Revision: 1.6 $
  Author:
    Dirk Lemmermann
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractDragAndDropCommand(IGanttChartNode owner, ILayer layer, DefaultGanttChartModel model, IGanttChartNode newOwner, DefaultGanttChartModel newModel, int dropAction)` Constructs a new command.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `fixRelationships(ITimelineObject object, IGanttChartNode oldOwner, IGanttChartNode newOwner, DefaultGanttChartModel oldModel, DefaultGanttChartModel newModel)` Fixes the relationship objects based on the information passed to it.
    `int` | `getDropAction()` Returns the user drop action that was used when the command was triggered.
    `ILayer` | `getLayer()` Returns the layer on which the timeline object gets displayed.
    `DefaultGanttChartModel` | `getNewModel()` Returns the new Gantt chart model in which the timeline object will be stored.
    `IGanttChartNode` | `getNewOwner()` Returns the new owner / tree node of the timeline object.
    `DefaultGanttChartModel` | `getOldModel()` Returns the old Gantt chart model in which the timeline object was stored.
    `IGanttChartNode` | `getOldOwner()` Returns the old owner / tree node of the timeline object.

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

    - ### Methods inherited from interface com.dlsc.flexgantt.command.ICommand

      `executeCommand, undoCommand`

- - ### Constructor Detail

    - #### AbstractDragAndDropCommand

          protected AbstractDragAndDropCommand(IGanttChartNode owner,
                                               ILayer layer,
                                               DefaultGanttChartModel model,
                                               IGanttChartNode newOwner,
                                               DefaultGanttChartModel newModel,
                                               int dropAction)

      Constructs a new command.
      Parameters:
        `owner` - the current owner / tree node on which to which the timeline object is assigned
        `layer` - the layer on which the timeline object gets currently displayed
        `model` - the model in which the owner and the timeline object are stored
        `newOwner` - the new owner / tree node to which the timeline object gets assigned
        `newModel` - the new model in which the timeline object gets stored
        `dropAction` - the type of drop performed (possible values are listed in `DnDConstants`)
      Since:
        1.0

  - ### Method Detail

    - #### fixRelationships

          protected void fixRelationships(ITimelineObject object,
                                          IGanttChartNode oldOwner,
                                          IGanttChartNode newOwner,
                                          DefaultGanttChartModel oldModel,
                                          DefaultGanttChartModel newModel)

      Fixes the relationship objects based on the information passed to it. When a timeline object gets assigned to a new tree node then the timeline object paths that are stored on the relationship objects become invalid. The paths need to be adjusted.
      Parameters:
        `object` - the timeline object that was dragged & dropped
        `oldOwner` - the old owner / tree node of the timeline object
        `newOwner` - the new owner / tree node of the timeline object
        `oldModel` - the old data model in which the timeline object was stored
        `newModel` - the new data model in which the timeline object is stored
      Since:
        1.0
      See Also:
        `IRelationship`, `IRelationship.getSourcePath()`, `IRelationship.getTargetPath()`, `IGanttChartModel.getRelationships()`, `TimelineObjectPath`

    - #### getLayer

          public ILayer getLayer()

      Returns the layer on which the timeline object gets displayed.
      Returns:
        the layer of the timeline object
      Since:
        1.0

    - #### getNewModel

          public DefaultGanttChartModel getNewModel()

      Returns the new Gantt chart model in which the timeline object will be stored.
      Returns:
        the timeline object's new Gantt chart model
      Since:
        1.0

    - #### getOldModel

          public DefaultGanttChartModel getOldModel()

      Returns the old Gantt chart model in which the timeline object was stored.
      Returns:
        the timeline object's old Gantt chart model
      Since:
        1.0

    - #### getNewOwner

          public IGanttChartNode getNewOwner()

      Returns the new owner / tree node of the timeline object.
      Returns:
        the timeline object's new owner
      Since:
        1.0

    - #### getOldOwner

          public IGanttChartNode getOldOwner()

      Returns the old owner / tree node of the timeline object.
      Returns:
        the timeline object's old owner
      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 timeline object. 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:
        `IDragAndDropPolicy.getDropActions(TimelineObjectPath, IGanttChartModel, Object, IGanttChartModel, long)`, `IDragAndDropPolicy.getDragAndDropCommand(TimelineObjectPath, IGanttChartModel, Object, IGanttChartModel, long, Object[], ILayer, int)`

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