public class NodeDropInputMode extends ItemDropInputMode<INode>
ItemDropInputMode specialized to drag'n'drop INodes.
A dragged INode is visualized during the drag operation. The input mode does also support snapping of the
dragged INode via the SnapContext. When the dragged node is
dropped, This mode can can drag nodes onto group and optional folder nodes
and automatically add the node to the corresponding group node in the hierarchy. In this case the IsValidParentPredicate
will be queried if the dropped upon node is actually a valid parent.
DATA_FORMAT_DROP_ID| Modifier | Constructor and Description |
|---|---|
|
NodeDropInputMode()
Constructs a new instance of class
NodeDropInputMode for the type INode. |
protected |
NodeDropInputMode(Class expectedType)
Constructs a new instance of class
DropInputMode for the expected data type. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
collectSnapResults(Object source,
CollectSnapResultsEventArgs args)
Callback registered on the
SnapContext that collects
SnapResults for the dragged element. |
protected INode |
createNode(IInputModeContext context,
IGraph graph,
INode node,
IModelItem dropTarget,
RectD layout)
Creates the node in the graph after it's been dropped.
|
protected IModelItem |
getDropTarget(PointD dragLocation)
Returns the drop target at the specified location.
|
Predicate<INode> |
getIsGroupNodePredicate()
Gets the callback for testing whether a
dragged node should be created as a
group node. |
Predicate<INode> |
getIsValidParentPredicate()
Gets the callback for testing whether an existing node in the graph can be used as a valid parent node in the context of
grouping.
|
protected RectD |
getNodeLayout(PointD mouseLocation,
SizeD size)
Calculates the layout of the new node.
|
protected void |
initializePreview()
Initializes the item preview.
|
boolean |
isFolderNodeAsParentAllowed()
Gets a value indicating whether nodes can be dropped on
collapsed folder nodes. |
boolean |
isNonGroupNodeAsParentAllowed()
Gets a value indicating whether nodes can be dropped onto nodes that are no
group nodes. |
protected void |
populatePreviewGraph(IGraph previewGraph)
Subclasses shall fill the specified graph that is used to preview the dragged item.
|
void |
setFolderNodeAsParentAllowed(boolean value)
Sets a value indicating whether nodes can be dropped on
collapsed folder nodes. |
void |
setIsGroupNodePredicate(Predicate<INode> value)
Sets the callback for testing whether a
dragged node should be created as a
group node. |
void |
setIsValidParentPredicate(Predicate<INode> value)
Sets the callback for testing whether an existing node in the graph can be used as a valid parent node in the context of
grouping.
|
void |
setNonGroupNodeAsParentAllowed(boolean value)
Sets a value indicating whether nodes can be dropped onto nodes that are no
group nodes. |
protected void |
updatePreview(IGraph previewGraph,
PointD dragLocation)
Subclasses shall update the
preview graph so the dragged item is displayed at the specified
dragLocation. |
addItemCreatedListener, cleanup, cleanupDropTarget, cleanupPreview, cleanupSnapContext, getDraggedItem, getDropTarget, getItemCreator, getPreviewGraph, getSnapContext, getSnappedMousePosition, initializeDropTarget, initializeSnapContext, isDropTargetHighlightEnabled, isPreviewEnabled, isSnappingEnabled, onConcurrencyControllerDeactivated, onDragDropped, onDragEntered, onDragExited, onDraggedOver, onItemCreated, removeItemCreatedListener, setDragLocation, setDropTarget, setDropTargetHighlightEnabled, setItemCreator, setPreviewEnabled, setSnapContext, setSnappingEnabled, updateDropTargetaddDragDroppedListener, addDragEnteredListener, addDragLeftListener, addDragOverListener, adjustTransferMode, cancel, createInputModeEventArgs, getController, getDropData, getDropData, getDropDataMap, getDropLocation, getExpectedType, getInputModeContext, getLastDragEvent, getMousePosition, getPriority, getTransferMode, getValidDropHitTestable, install, isCapturingMouseInputDuringDragEnabled, isEnabled, isExclusive, onCanceled, onConcurrencyControllerActivated, onStopped, removeDragDroppedListener, removeDragEnteredListener, removeDragLeftListener, removeDragOverListener, setCapturingMouseInputDuringDragEnabled, setDropDataMap, setEnabled, setExclusive, setPriority, setTransferMode, setValidDropHitTestable, stop, uninstallpublic NodeDropInputMode()
NodeDropInputMode for the type INode.protected NodeDropInputMode(Class expectedType)
DropInputMode for the expected data type. Not
used in this class since data type is always INode. This constructor only exists for usage in child class.protected void collectSnapResults(Object source, CollectSnapResultsEventArgs args)
ItemDropInputModeSnapContext that collects
SnapResults for the dragged element.
The default implementation doesn't collect any snap results.
collectSnapResults in class ItemDropInputMode<INode>source - The SnapContext this callback is registered at.args - The arguments describing the movement SnapResults shall be collected for.protected INode createNode(IInputModeContext context, IGraph graph, INode node, IModelItem dropTarget, RectD layout)
This method is called by the ItemCreator that is set as default on this
class.
context - The context for which the node should be created.graph - The Graph in which to create the item.node - The node that was dragged and should therefore be created.dropTarget - The IModelItem on which the node is dropped.layout - The bounds of the new node.protected IModelItem getDropTarget(PointD dragLocation)
ItemDropInputMode
The drop target is highlighted, if DropTargetHighlightEnabled is enabled. Per
default, null is returned.
getDropTarget in class ItemDropInputMode<INode>dragLocation - The location to return the drop target for.null if no drop target can be found.public final Predicate<INode> getIsGroupNodePredicate()
dragged node should be created as a
group node.
The default implementation returns false always. Can be set to a different value to implement custom group node
detection.
setIsGroupNodePredicate(Predicate)public final Predicate<INode> getIsValidParentPredicate()
The default implementation returns true always. Can be set to a different value to implement custom group node
detection. Note that the node passed to the predicate may be null to indicate that the node will be placed at
the root of the hierarchy.
isNonGroupNodeAsParentAllowed(),
isFolderNodeAsParentAllowed(),
setIsValidParentPredicate(Predicate)protected RectD getNodeLayout(PointD mouseLocation, SizeD size)
In this implementation the mouse location is used as center of the node. Can be overridden in child class to implement a different layout.
mouseLocation - Current mouse positionsize - Size of the nodeRectD with the given size and the mouse location as center.protected void initializePreview()
ItemDropInputMode
This method is called by ItemDropInputMode.onDragEntered(InputModeEventArgs). If a preview
shall be displayed, the preview graph is initialized and ItemDropInputMode.populatePreviewGraph(IGraph)
is called.
initializePreview in class ItemDropInputMode<INode>public final boolean isFolderNodeAsParentAllowed()
collapsed folder nodes.
If this property is set to true, dropping nodes on collapsed folder nodes will create the node inside the folder
node in the master graph. In that case the ItemCreated
event will yield the node in the master graph. The node
will not be contained in the currently visible graph. By default this feature is
disabled. In any case the IsValidParentPredicate will be queried additionally if
the node is a valid parent.
true if folder node parents are allowed; false otherwise.setFolderNodeAsParentAllowed(boolean)public final boolean isNonGroupNodeAsParentAllowed()
group nodes.
If this property is enabled, dropping a node on a non-group node will effectively convert the non-group node to a real
group node. By default this feature is disabled. In any case the IsValidParentPredicate
will be queried additionally if the node is a valid parent.
true if non-group node parents are allowed as valid drop targets; false otherwise.setNonGroupNodeAsParentAllowed(boolean)protected void populatePreviewGraph(IGraph previewGraph)
ItemDropInputModepopulatePreviewGraph in class ItemDropInputMode<INode>previewGraph - The preview graph to fill.public final void setFolderNodeAsParentAllowed(boolean value)
collapsed folder nodes.
If this property is set to true, dropping nodes on collapsed folder nodes will create the node inside the folder
node in the master graph. In that case the ItemCreated
event will yield the node in the master graph. The node
will not be contained in the currently visible graph. By default this feature is
disabled. In any case the IsValidParentPredicate will be queried additionally if
the node is a valid parent.
value - true if folder node parents are allowed; false otherwise.isFolderNodeAsParentAllowed()public final void setIsGroupNodePredicate(Predicate<INode> value)
dragged node should be created as a
group node.
The default implementation returns false always. Can be set to a different value to implement custom group node
detection.
value - The IsGroupNodePredicate to set.getIsGroupNodePredicate()public final void setIsValidParentPredicate(Predicate<INode> value)
The default implementation returns true always. Can be set to a different value to implement custom group node
detection. Note that the node passed to the predicate may be null to indicate that the node will be placed at
the root of the hierarchy.
value - The IsValidParentPredicate to set.isNonGroupNodeAsParentAllowed(),
isFolderNodeAsParentAllowed(),
getIsValidParentPredicate()public final void setNonGroupNodeAsParentAllowed(boolean value)
group nodes.
If this property is enabled, dropping a node on a non-group node will effectively convert the non-group node to a real
group node. By default this feature is disabled. In any case the IsValidParentPredicate
will be queried additionally if the node is a valid parent.
value - true if non-group node parents are allowed as valid drop targets; false otherwise.isNonGroupNodeAsParentAllowed()protected void updatePreview(IGraph previewGraph, PointD dragLocation)
ItemDropInputModepreview graph so the dragged item is displayed at the specified
dragLocation.updatePreview in class ItemDropInputMode<INode>previewGraph - The preview graph to update.dragLocation - The current drag location.