com.borland.primetime.viewer
Class AbstractNodeViewer

java.lang.Object
  |
  +--com.borland.primetime.viewer.AbstractNodeViewer
All Implemented Interfaces:
NodeViewer
Direct Known Subclasses:
DesignerViewer, HistoryViewer

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)
          Adds given listener to list of registered listeners for Property change events.
 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()
          Creates the Swing GUI component to display content in the Structure Pane of the active Browser.
abstract  javax.swing.JComponent createViewerComponent()
          Creates the Swing GUI component to display content in the ContentView of the active Browser.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Notifies all registered PropertyChangeListeners that a property has been changed.
 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()
          Get the description of this NodeViewer for the ContentView tab tooltip.
 javax.swing.Icon getViewerIcon()
          Get the icon representing NodeViewer on the ContentView tab.
 void releaseViewer()
           This method is called when a context being viewed in a Browser has been closed.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes given listener from list of registered listeners for Property change events.
 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
 
Methods inherited from interface com.borland.primetime.ide.NodeViewer
getViewerTitle
 

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()
Creates the Swing GUI component to display content in the ContentView of the active Browser.
Returns:
Returns the Swing component to display in the ContentView.

createStructureComponent

public abstract javax.swing.JComponent createStructureComponent()
Creates the Swing GUI component to display content in the Structure Pane of the active Browser.
Returns:
Returns the Swing component to display in the Structure Pane, or null.

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()
Get the description of this NodeViewer for the ContentView tab tooltip.
Specified by:
getViewerDescription in interface NodeViewer
Returns:
Returns description or null.

getViewerIcon

public javax.swing.Icon getViewerIcon()
Get the icon representing NodeViewer on the ContentView tab.
Specified by:
getViewerIcon in interface NodeViewer
Returns:
Returns icon or null.

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. It is possible for this notification to happen before the viewer has been activated.

Specified by:
viewerNodeChanged in interface NodeViewer

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.

Specified by:
viewerDeactivating in interface NodeViewer
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. This may be called multiple times in situations where the content management is not sure that a given viewer was notified.

Specified by:
viewerDeactivated in interface NodeViewer

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.

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

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). This may be called multiple times in situations where the content management is not sure that a given viewer was notified.

Specified by:
browserDeactivated in interface NodeViewer

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). This may be called multiple times in situations where the content management is not sure that a given viewer was notified.

Specified by:
browserActivated in interface NodeViewer

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.

Specified by:
releaseViewer in interface NodeViewer

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds given listener to list of registered listeners for Property change events.
Specified by:
addPropertyChangeListener in interface NodeViewer
Parameters:
listener - The listener to be registered.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes given listener from list of registered listeners for Property change events.
Specified by:
removePropertyChangeListener in interface NodeViewer
Parameters:
listener - The listener to be unregistered.

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Notifies all registered PropertyChangeListeners that a property has been changed.
Parameters:
propertyName - The name of the property.
oldValue - The old value of the property, may be null.
newValue - The new value of the proeprty, may be null.