public abstract class NodeTransfer extends Object
This is a dummy utility class--no instances are possible.
Modifier and Type | Class and Description |
---|---|
static interface |
NodeTransfer.Paste
An intelligent source of paste types (ways how to paste)
for a target node.
|
Modifier and Type | Field and Description |
---|---|
static int |
CLIPBOARD_COPY
Constant indicating copying to the clipboard.
|
static int |
CLIPBOARD_CUT
Constant indicating cutting to the clipboard.
|
static int |
COPY
Generic mask for copying nodes (do not destroy the original).
|
static int |
DND_COPY |
static int |
DND_COPY_OR_MOVE |
static int |
DND_LINK |
static int |
DND_MOVE |
static int |
DND_NONE
Constants for drag-n-drop operations.
|
static int |
DND_REFERENCE |
static int |
MOVE
Generic mask for moving nodes (destroy the original).
|
Modifier and Type | Method and Description |
---|---|
static <T extends Node.Cookie> |
cookie(Transferable t,
int action,
Class<T> cookie)
Obtain a cookie instance from the copied node in a transferable.
|
static ExTransferable.Single |
createPaste(NodeTransfer.Paste paste)
Creates transfer object that is used to carry an intelligent
paste source through transferable or clipboard.
|
static NodeTransfer.Paste |
findPaste(Transferable t)
Find an intelligent source of paste types in a transferable.
|
static Node |
node(Transferable t,
int action)
Obtain a node from a transferable.
|
static Node[] |
nodes(Transferable t,
int action)
Obtain a list of nodes from a transferable.
|
static ExTransferable.Single |
transferable(Node n,
int actions)
Creates transferable that represents a node operation, such as cut-to-clipboard.
|
public static final int DND_NONE
DnDConstants
.public static final int DND_COPY
public static final int DND_MOVE
public static final int DND_COPY_OR_MOVE
public static final int DND_LINK
public static final int DND_REFERENCE
public static final int CLIPBOARD_COPY
NodeTransfer.DND_COPY
, because
copy to clipboard and d'n'd copy should be the same.public static final int CLIPBOARD_CUT
public static final int COPY
NodeTransfer.CLIPBOARD_COPY
or NodeTransfer.DND_COPY
.public static final int MOVE
NodeTransfer.CLIPBOARD_CUT
or NodeTransfer.DND_MOVE
.public static ExTransferable.Single transferable(Node n, int actions)
NodeTransfer.node(java.awt.datatransfer.Transferable, int)
, NodeTransfer.nodes(java.awt.datatransfer.Transferable, int)
, and NodeTransfer.cookie(java.awt.datatransfer.Transferable, int, java.lang.Class<T>)
.n
- the node to create a transferable foractions
- the action performed on the nodepublic static Node node(Transferable t, int action)
t
- transferableaction
- one of the DND_*
or CLIPBOARD_*
constantsnull
public static Node[] nodes(Transferable t, int action)
NodeTransfer.node(java.awt.datatransfer.Transferable, int)
.
If there is a multiple transfer
(of at least one element),
each element of which
contains a node, then an array of these will be returned.
If neither of these things is true, null
will be returned.
This is a convenience method intended for those who wish to specially support pastes
of multiple nodes at once. (By default, an explorer will
fall back to presenting each component of a multiple-item transferable separately when checking for paste
types on a target node, so if you have only one paste type and it makes no difference whether all of the nodes
are pasted together or separately, you can just use NodeTransfer.node(java.awt.datatransfer.Transferable, int)
.)
If you wish to test for cookies, you should do so manually according to your specific logic.
t
- the transferable to probeaction
- a DnD or clipboard constantnull
public static <T extends Node.Cookie> T cookie(Transferable t, int action, Class<T> cookie)
First of all it checks whether the given transferable contains a node and then asks for the cookie.
If you wish to specially support multiple-node transfers, please use NodeTransfer.nodes(java.awt.datatransfer.Transferable, int)
and manually check for the desired combination of cookies.
t
- transferable to check incookie
- cookie representation class to look foraction
- the action which was used to store the nodenull
if it does not existpublic static ExTransferable.Single createPaste(NodeTransfer.Paste paste)
NodeTransfer.findPaste(java.awt.datatransfer.Transferable)
can retrieve it.paste
- the intelligent source of paste typespublic static NodeTransfer.Paste findPaste(Transferable t)
AbstractNode.createPasteTypes(java.awt.datatransfer.Transferable, java.util.List<org.openide.util.datatransfer.PasteType>)
looks for this
by default, so cut/copied nodes may specify how they may be pasted
to some external node target.t
- the transferable to testnull
if none is in the transferable