Java Code Examples for org.openide.nodes.Node.cloneNode()

The following are Jave code examples for showing how to use cloneNode() of the org.openide.nodes.Node class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: SettingChildren.java   Source Code and License Vote up 6 votes
protected Node copyNode (Node node) {
    boolean filter = false;
    try {
        DataObject d = (DataObject) node.getCookie (DataObject.class);
        if (d != null) {
            InstanceCookie.Of inst = (InstanceCookie.Of)d.getCookie(InstanceCookie.Of.class);
            if (inst != null && (inst.instanceOf(Node.class) || inst.instanceOf(Node.Handle.class))) {
                // This is just a node, not a real setting. E.g. ModuleNode, LoaderPoolNode. As such,
                // it itself should not display any origin information, it would make no sense. However
                // its children might have a legitimate DataObject cookie from the SFS.
                d = null;
            }
        }
        DataFolder folder = (DataFolder) node.getCookie (DataFolder.class);
        FileSystem fs = d == null || folder != null ? null : d.getPrimaryFile ().getFileSystem ();
        filter = fs == null ? false : fs.isDefault();
    } catch (FileStateInvalidException e) {
        // ignore
    }

    return filter ? new SettingFilterNode (node) : 
        node.isLeaf() ? node.cloneNode() : new TrivialFilterNode(node);
}
 
Example 2
Project: incubator-netbeans   File: SiteDocsNode.java   Source Code and License Vote up 5 votes
@Override
protected Node[] createNodes(Node obj) {
    DataObject dobj = (obj).getLookup().lookup(DataObject.class);

    if (dobj != null) {
        if (!VisibilityQuery.getDefault().isVisible(dobj.getPrimaryFile())) {
            return new Node[0];
        }
        Node n = new SiteDocsNode(project, obj, false);
        return new Node[] {n};
    }
    Node origos = obj;
    return new Node[] { origos.cloneNode() };
}
 
Example 3
Project: incubator-netbeans   File: ServicesTab.java   Source Code and License Vote up 4 votes
protected @Override Node createNodeForKey(Node key) {
    return key.cloneNode();
}
 
Example 4
Project: incubator-netbeans   File: LookupNode.java   Source Code and License Vote up 4 votes
/** A method to allow subclasses to create different child for any other node then folder.
* @param node to create child for
*/
protected Node createChild (Node node) {
    return node.cloneNode ();
}