本文整理了Java中org.openide.nodes.NodeTransfer
类的一些代码示例,展示了NodeTransfer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NodeTransfer
类的具体详情如下:
包路径:org.openide.nodes.NodeTransfer
类名称:NodeTransfer
[英]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.
[中]类,该类包含用于处理节点的特定数据传输风格和方法。有一些风格允许复制或剪切节点,并决定其粘贴类型。
这是一个虚拟实用程序类——不可能有任何实例。
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** Cut this node to the clipboard.
*
* @return {@link org.openide.util.datatransfer.ExTransferable.Single} with one cut flavor
* @throws IOException if it could not cut
* @see NodeTransfer
*/
public Transferable clipboardCut() throws IOException {
return NodeTransfer.transferable(this, NodeTransfer.CLIPBOARD_CUT);
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** Obtain a cookie instance from the copied node in a transferable.
* <P>
* First of all it checks whether the given transferable contains
* a node and then asks for the cookie.
* <p>If you wish to specially support multiple-node transfers, please use {@link #nodes}
* and manually check for the desired combination of cookies.
*
* @param t transferable to check in
* @param cookie cookie representation class to look for
* @param action the action which was used to store the node
*
* @return cookie or <code>null</code> if it does not exist
*/
public static <T extends Node.Cookie> T cookie(Transferable t, int action, Class<T> cookie) {
Node n = node(t, action);
return (n == null) ? null : n.getCookie(cookie);
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** Creates transferable that represents a node operation, such as cut-to-clipboard.
* The transferable will be recognizable by {@link #node}, {@link #nodes}, and {@link #cookie}.
*
* @param n the node to create a transferable for
* @param actions the action performed on the node
* @return the transferable
*/
public static ExTransferable.Single transferable(final Node n, int actions) {
return new ExTransferable.Single(createDndFlavor(actions)) {
public Object getData() {
return n;
}
};
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
Node n = node(mto.getTransferableAt(i), action);
Node n = node(t, action);
maybeReportException(cce);
} catch (IOException ioe) {
maybeReportException(ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException(ufe);
代码示例来源:origin: eu.agrosense.client/grid-api
@Override
public PasteType getDropType(final Transferable transferable, int action, int index) {
final GridManager gridManager = Lookup.getDefault().lookup(GridManager.class);
final Node[] nodes = NodeTransfer.nodes(transferable, NodeTransfer.DND_COPY);
if (nodes != null && acceptNode(nodes) && gridManager != null) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
processDroppedNodes(nodes, gridManager);
return null;
}
};
}
return null;
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** Find an intelligent source of paste types in a transferable.
* Note that {@link AbstractNode#createPasteTypes} looks for this
* by default, so cut/copied nodes may specify how they may be pasted
* to some external node target.
* @param t the transferable to test
* @return the intelligent source or <code>null</code> if none is in the transferable
*/
public static Paste findPaste(Transferable t) {
try {
if (t.isDataFlavorSupported(nodePasteFlavor)) {
return (Paste) t.getTransferData(nodePasteFlavor);
}
} catch (ClassCastException cce) {
maybeReportException(cce);
} catch (IOException ioe) {
maybeReportException(ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException(ufe);
}
return null;
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** Accumulate the paste types that this node can handle
* for a given transferable.
* <P>
* The default implementation simply tests whether the transferable supports
* intelligent pasting via {@link NodeTransfer#findPaste}, and if so, it obtains the paste types
* from the {@link NodeTransfer.Paste transfer data} and inserts them into the set.
* <p>Subclass implementations should typically call super (first or last) so that they
* add to, rather than replace, a superclass's available paste types; especially as the
* default implementation in <code>AbstractNode</code> is generally desirable to retain.
*
* @param t a transferable containing clipboard data
* @param s a list of {@link PasteType}s that will have added to it all types
* valid for this node (ordered as they will be presented to the user)
*/
protected void createPasteTypes(Transferable t, List<PasteType> s) {
NodeTransfer.Paste p = NodeTransfer.findPaste(t);
if (p != null) {
// adds all its types into the set
s.addAll(Arrays.asList(p.types(this)));
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
boolean ok = true;
for (int i = 0; i < count; i++) {
Node n = node (mto.getTransferableAt (i), action);
if (n == null) {
ok = false;
Node n = node (t, action);
if (n != null) return new Node[] { n };
maybeReportException (cce);
} catch (IOException ioe) {
maybeReportException (ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException (ufe);
代码示例来源:origin: eu.agrosense.client/grid
@Override
public PasteType getDropType(final Transferable transferable, int action, int index) {
final GridManager gridManager = Lookup.getDefault().lookup(GridManager.class);
final Node[] nodes = NodeTransfer.nodes(transferable, NodeTransfer.DND_COPY);
if (nodes != null && acceptNode(nodes) && gridManager != null) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
processDroppedNodes(nodes, gridManager);
return null;
}
};
}
return null;
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
maybeReportException(nfe);
} catch (ClassCastException cce) {
maybeReportException(cce);
} catch (IOException ioe) {
maybeReportException(ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException(ufe);
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** Accumulate the paste types that this node can handle
* for a given transferable.
* <P>
* The default implementation simply tests whether the transferable supports
* intelligent pasting via {@link NodeTransfer#findPaste}, and if so, it obtains the paste types
* from the {@link NodeTransfer.Paste transfer data} and inserts them into the set.
* <p>Subclass implementations should typically call super (first or last) so that they
* add to, rather than replace, a superclass's available paste types; especially as the
* default implementation in <code>AbstractNode</code> is generally desirable to retain.
*
* @param t a transferable containing clipboard data
* @param s a list of {@link PasteType}s that will have added to it all types
* valid for this node (ordered as they will be presented to the user)
*/
protected void createPasteTypes (Transferable t, List s) {
NodeTransfer.Paste p = NodeTransfer.findPaste (t);
if (p != null) {
// adds all its types into the set
s.addAll (Arrays.asList (p.types (this)));
}
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** Copy this node to the clipboard.
*
* @return {@link org.openide.util.datatransfer.ExTransferable.Single} with one copy flavor
* @throws IOException if it could not copy
* @see NodeTransfer
*/
public Transferable clipboardCopy() throws IOException {
return NodeTransfer.transferable(this, NodeTransfer.CLIPBOARD_COPY);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** Obtain a cookie instance from the copied node in a transferable.
* <P>
* First of all it checks whether the given transferable contains
* a node and then asks for the cookie.
* <p>If you wish to specially support multiple-node transfers, please use {@link #nodes}
* and manually check for the desired combination of cookies.
*
* @param t transferable to check in
* @param cookie cookie representation class to look for
* @param action the action which was used to store the node
*
* @return cookie or <code>null</code> if it does not exist
*/
public static Node.Cookie cookie (Transferable t, int action, Class cookie) {
Node n = node (t, action);
return n == null ? null : n.getCookie (cookie);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
boolean ok = true;
for (int i = 0; i < count; i++) {
Node n = node (mto.getTransferableAt (i), action);
if (n == null) {
ok = false;
Node n = node (t, action);
if (n != null) return new Node[] { n };
maybeReportException (cce);
} catch (IOException ioe) {
maybeReportException (ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException (ufe);
代码示例来源:origin: eu.agrosense.client/productionunit-nb
public static PasteType createPasteType(Transferable transferable, PresentationModel cpuModel) {
final List<Runnable> runnables = new ArrayList<>();
Node[] nodes = NodeTransfer.nodes(transferable, NodeTransfer.DND_COPY);
if (nodes != null) {
for (Node node : nodes) {
Runnable r = handleDrop(node, cpuModel);
if (r != null) runnables.add(r);
}
}
return runnables.isEmpty() ? null : new RunnablesPasteType(runnables);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** Find an intelligent source of paste types in a transferable.
* Note that {@link AbstractNode#createPasteTypes} looks for this
* by default, so cut/copied nodes may specify how they may be pasted
* to some external node target.
* @param t the transferable to test
* @return the intelligent source or <code>null</code> if none is in the transferable
*/
public static Paste findPaste (Transferable t) {
try {
if (t.isDataFlavorSupported (nodePasteFlavor)) {
return (Paste)t.getTransferData (nodePasteFlavor);
}
} catch (ClassCastException cce) {
maybeReportException (cce);
} catch (IOException ioe) {
maybeReportException (ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException (ufe);
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Creates transferable that represents a node operation, such as cut-to-clipboard.
* The transferable will be recognizable by {@link #node}, {@link #nodes}, and {@link #cookie}.
*
* @param n the node to create a transferable for
* @param actions the action performed on the node
* @return the transferable
*/
public static ExTransferable.Single transferable (final Node n, int actions) {
return new ExTransferable.Single (createDndFlavor (actions)) {
public Object getData () {
return n;
}
};
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Accumulate the paste types that this node can handle
* for a given transferable.
* <P>
* The default implementation simply tests whether the transferable supports
* intelligent pasting via {@link NodeTransfer#findPaste}, and if so, it obtains the paste types
* from the {@link NodeTransfer.Paste transfer data} and inserts them into the set.
* <p>Subclass implementations should typically call super (first or last) so that they
* add to, rather than replace, a superclass's available paste types; especially as the
* default implementation in <code>AbstractNode</code> is generally desirable to retain.
*
* @param t a transferable containing clipboard data
* @param s a list of {@link PasteType}s that will have added to it all types
* valid for this node (ordered as they will be presented to the user)
*/
protected void createPasteTypes (Transferable t, List s) {
NodeTransfer.Paste p = NodeTransfer.findPaste (t);
if (p != null) {
// adds all its types into the set
s.addAll (Arrays.asList (p.types (this)));
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** Cut this node to the clipboard.
*
* @return {@link org.openide.util.datatransfer.ExTransferable.Single} with one cut flavor
* @throws IOException if it could not cut
* @see NodeTransfer
*/
public Transferable clipboardCut () throws IOException {
return NodeTransfer.transferable (this, NodeTransfer.CLIPBOARD_CUT);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Obtain a cookie instance from the copied node in a transferable.
* <P>
* First of all it checks whether the given transferable contains
* a node and then asks for the cookie.
* <p>If you wish to specially support multiple-node transfers, please use {@link #nodes}
* and manually check for the desired combination of cookies.
*
* @param t transferable to check in
* @param cookie cookie representation class to look for
* @param action the action which was used to store the node
*
* @return cookie or <code>null</code> if it does not exist
*/
public static Node.Cookie cookie (Transferable t, int action, Class cookie) {
Node n = node (t, action);
return n == null ? null : n.getCookie (cookie);
}
内容来源于网络,如有侵权,请联系作者删除!