Interface LogicalViewProvider

public interface LogicalViewProvider

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

See Also:

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


public 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.

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


public 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)); 

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
a subnode with that cookie, or null


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