com.borland.primetime.ide
Interface NodeViewerFactory


public interface NodeViewerFactory

The NodeViewerFactory interface defines a factory that creates instances of NodeViewer for displaying the contents of Node objects. When a user opens a file - or something - in a Browser, a tab is displayed with the file (or object's) display name. Under that tab is another set of tabs (aligned along the bottom) which represent the NodeViewers that have been created by registered NodeViewerFactories that 'accept' the corresponding node.

For example, the TextNodeViewerFactory is a registered NodeViewerFactory that 'accepts' all nodes of type TextFileNode (and subclasses thereof). When a node is displayed in the Browser of the type TextFileNode, the TextNodeViewerFactory creates an instance of TextNodeViewer to display a 'Source' tab representation of the Node.

All registered NodeViewerFactories will be asked to create a NodeViewer when a new Node is displayed in the Browser. A NodeViewerFactory may decline to represent a specific node by returning 'null' from the createNodeViewer(...) method.

To register a NodeViewerFactory, call either of the following methods: Browser.registerNodeViewerFactory(NodeViewerFactory factory) Browser.registerNodeViewerFactory(NodeViewerFactory factory, boolean asFirst)

See Also:
Browser, Context, com.borland.primetime.ide.MainContentView, ContentView, StructureView

Method Summary
 boolean canDisplayNode(Node node)
          If the NodeViewerFactory is registered with the Browser, this method is called before a new Node is displayed in the Browser window.
 NodeViewer createNodeViewer(Context context)
          If the NodeViewerFactory is registered with the Browser, this method is called each time a new Node is displayed in the Browser window.
 

Method Detail

canDisplayNode

public boolean canDisplayNode(Node node)
If the NodeViewerFactory is registered with the Browser, this method is called before a new Node is displayed in the Browser window. If the NodeViewerFactory instance can display the specified node, true should be returned. If the NodeViewerFactory does not wish to display the specified Node, it should return false.

This method is used for enabling / disabling context menus, so it should execute fairly quickly.

Parameters:
node - The Node that is about to be displayed in a Browser window
Returns:
True if this factory can create a viewer to represent the passed Node, or false if this NodeViewerFactory does not wish to represent the specified Node

createNodeViewer

public NodeViewer createNodeViewer(Context context)
If the NodeViewerFactory is registered with the Browser, this method is called each time a new Node is displayed in the Browser window. If the NodeViewerFactory instance wishes to display a tab in the specified context, a new instance of a NodeViewer should be returned. If the NodeViewerFactory does not wish to display the specified Node, it must return null.
Parameters:
context - The Browser / Node pair that is about to be displayed in a Browser window
Returns:
A NodeViewer to represent the passed Context, or null if this NodeViewerFactory does not wish to represent the specified Context