com.borland.jbuilder.designer
Class DesignerViewer

java.lang.Object
  |
  +--com.borland.primetime.viewer.AbstractNodeViewer
        |
        +--com.borland.jbuilder.designer.DesignerViewer
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, NodeViewer

public class DesignerViewer
extends AbstractNodeViewer
implements java.awt.event.MouseListener

Extension of AbstractNodeViewer for the design tab.


Field Summary
 UpdateAction ACTION_DesignerCopy
           
 UpdateAction ACTION_DesignerCut
           
 UpdateAction ACTION_DesignerPaste
           
 UpdateAction ACTION_DesignerRedo
           
 UpdateAction ACTION_DesignerUndo
           
static MessageCategory designerCategory
           
 boolean firstTime
           
 
Fields inherited from class com.borland.primetime.viewer.AbstractNodeViewer
context, structureComponent, viewerComponent
 
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
DesignerViewer(Context context)
          Constructs a new DesignerViewer.
 
Method Summary
 void activateDesignView(Designer designer)
          Activates the design view for the given designer.
 void activateDesignViewImpl(Designer designer)
          Updates the DesignView
static void addDesignerMessage(java.lang.String s, java.lang.Throwable t)
          Adds a message to the Designer tab of the message view.
static com.borland.jbuilder.cmt.CmtModelNode addNode(com.borland.jbuilder.cmt.CmtSubcomponent subcomponent)
          Adds a new component (with subcomponent) to the models given a class name, at no specific location
static com.borland.jbuilder.cmt.CmtModelNode addNode(com.borland.jbuilder.cmt.CmtSubcomponent subcomponent, com.borland.jbuilder.cmt.CmtModelNode targetNode)
          Adds a new subComponent (with node) to the models ,determining its target from the current selection
 com.borland.jbuilder.cmt.CmtModelNode addNode(java.lang.String componentClassName)
          Adds a new component (with node) to the models given a class name, at no specific location
 com.borland.jbuilder.cmt.CmtModelNode addNode(java.lang.String componentClassName, com.borland.jbuilder.cmt.CmtModelNode targetNode)
          Adds a new component (with node) to the models given a class name and a specific target node.
 void addToClassPath(java.lang.String className)
          Adds a new class name onto the classPath for the current project.
 void browserActivated()
          Handles notification of Browser being activated.
 void buildFinished()
          Handles notification of when a project is finished building.
 void changeUrl(Url url)
          Prepare to edit a component, opening it if necessary.
 void commit()
          Validates window panes after a user action has been performed, and commits the user action.
 void copy(boolean cut)
          Copy a component to the clipboard.
 javax.swing.JComponent createStructureComponent()
          Creates the UI component to display in the Structure Pane of the Browser.
 javax.swing.JComponent createViewerComponent()
          Creates the UI component (an HTMLViewerComponent) to display in the Browser.
 Designer edit(com.borland.jbuilder.cmt.CmtModelNode treeNode)
          Edits (opens and activates) a given node using its associated designer view.
 java.awt.Component getActiveDesignView()
          Retrieves the design view for the active designer.
 com.borland.jbuilder.cmt.CmtComponent getClipboard()
          Retrieve the clipboard instance
 com.borland.jbuilder.cmt.CmtComponents getComponents()
          Retrieves the components belonging to the current JBuilder project.
 com.borland.jbuilder.cmt.CmtComponentSource getComponentSource()
          Retrieves the component source for the components in the current project.
 java.awt.Component getDesignToolbar(Designer designer)
          Retrieves the toolbar assigned to the given designer.
 java.awt.Component getDesignView(Designer designer)
          Retrieves the current design view for this context.
 com.borland.jbuilder.designer.inspector.Inspector getInspector()
          Retrieves the Inspector instance.
 int getMode()
          Retrieves the current Designer mode.
 JBProject getProject()
          Retrieves the current JBuilder project.
 javax.swing.tree.TreeSelectionModel getSelection()
          Retrieves the current selection model.
 com.borland.jbuilder.cmt.CmtSubcomponent[] getSubcomponents()
          Returns an array of CmtSubcomponents belonging to the current Component under design
 java.lang.String getToolInitializer()
          Retrieves the initializer for the current palette.
 java.lang.String getToolName()
          Retrieves the name of the currently selected palette tool.
static javax.swing.tree.TreePath getTreePath(javax.swing.tree.TreeNode node)
          Retrieves the TreePath for the given node.
 java.lang.String getViewerDescription()
          Retrieves the DesignerViewer description string.
 java.lang.String getViewerTitle()
          Retrieves the DesignerViewer title string.
 void gotoMethod(java.lang.String methodName, java.lang.String[] params)
          Opens the editor for the current class being designed and scrolls to the given method.
 boolean hideInspector(javax.swing.JComponent newView, boolean userAction)
          Hides the designer Inspector.
 void lookupHelp(java.lang.String className)
          Brings up the help browser loaded with the documentation for the given class name.
 void lookupHelp(java.lang.String className, java.lang.String propertyName)
          Brings up the help browser loaded with the documentation for the given class and the given property.
 void mouseClicked(java.awt.event.MouseEvent e)
          Handles a mouse clicked event.
 void mouseEntered(java.awt.event.MouseEvent e)
          Handles a mouse entered event.
 void mouseExited(java.awt.event.MouseEvent e)
          Handles a mouse exited event.
 void mousePressed(java.awt.event.MouseEvent e)
          Handles a mouse pressed event.
 void mouseReleased(java.awt.event.MouseEvent e)
          Handles a mouse released event.
 void open(boolean freshOpen)
          Opens/reopens a component for editing.
 void openImpl(boolean freshOpen)
          Opens/reopens a component for editing, given its corresponding classname and/or a filename.
 com.borland.jbuilder.cmt.CmtModelNode[] paste()
          Retrieves a set of component nodes from the clipboard for pasting.
 com.borland.jbuilder.cmt.CmtModelNode[] paste(java.awt.Point relLocation)
          Retrieves and pastes a set of component nodes from the clipboard to the location specified.
 void releaseViewer()
          Called when the context being viewed has been closed.
 boolean remove(com.borland.jbuilder.cmt.CmtModelNode treeNode)
          Removes the specified component node.
 void removeSelectedNodes()
          Removes the selected components nodes.
 void setBusy(boolean b)
          Changes UI to indicate either a busy state or a ready state.
 void setDesignToolbar(Designer designer, java.awt.Component toolbar)
          Associates the given toolbar to the given designer instance.
 void setDesignView(Designer designer, java.awt.Component view)
          Callback for designers to set the design view for this context for a given designer.
static void setStatusText(java.lang.String text)
          Specifies the text string for the browser status bar.
 boolean showInspector(javax.swing.JComponent newView, boolean userAction)
          Displays the designer Inspector.
 void toolUsed()
          Retrieves the tool currently in use.
 void viewerActivated(boolean requestFocus)
           Notification that this viewer has been activated.
 
Methods inherited from class com.borland.primetime.viewer.AbstractNodeViewer
addPropertyChangeListener, browserDeactivated, firePropertyChange, getContext, getStructureComponent, getViewerComponent, getViewerIcon, removePropertyChangeListener, viewerDeactivated, viewerDeactivating, viewerNodeChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

designerCategory

public static MessageCategory designerCategory

ACTION_DesignerUndo

public UpdateAction ACTION_DesignerUndo

ACTION_DesignerRedo

public UpdateAction ACTION_DesignerRedo

ACTION_DesignerCut

public UpdateAction ACTION_DesignerCut

ACTION_DesignerCopy

public UpdateAction ACTION_DesignerCopy

ACTION_DesignerPaste

public UpdateAction ACTION_DesignerPaste

firstTime

public boolean firstTime
Constructor Detail

DesignerViewer

public DesignerViewer(Context context)

Constructs a new DesignerViewer.

Parameters:
context - context (browser/node pair) for which the viewer is to be constructed
Method Detail

addDesignerMessage

public static void addDesignerMessage(java.lang.String s,
                                      java.lang.Throwable t)

Adds a message to the Designer tab of the message view.

Parameters:
s - the message string
t - throwable exception object. Unused.

getViewerTitle

public java.lang.String getViewerTitle()

Retrieves the DesignerViewer title string.

Following copied from interface: com.borland.primetime.ide.NodeViewer
Returns:
The user-friendly title to be displayed on the tab for this NodeViewer.

getViewerDescription

public java.lang.String getViewerDescription()

Retrieves the DesignerViewer description string.

Overrides:
getViewerDescription in class AbstractNodeViewer
Following copied from class: com.borland.primetime.viewer.AbstractNodeViewer
Returns:
Returns description or null.

createViewerComponent

public javax.swing.JComponent createViewerComponent()

Creates the UI component (an HTMLViewerComponent) to display in the Browser.

Overrides:
createViewerComponent in class AbstractNodeViewer
Returns:
the HTMLViewerComponent to display in the browser.

releaseViewer

public void releaseViewer()

Called when the context being viewed has been closed. Releases the DesignerViewer resources (i.e. palette, inspector) in use.

Overrides:
releaseViewer in class AbstractNodeViewer

createStructureComponent

public javax.swing.JComponent createStructureComponent()

Creates the UI component to display in the Structure Pane of the Browser.

Overrides:
createStructureComponent in class AbstractNodeViewer
Returns:
the component to display in the structure pane.

viewerActivated

public void viewerActivated(boolean requestFocus)

Notification that this viewer has been activated. 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.

Overrides:
viewerActivated in class AbstractNodeViewer
Parameters:
requestFocus - indicates whether the viewer component should request focus at this point

getProject

public JBProject getProject()

Retrieves the current JBuilder project.

Returns:
current JBProject instance

getComponents

public com.borland.jbuilder.cmt.CmtComponents getComponents()

Retrieves the components belonging to the current JBuilder project.

Returns:
set of CmtComponents for current project

getComponentSource

public com.borland.jbuilder.cmt.CmtComponentSource getComponentSource()

Retrieves the component source for the components in the current project.

Returns:
CmtComponentSource component source instance

open

public void open(boolean freshOpen)

Opens/reopens a component for editing.

Calls openImpl method to do the actual opening.

Parameters:
freshOpen - indicates whether this is a new open request as opposed to a reopen request

openImpl

public void openImpl(boolean freshOpen)

Opens/reopens a component for editing, given its corresponding classname and/or a filename.

Performs the following sequence:



Parameters:
freshOpen - indicates whether this is a new open request as opposed to a reopen request

getClipboard

public com.borland.jbuilder.cmt.CmtComponent getClipboard()

Retrieve the clipboard instance

Returns:
clipboard CmtComponent instance

changeUrl

public void changeUrl(Url url)

Prepare to edit a component, opening it if necessary.

Parameters:
url - unused

copy

public void copy(boolean cut)

Copy a component to the clipboard.

Parameters:
cut - true if copy is actually a cut operation, otherwise false

getSubcomponents

public com.borland.jbuilder.cmt.CmtSubcomponent[] getSubcomponents()

Returns an array of CmtSubcomponents belonging to the current Component under design

Returns:
array of CmtSubcomponents for current Component

getSelection

public javax.swing.tree.TreeSelectionModel getSelection()

Retrieves the current selection model.

Returns:
TreeSelectionModel selection model

paste

public com.borland.jbuilder.cmt.CmtModelNode[] paste()

Retrieves a set of component nodes from the clipboard for pasting.

Returns:
CmtModelNode array of nodes from clipboard to paste

getInspector

public com.borland.jbuilder.designer.inspector.Inspector getInspector()

Retrieves the Inspector instance.

Returns:
current Inspector object instance

paste

public com.borland.jbuilder.cmt.CmtModelNode[] paste(java.awt.Point relLocation)

Retrieves and pastes a set of component nodes from the clipboard to the location specified.

Returns:
CmtModelNode array of nodes from clipboard to paste

setBusy

public void setBusy(boolean b)

Changes UI to indicate either a busy state or a ready state.

Parameters:
b - true if busy state, otherwise false

edit

public Designer edit(com.borland.jbuilder.cmt.CmtModelNode treeNode)

Edits (opens and activates) a given node using its associated designer view.

Parameters:
node - the model node
Returns:
associated designer view instance

setDesignView

public void setDesignView(Designer designer,
                          java.awt.Component view)

Callback for designers to set the design view for this context for a given designer.

Parameters:
designer - designer to which a view is to be set
view - design view to set

getDesignView

public java.awt.Component getDesignView(Designer designer)

Retrieves the current design view for this context.

Parameters:
designer - designer from which the view is to be retrieved
Returns:
design view for given designer

getActiveDesignView

public java.awt.Component getActiveDesignView()

Retrieves the design view for the active designer.

Returns:
design view for active designer

setDesignToolbar

public void setDesignToolbar(Designer designer,
                             java.awt.Component toolbar)

Associates the given toolbar to the given designer instance.

Parameters:
designer - designer target for toolbar
toolbar - toolbar to associate

getDesignToolbar

public java.awt.Component getDesignToolbar(Designer designer)

Retrieves the toolbar assigned to the given designer.

Parameters:
designer - designer owning the toolbar requested
Returns:
toolbar assigned to the given designer

showInspector

public boolean showInspector(javax.swing.JComponent newView,
                             boolean userAction)

Displays the designer Inspector.

Parameters:
newView - new Inspector view
userAction - true if user uses explicit action to turn on the Inspector view, otherwise false
Returns:
true if Inspector is shown, otherwise false

hideInspector

public boolean hideInspector(javax.swing.JComponent newView,
                             boolean userAction)

Hides the designer Inspector.

Parameters:
newView - inspector view
userAction - true if Inspector view is being closed through direct user action
Returns:
true if Inspector is successfully hidden, otherwise false.

activateDesignView

public void activateDesignView(Designer designer)

Activates the design view for the given designer.

Parameters:
designer - designer containing view to activate

browserActivated

public void browserActivated()

Handles notification of Browser being activated.

Overrides:
browserActivated in class AbstractNodeViewer

activateDesignViewImpl

public void activateDesignViewImpl(Designer designer)

Updates the DesignView


removeSelectedNodes

public void removeSelectedNodes()

Removes the selected components nodes.


remove

public boolean remove(com.borland.jbuilder.cmt.CmtModelNode treeNode)

Removes the specified component node.

Parameters:
treeNode - component node to remove
Returns:
true if component model for the node can be found, otherwise false.

Note that this return value is not necessarily an indication of the node being successfully removed.


addNode

public com.borland.jbuilder.cmt.CmtModelNode addNode(java.lang.String componentClassName)

Adds a new component (with node) to the models given a class name, at no specific location

Parameters:
componentClassName - class name of component to add
Returns:
new CmtModelNode for component added

addNode

public static com.borland.jbuilder.cmt.CmtModelNode addNode(com.borland.jbuilder.cmt.CmtSubcomponent subcomponent)

Adds a new component (with subcomponent) to the models given a class name, at no specific location

Parameters:
subcomponent - new component to add
Returns:
new CmtModelNode for component added

addNode

public static com.borland.jbuilder.cmt.CmtModelNode addNode(com.borland.jbuilder.cmt.CmtSubcomponent subcomponent,
                                                            com.borland.jbuilder.cmt.CmtModelNode targetNode)

Adds a new subComponent (with node) to the models ,determining its target from the current selection

Parameters:
subcomponent - new component node to add
targetNode - target node to which subcomponent is to be added
Returns:
new CmtModelNode for the component node added

addNode

public com.borland.jbuilder.cmt.CmtModelNode addNode(java.lang.String componentClassName,
                                                     com.borland.jbuilder.cmt.CmtModelNode targetNode)

Adds a new component (with node) to the models given a class name and a specific target node.

Parameters:
componentClassName -  
targetNode -  

commit

public void commit()

Validates window panes after a user action has been performed, and commits the user action.


getMode

public int getMode()

Retrieves the current Designer mode. The Designer modes are:

Returns:
Designer mode integer index

getToolName

public java.lang.String getToolName()

Retrieves the name of the currently selected palette tool.

Returns:
String name of currently selected palette tool

getToolInitializer

public java.lang.String getToolInitializer()

Retrieves the initializer for the current palette.

Returns:
String initializer for the current tool palette

toolUsed

public void toolUsed()

Retrieves the tool currently in use.


addToClassPath

public void addToClassPath(java.lang.String className)

Adds a new class name onto the classPath for the current project.

Parameters:
className - new class name to add to classPath

gotoMethod

public void gotoMethod(java.lang.String methodName,
                       java.lang.String[] params)

Opens the editor for the current class being designed and scrolls to the given method.

Parameters:
methodName - name of method to which to scroll
params - parameter signature of the method

setStatusText

public static void setStatusText(java.lang.String text)

Specifies the text string for the browser status bar.

Parameters:
text - text string to be displayed in browser status bar

lookupHelp

public void lookupHelp(java.lang.String className)

Brings up the help browser loaded with the documentation for the given class name.

Parameters:
className - name of class for which documentation is requested

lookupHelp

public void lookupHelp(java.lang.String className,
                       java.lang.String propertyName)

Brings up the help browser loaded with the documentation for the given class and the given property.

Parameters:
className - name of class for which documentation is requested
propertyName - name of class property

buildFinished

public void buildFinished()

Handles notification of when a project is finished building.


getTreePath

public static javax.swing.tree.TreePath getTreePath(javax.swing.tree.TreeNode node)

Retrieves the TreePath for the given node.

Parameters:
node - given tree node
Returns:
TreePath for the given tree node

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)

Handles a mouse clicked event. Currently unimplemented.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - mouse clicked event object

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)

Handles a mouse pressed event. Currently unimplemented.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - mouse pressed event object

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)

Handles a mouse released event. This method manages dropping a component into the active designer.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - mouse released event object

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)

Handles a mouse entered event. This method manages the cursor display based on the current Designer mode.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - mouse entered event object

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)

Handles a mouse exited event. Currently unimplemented.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - mouse exited event object