com.borland.primetime.ide
Interface NodeViewer

All Known Implementing Classes:
AbstractNodeViewer

public interface NodeViewer

The NodeViewer interface defines a type of viewer for displaying the contents of Node objects. When a user opens a node the browser, the a tab with the node's display name is added to the top of the brower's content view. The node may or may not represent a file, the process is the same in either case.

At the bottom of the content view is another set of tabs which represent the NodeViewers that have been created by registered NodeViewerFactories that 'accept' the corresponding node. NodeViewers are never recyled; a newly created NodeViewer instance is used as a viewer for each node within each browser.

Example: the TextNodeViewerFactory is a registered NodeViewerFactory that 'accepts' all nodes of type TextFileNode and its subclasses. When a TextFileNode is added to the content view in the browser, the TextNodeViewerFactory creates an instance of TextNodeViewer to display a 'Source' tab representation.

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

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

Field Summary
static NodeViewer[] EMPTY_ARRAY
          Used to return an empty array of NodeViewers when there are none.
static java.lang.String PROP_DESCRIPTION
          PropertyChangeListener property name key indicating the description has changed
static java.lang.String PROP_ICON
          PropertyChangeListener property name key indicating the icon has changed
static java.lang.String PROP_STRUCTURE_COMPONENT
          PropertyChangeListener property name key indicating the structure component has changed
static java.lang.String PROP_TITLE
          PropertyChangeListener property name key indicating the title has changed
static java.lang.String PROP_VIEWER_COMPONENT
          PropertyChangeListener property name key indicating the viewer component has changed
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          PropertyChangeListener events are used to broadcast changes to the NodeViewer's title, icon, and description as well as the associated viewer and structure components.
 void browserActivated()
           This method is called ONLY on the active NodeViewer when the Browser has been activated (the user clicked on another window).
 void browserDeactivated()
           This method is called ONLY on the active NodeViewer when the Browser has been deactivated (the user clicked on another window).
 javax.swing.JComponent getStructureComponent()
           Returns a component to display in the MainStructureView in the Browser.
 javax.swing.JComponent getViewerComponent()
           Returns the UI component to display in the Browser.
 java.lang.String getViewerDescription()
           Returns a short description of this NodeViewer.
 javax.swing.Icon getViewerIcon()
           Returns a display icon for this NodeViewer's tab.
 java.lang.String getViewerTitle()
           Returns a user-friendly display string for this node viewer.
 void releaseViewer()
           This method is called when a context being viewed in a Browser has been closed.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void viewerActivated(boolean requestFocus)
           This method is called after getViewerComponent(...) has returned a Component that has been placed in the correct location in the Browser, getStructureComponent(...) has returned a Component that has been placed in the correct location in the Browser, and the tab has switched to view the new viewer.
 void viewerDeactivated()
           This method is called after a viewer is successfully deactivated.
 void viewerDeactivating()
           This method is called when a viewer is about to be deactivated (user clicked on a different tab).
 void viewerNodeChanged()
           This method is called when the Node associated with this viewer has been altered.
 

Field Detail

EMPTY_ARRAY

public static final NodeViewer[] EMPTY_ARRAY
Used to return an empty array of NodeViewers when there are none.

PROP_TITLE

public static final java.lang.String PROP_TITLE
PropertyChangeListener property name key indicating the title has changed

PROP_DESCRIPTION

public static final java.lang.String PROP_DESCRIPTION
PropertyChangeListener property name key indicating the description has changed

PROP_ICON

public static final java.lang.String PROP_ICON
PropertyChangeListener property name key indicating the icon has changed

PROP_VIEWER_COMPONENT

public static final java.lang.String PROP_VIEWER_COMPONENT
PropertyChangeListener property name key indicating the viewer component has changed

PROP_STRUCTURE_COMPONENT

public static final java.lang.String PROP_STRUCTURE_COMPONENT
PropertyChangeListener property name key indicating the structure component has changed
Method Detail

getViewerTitle

public java.lang.String getViewerTitle()

Returns a user-friendly display string for this node viewer. This is the text that will appear on the tab along the bottom of the ContentView for this node. This value should be resourced.

Returns:
The user-friendly title to be displayed on the tab for this NodeViewer.

getViewerDescription

public java.lang.String getViewerDescription()

Returns a short description of this NodeViewer. This is the text found in the tooltip as the user mouses over the tabs of the ContentView. This value should be resourced.

Returns:
The user-friendly description (tooltip) for this NodeViewer.

getViewerIcon

public javax.swing.Icon getViewerIcon()

Returns a display icon for this NodeViewer's tab.

Typically, null is returned and no Icon is used in the ContentView tabs, but the option to display one is available for 'special' cases. None of the JBuilder NodeViewers display icons.

Returns:
An icon to be displayed on the tab for this NodeViewer.

getViewerComponent

public javax.swing.JComponent getViewerComponent()

Returns the UI component to display in the Browser. Note that once created this component must be cached and returned on subsequent calls to getViewerComponent. Returning a different viewer component will cause the browser to replace the existing viewer.

Returns:
The javax.swing.JComponent to serve as a viewer for this Node.

getStructureComponent

public javax.swing.JComponent getStructureComponent()

Returns a component to display in the MainStructureView in the Browser. Note that once created this component must be cached and returned on subsequent calls to code>getStructureComponent. Returning a different structure component will cause the browser to replace the existing structure.

Returns:
An JComponent to serve as the sturcture view for this Node, or null if no structure view is available.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
PropertyChangeListener events are used to broadcast changes to the NodeViewer's title, icon, and description as well as the associated viewer and structure components.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)

viewerNodeChanged

public void viewerNodeChanged()

This method is called when the Node associated with this viewer has been altered. Typically this indicates that the node has been renamed or moved in the project hierarchy. This is an opporitunity for the NodeViewer to update anything that displays the Node's name, description, etc.


viewerActivated

public void viewerActivated(boolean requestFocus)

This method is called after getViewerComponent(...) has returned a Component that has been placed in the correct location in the Browser, getStructureComponent(...) has returned a Component that has been placed in the correct location in the Browser, and the tab has switched to view the new viewer.

Parameters:
requestFocus - True if the viewer component should requestFocus at this point.

viewerDeactivating

public void viewerDeactivating()
                        throws VetoException

This method is called when a viewer is about to be deactivated (user clicked on a different tab). This is an opporitunity for the NodeViewer to check the current state of any 'edits' that a user might have made, and if a critical problem exists, throw a VetoException, and the viewer will not be deactivated.

Typically, this method does nothing. Only in cases where switching Nodes, or changing views which put the node in an indeterminate state should the jarring effect of 'sticking' the viewer be used. This *could* make the user think that JBuilder is locked-up if no UI clues indicate that there is a problem.

Throws:
VetoException - if this viewer component is in an invalid state that cannot be left unresolved.

viewerDeactivated

public void viewerDeactivated()

This method is called after a viewer is successfully deactivated.


browserActivated

public void browserActivated()

This method is called ONLY on the active NodeViewer when the Browser has been activated (the user clicked on another window).


browserDeactivated

public void browserDeactivated()

This method is called ONLY on the active NodeViewer when the Browser has been deactivated (the user clicked on another window).


releaseViewer

public void releaseViewer()

This method is called when a context being viewed in a Browser has been closed. This is an opporitunity for the NodeViewer to relase any resources that it wants - now that this viewer is no longer needed.