com.borland.primetime.viewer
Class AbstractNodeViewer

java.lang.Object
  |
  +--com.borland.primetime.viewer.AbstractNodeViewer

public abstract class AbstractNodeViewer
extends java.lang.Object
implements NodeViewer

AbstractNodeViewer provides a reasonable default implementation of the NodeViewer interface. Subclasses need only provide a constructor that invokes super(context) and override the abstract methods getViewerTitle, createViewerComponent, createStructureComponent to have a functional viewer.


Field Summary
protected  Context context
          The context for which this viewer was constructed.
protected  javax.swing.JComponent structureComponent
          The cached structure component, or null if no component has been requested or no structure component is available.
protected  javax.swing.JComponent viewerComponent
          The cached viewer component, or null if no component has been requested for this viewer.
 
Fields inherited from interface com.borland.primetime.ide.NodeViewer
EMPTY_ARRAY, PROP_DESCRIPTION, PROP_ICON, PROP_STRUCTURE_COMPONENT, PROP_TITLE, PROP_VIEWER_COMPONENT
 
Constructor Summary
AbstractNodeViewer(Context context)
          Creates a new AbstractNodeViewer for the specified context.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          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).
abstract  javax.swing.JComponent createStructureComponent()
           
abstract  javax.swing.JComponent createViewerComponent()
           
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
 Context getContext()
          Returns the context for which this AbstractNodeViewer was created.
 javax.swing.JComponent getStructureComponent()
          Returns the cached structure component if one has already been created.
 javax.swing.JComponent getViewerComponent()
          Returns the cached viewer component if one has already been created.
 java.lang.String getViewerDescription()
           Returns a short description of this NodeViewer.
 javax.swing.Icon getViewerIcon()
           Returns a display icon for this NodeViewer's tab.
 void releaseViewer()
           This method is called when a context being viewed in a Browser has been closed.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected Context context
The context for which this viewer was constructed.

viewerComponent

protected javax.swing.JComponent viewerComponent
The cached viewer component, or null if no component has been requested for this viewer.

structureComponent

protected javax.swing.JComponent structureComponent
The cached structure component, or null if no component has been requested or no structure component is available.
Constructor Detail

AbstractNodeViewer

public AbstractNodeViewer(Context context)
Creates a new AbstractNodeViewer for the specified context.
Parameters:
context - The unique combination of Browser and Node for which this NodeViewer is needed.
Method Detail

getContext

public Context getContext()
Returns the context for which this AbstractNodeViewer was created.
Returns:
A valid context instance.

createViewerComponent

public abstract javax.swing.JComponent createViewerComponent()

createStructureComponent

public abstract javax.swing.JComponent createStructureComponent()

getViewerComponent

public javax.swing.JComponent getViewerComponent()
Returns the cached viewer component if one has already been created. If no viewer has been created, invokes createViewerComponent to create one and caches its value for the next request.
Specified by:
getViewerComponent in interface NodeViewer
Returns:
An instance of a JComponent subclass that displays a meaningful content viewer for the relevant node.

getStructureComponent

public javax.swing.JComponent getStructureComponent()
Returns the cached structure component if one has already been created. If no structure has been created, invokes createStructureComponent to create one and caches its value for the next request.
Specified by:
getStructureComponent in interface NodeViewer
Returns:
An instance of a JComponent subclass that displays a meaningful quick browsing interface for the relevant node.

getViewerDescription

public java.lang.String getViewerDescription()
Description copied from interface: NodeViewer

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.

Specified by:
getViewerDescription in interface NodeViewer
Tags copied from interface: NodeViewer
Returns:
The user-friendly description (tooltip) for this NodeViewer.

getViewerIcon

public javax.swing.Icon getViewerIcon()
Description copied from interface: NodeViewer

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.

Specified by:
getViewerIcon in interface NodeViewer
Tags copied from interface: NodeViewer
Returns:
An icon to be displayed on the tab for this NodeViewer.

viewerNodeChanged

public void viewerNodeChanged()
Description copied from interface: NodeViewer

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.

Specified by:
viewerNodeChanged in interface NodeViewer

viewerDeactivating

public void viewerDeactivating()
                        throws VetoException
Description copied from interface: NodeViewer

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.

Specified by:
viewerDeactivating in interface NodeViewer
Tags copied from interface: NodeViewer
Throws:
VetoException - if this viewer component is in an invalid state that cannot be left unresolved.

viewerDeactivated

public void viewerDeactivated()
Description copied from interface: NodeViewer

This method is called after a viewer is successfully deactivated.

Specified by:
viewerDeactivated in interface NodeViewer

viewerActivated

public void viewerActivated(boolean requestFocus)
Description copied from interface: NodeViewer

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.

Specified by:
viewerActivated in interface NodeViewer
Tags copied from interface: NodeViewer
Parameters:
requestFocus - True if the viewer component should requestFocus at this point.

browserDeactivated

public void browserDeactivated()
Description copied from interface: NodeViewer

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

Specified by:
browserDeactivated in interface NodeViewer

browserActivated

public void browserActivated()
Description copied from interface: NodeViewer

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

Specified by:
browserActivated in interface NodeViewer

releaseViewer

public void releaseViewer()
Description copied from interface: NodeViewer

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.

Specified by:
releaseViewer in interface NodeViewer

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: NodeViewer
PropertyChangeListener events are used to broadcast changes to the NodeViewer's title, icon, and description as well as the associated viewer and structure components.
Specified by:
addPropertyChangeListener in interface NodeViewer

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface NodeViewer

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)