Java Code Examples for org.openide.nodes.Node#canDestroy()

The following examples show how to use org.openide.nodes.Node#canDestroy() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   File: PropertiesDataNode.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void createPasteTypes(Transferable transferable,
                             List<PasteType> types) {
    super.createPasteTypes(transferable, types);

    Element.ItemElem item;
    Node node = NodeTransfer.node(transferable, NodeTransfer.MOVE);
    if (node != null && node.canDestroy()) {
        item = node.getCookie(Element.ItemElem.class);
        if (item == null) {
            return;
        }
        Node itemNode = getChildren().findChild(item.getKey());
        if (node.equals(itemNode)) {
            return;
        }
        types.add(new EntryPasteType(item, node));
    } else {
        item = NodeTransfer.cookie(transferable, 
                                   NodeTransfer.COPY,
                                   Element.ItemElem.class);
        if (item != null) {
            types.add(new EntryPasteType(item, null));
        }
    }
}
 
Example 2
Source Project: netbeans   File: PropertiesLocaleNode.java    License: Apache License 2.0 5 votes vote down vote up
/** Creates paste types for this node. Overrides superclass method. */
@Override
protected void createPasteTypes(Transferable t, List<PasteType> s) {
    super.createPasteTypes(t, s);
    Element.ItemElem item;
    Node n = NodeTransfer.node(t, NodeTransfer.MOVE);
    // cut
    if (n != null && n.canDestroy ()) {
        item = n.getCookie(Element.ItemElem.class);
        if (item != null) {
            // are we pasting into the same node
            Node n2 = getChildren().findChild(item.getKey());
            if (n == n2) {
                return;
            }
            s.add(new KeyPasteType(item, n, KeyPasteType.MODE_PASTE_WITH_VALUE));
            s.add(new KeyPasteType(item, n, KeyPasteType.MODE_PASTE_WITHOUT_VALUE));
            return;
        }
    }
    // copy
    else {
        item = NodeTransfer.cookie(t, NodeTransfer.COPY, Element.ItemElem.class);
        if (item != null) {
            s.add(new KeyPasteType(item, null, KeyPasteType.MODE_PASTE_WITH_VALUE));
            s.add(new KeyPasteType(item, null, KeyPasteType.MODE_PASTE_WITHOUT_VALUE));
            return;
        }
    }
}