/** 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); }
/** 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); }
/** 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; } }; }
Node n = node(mto.getTransferableAt(i), action); Node n = node(t, action); maybeReportException(cce); } catch (IOException ioe) { maybeReportException(ioe); } catch (UnsupportedFlavorException ufe) { maybeReportException(ufe);
@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; }
/** 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; }
/** 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))); } }
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);
@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; }
maybeReportException(nfe); } catch (ClassCastException cce) { maybeReportException(cce); } catch (IOException ioe) { maybeReportException(ioe); } catch (UnsupportedFlavorException ufe) { maybeReportException(ufe);
/** 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))); } }
/** 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); }
/** 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); }
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);
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); }
/** 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; }
/** 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; } }; }
/** 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))); } }
/** 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); }
/** 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); }