com.dlsc.flexgantt.policy.layer
Class DefaultDragAndDropPolicy

java.lang.Object
  extended by com.dlsc.flexgantt.policy.AbstractPolicy
      extended by com.dlsc.flexgantt.policy.layer.DefaultDragAndDropPolicy
All Implemented Interfaces:
IPolicy, IDragAndDropPolicy

public class DefaultDragAndDropPolicy
extends AbstractPolicy
implements IDragAndDropPolicy

The default implmementation of the drag & drop policy. For a general description of this policy please refer to the policy interface IDragAndDropPolicy.

Since:
1.0
Author:
Dirk Lemmermann

Constructor Summary
DefaultDragAndDropPolicy()
           
 
Method Summary
 int getDragActions(java.lang.Object node, java.lang.Object timelineObject, IGanttChartModel model)
          Determines how the given timeline object can be dragged (copy, move, copy or move, none).
 ICommand getDragAndDropCommand(java.lang.Object node, java.lang.Object droppedTimelineObject, IGanttChartModel model, java.lang.Object newNode, IGanttChartModel newModel, long newStartTime, java.lang.Object[] timelineObjects, ILayer layer, int dropAction)
          Returns a command object that will be used to make the necessary modifications to the models when the user dragged several timeline objects from one row to another at the same time.
 int getDropActions(java.lang.Object node, java.lang.Object timelineObject, IGanttChartModel model, java.lang.Object newNode, IGanttChartModel newModel, long newStartTime)
          Determines whether the new location as specified by the new tree node, new model and new time span can be used as a drop location for the given timeline object.
 
Methods inherited from class com.dlsc.flexgantt.policy.AbstractPolicy
assertClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDragAndDropPolicy

public DefaultDragAndDropPolicy()
Method Detail

getDragActions

public int getDragActions(java.lang.Object node,
                          java.lang.Object timelineObject,
                          IGanttChartModel model)
Description copied from interface: IDragAndDropPolicy
Determines how the given timeline object can be dragged (copy, move, copy or move, none). The possible values for the return value are defined as constants in the DnDConstants class.

Specified by:
getDragActions in interface IDragAndDropPolicy
Parameters:
node - the tree node that owns the timeline object
timelineObject - the timeline object that has to participate in a drag and drop operation
model - the data source of the tree node and the timeline object
Returns:
a drag and drop constant, which specifies what kind of drag and drop operations can be performed

getDropActions

public int getDropActions(java.lang.Object node,
                          java.lang.Object timelineObject,
                          IGanttChartModel model,
                          java.lang.Object newNode,
                          IGanttChartModel newModel,
                          long newStartTime)
Description copied from interface: IDragAndDropPolicy
Determines whether the new location as specified by the new tree node, new model and new time span can be used as a drop location for the given timeline object.

Specified by:
getDropActions in interface IDragAndDropPolicy
Parameters:
node - the tree node that owns the timeline object
timelineObject - the timeline object that has to participate in a drag and drop operation
model - the data source of the tree node and the timeline object
newNode - the tree node that will be the new owner of the timeline object
newModel - the data source of the new tree node owner
newStartTime - the time point that will be the new start time of the timeline object
Returns:
a drag and drop action, which specifies what kind of drop operation can be performed on the given node and time point (possible values are defined in DnDConstants

getDragAndDropCommand

public ICommand getDragAndDropCommand(java.lang.Object node,
                                      java.lang.Object droppedTimelineObject,
                                      IGanttChartModel model,
                                      java.lang.Object newNode,
                                      IGanttChartModel newModel,
                                      long newStartTime,
                                      java.lang.Object[] timelineObjects,
                                      ILayer layer,
                                      int dropAction)
Description copied from interface: IDragAndDropPolicy
Returns a command object that will be used to make the necessary modifications to the models when the user dragged several timeline objects from one row to another at the same time.

Specified by:
getDragAndDropCommand in interface IDragAndDropPolicy
Parameters:
node - the tree node that owns the timeline objects
droppedTimelineObject - the timeline object that was dragged and dropped
model - the data source of the tree node and the timeline objects
newNode - the tree node that will be the new owner of the timeline objects
newModel - the data source of the new tree node owner
newStartTime - the time point that will be the new start time of the timeline object
timelineObjects - the timeline objects that might have to participate in a drag and drop operation because they were selected at the same time
layer - the layer on which the drag and drop operation takes place
dropAction - an value used to distinguish between different types of drop operations (possible values listed in DnDConstants
Returns:
a command object that has to make the necessary model changes