站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

NodeTransfer (NetBeans Nodes API) - NetBeans API Javadoc 5.0.0

 

org.openide.nodes
Class NodeTransfer

java.lang.Object
  extended byorg.openide.nodes.NodeTransfer

public abstract class NodeTransfer
extends Object

Class that contains specific datatransfer flavors and methods to work with nodes. There are flavors to allow a node to be copied or cut, and to decide its paste types.

This is a dummy utility class--no instances are possible.


Nested Class Summary
static interface NodeTransfer.Paste
          An intelligent source of paste types (ways how to paste) for a target node.
 
Field Summary
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).
 
Method Summary
static Node.Cookie cookie(Transferable t, int action, Class 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DND_NONE

public static final int DND_NONE
Constants for drag-n-drop operations. Are exactly the same as constants in DnDConstants.

See Also:
Constant Field Values

DND_COPY

public static final int DND_COPY
See Also:
Constant Field Values

DND_MOVE

public static final int DND_MOVE
See Also:
Constant Field Values

DND_COPY_OR_MOVE

public static final int DND_COPY_OR_MOVE
See Also:
Constant Field Values

DND_LINK

public static final int DND_LINK
See Also:
Constant Field Values

DND_REFERENCE

public static final int DND_REFERENCE
See Also:
Constant Field Values

CLIPBOARD_COPY

public static final int CLIPBOARD_COPY
Constant indicating copying to the clipboard. Equal to DND_COPY, because copy to clipboard and d'n'd copy should be the same.

See Also:
Constant Field Values

CLIPBOARD_CUT

public static final int CLIPBOARD_CUT
Constant indicating cutting to the clipboard.

See Also:
Constant Field Values

COPY

public static final int COPY
Generic mask for copying nodes (do not destroy the original). Equal to CLIPBOARD_COPY or DND_COPY.

See Also:
Constant Field Values

MOVE

public static final int MOVE
Generic mask for moving nodes (destroy the original). Equal to CLIPBOARD_CUT or DND_MOVE.

See Also:
Constant Field Values
Method Detail

transferable

public static ExTransferable.Single transferable(Node n,
                                                 int actions)
Creates transferable that represents a node operation, such as cut-to-clipboard. The transferable will be recognizable by node(java.awt.datatransfer.Transferable, int), nodes(java.awt.datatransfer.Transferable, int), and cookie(java.awt.datatransfer.Transferable, int, java.lang.Class).

Parameters:
n - the node to create a transferable for
actions - the action performed on the node
Returns:
the transferable

node

public static Node node(Transferable t,
                        int action)
Obtain a node from a transferable. Probes the transferable in case it includes a flavor corresponding to a node operation (which you must specify a mask for).

Parameters:
t - transferable
action - one of the DND_* or CLIPBOARD_* constants
Returns:
the node or null

nodes

public static Node[] nodes(Transferable t,
                           int action)
Obtain a list of nodes from a transferable. If there is only a single node in the transferable, this will just return a singleton array like 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, explorer.ExplorerActions will fallback 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 node(java.awt.datatransfer.Transferable, int).)

If you wish to test for cookies, you should do so manually according to your specific logic.

Parameters:
t - the transferable to probe
action - a DnD or clipboard constant
Returns:
a non-empty array of nodes, or null

cookie

public static Node.Cookie cookie(Transferable t,
                                 int action,
                                 Class cookie)
Obtain a cookie instance from the copied node in a transferable.

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 nodes(java.awt.datatransfer.Transferable, int) and manually check for the desired combination of cookies.

Parameters:
t - transferable to check in
cookie - cookie representation class to look for
action - the action which was used to store the node
Returns:
cookie or null if it does not exist

createPaste

public static ExTransferable.Single createPaste(NodeTransfer.Paste paste)
Creates transfer object that is used to carry an intelligent paste source through transferable or clipboard. findPaste(java.awt.datatransfer.Transferable) can retrieve it.

Parameters:
paste - the intelligent source of paste types
Returns:
the transferable

findPaste

public static NodeTransfer.Paste findPaste(Transferable t)
Find an intelligent source of paste types in a transferable. Note that AbstractNode.createPasteTypes(java.awt.datatransfer.Transferable, java.util.List) looks for this by default, so cut/copied nodes may specify how they may be pasted to some external node target.

Parameters:
t - the transferable to test
Returns:
the intelligent source or null if none is in the transferable

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.