站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.5.1

LogicalViewProvider (NetBeans Project UI API) - NetBeans API Javadoc 5.5.1

org.netbeans.modules.projectuiapi/1 1.13.32 5

org.netbeans.spi.project.ui
Interface LogicalViewProvider


public interface LogicalViewProvider

Ability for a Project to supply a logical view of itself.

See Also:
Project.getLookup()

Method Summary
 Node createLogicalView()
          Create a logical view node.
 Node findPath(Node root, Object target)
          Try to find a given node in the logical view.
 

Method Detail

createLogicalView

Node createLogicalView()
Create a logical view node. Projects should not attempt to cache this node in any way; this call should always create a fresh node with no parent. The node's lookup should contain the project object.

Returns:
a node displaying the contents of the project in an intuitive way

findPath

Node findPath(Node root,
              Object target)
Try to find a given node in the logical view. If some node within the logical view tree has the supplied object in its lookup, it ought to be returned if that is practical. If there are multiple such nodes, the one most suitable for display to the user should be returned.
This may be used to select nodes corresponding to files, etc. The following constraint should hold:
  
 private static boolean isAncestor(Node root, Node n) {  
     if (n == null) return false;  
     if (n == root) return true;  
     return isAncestor(root, n.getParentNode());  
 }  
 // ...  
 Node root = ...;  
 Object target = ...;  
 LogicalViewProvider lvp = ...;  
 Node n = lvp.findPath(root, target);  
 if (n != null) {  
     assert isAncestor(root, n);  
     Lookup.Template tmpl = new Lookup.Template(null, null, target); 
     Collection res = n.getLookup().lookup(tmpl).allInstances();  
     assert Collections.singleton(target).equals(new HashSet(res)); 
 }  
 

Parameters:
root - a root node. E.g. a node from createLogicalView() or some wapper (FilterNode) around the node. The provider of the functionality is responsible for finding the appropriate node in the wrapper's children.
target - a target cookie, such as a DataObject
Returns:
a subnode with that cookie, or null

org.netbeans.modules.projectuiapi/1 1.13.32 5

Built on March 26 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.