本文整理了Java中org.openide.nodes.NodeTransfer.nodes()
方法的一些代码示例,展示了NodeTransfer.nodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NodeTransfer.nodes()
方法的具体详情如下:
包路径:org.openide.nodes.NodeTransfer
类名称:NodeTransfer
方法名:nodes
[英]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. If there is a ExTransferable#multiFlavor (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 #node.)
If you wish to test for cookies, you should do so manually according to your specific logic.
[中]
代码示例来源: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: 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: 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: org.netbeans.modules/org-netbeans-modules-xml-xam-ui
/**
* Create PasteType to receive the transferable into the given component.
*
* @param target the target component.
* @param transfer the component(s) being pasted.
* @param type type of the component to allow (e.g. Element.class),
* or null to allow all types.
* @param operations set of NodeTransfer constants for cut/copy.
* @param index index at which to paste the component (-1 to append).
* @return the new paste type.
*/
private static PasteType getPasteType(Component target,
Transferable transfer, Class<? extends Component> type,
int[] operations, int index) {
PasteType retVal = null;
// Check each operation until a supported one is found.
for (int oper : operations) {
// Attempt to retrieve the nodes from transferable.
Node[] nodes = NodeTransfer.nodes(transfer, oper);
if (nodes != null) {
// Can any of these be pasted into the target?
if (canPaste(nodes, target, oper, type)) {
retVal = new PasteTypeImpl(Arrays.asList(nodes), target,
oper, index);
break;
}
}
}
return retVal;
}
内容来源于网络,如有侵权,请联系作者删除!