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

The following examples show how to use org.openide.nodes.Node#cloneNode() . 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: SettingChildren.java    License: Apache License 2.0 6 votes vote down vote up
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
Source Project: netbeans   File: SiteDocsNode.java    License: Apache License 2.0 5 votes vote down vote up
@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
Source Project: netbeans   File: WebPagesNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Node[] createNodes(Node obj) {
    FileObject fobj = obj.getLookup().lookup(FileObject.class);

    if (fobj != null) {
        if (!VisibilityQuery.getDefault().isVisible(fobj)) {
            return new Node[0];
        }
        Node n = new WebPagesNode(project, obj, root, false);
        return new Node[] {n};
    }
    Node origos = obj;
    return new Node[] { origos.cloneNode() };
}
 
Example 4
Source Project: netbeans   File: LookupNode.java    License: Apache License 2.0 4 votes vote down vote up
/** 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 ();
}
 
Example 5
Source Project: netbeans   File: ServicesTab.java    License: Apache License 2.0 4 votes vote down vote up
protected @Override Node createNodeForKey(Node key) {
    return key.cloneNode();
}