KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > project > ui > LogicalViewProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.project.ui;
21
22 import org.openide.nodes.Node;
23
24 /**
25  * Ability for a {@link org.netbeans.api.project.Project} to supply
26  * a logical view of itself.
27  * @see org.netbeans.api.project.Project#getLookup
28  * @author Jesse Glick
29  */

30 public interface LogicalViewProvider {
31
32     /**
33      * Create a logical view node.
34      * Projects should not attempt to cache this node in any way;
35      * this call should always create a fresh node with no parent.
36      * The node's lookup should contain the project object.
37      * @return a node displaying the contents of the project in an intuitive way
38      */

39     Node createLogicalView();
40     
41     /**
42     * Try to find a given node in the logical view.
43     * If some node within the logical view tree has the supplied object
44     * in its lookup, it ought to be returned if that is practical.
45     * If there are multiple such nodes, the one most suitable for display
46     * to the user should be returned.<BR>
47     * This may be used to select nodes corresponding to files, etc.
48     * The following constraint should hold:
49     * <pre>
50     * private static boolean isAncestor(Node root, Node n) {
51     * if (n == null) return false;
52     * if (n == root) return true;
53     * return isAncestor(root, n.getParentNode());
54     * }
55     * // ...
56     * Node root = ...;
57     * Object target = ...;
58     * LogicalViewProvider lvp = ...;
59     * Node n = lvp.findPath(root, target);
60     * if (n != null) {
61     * assert isAncestor(root, n);
62     * Lookup.Template tmpl = new Lookup.Template(null, null, target);
63     * Collection res = n.getLookup().lookup(tmpl).allInstances();
64     * assert Collections.singleton(target).equals(new HashSet(res));
65     * }
66     * </pre>
67     * @param root a root node. E.g. a node from {@link #createLogicalView} or some wapper
68     * (FilterNode) around the node. The provider of the functionality is
69     * responsible for finding the appropriate node in the wrapper's children.
70     * @param target a target cookie, such as a {@link org.openide.loaders.DataObject}
71     * @return a subnode with that cookie, or null
72     */

73     Node findPath(Node root, Object JavaDoc target);
74     
75 }
76
Popular Tags