ti.chimera
Class View

java.lang.Object
  extended byti.chimera.View

public abstract class View
extends java.lang.Object

A View is a "window" created by a plug-in. It can contain any swing component, or any lightweight (ie. does not have a native peer) AWT component.

Version:
0.1
Author:
Rob Clark

Field Summary
protected  Main main
          The main application.
 
Constructor Summary
View(Main main, java.lang.String name, javax.swing.Icon icon)
          Class Constructor.
 
Method Summary
 void addAction(javax.swing.Action a)
          This can be called by the class implementing the view in order to add view and/or plug-in specific actions to this view's popup menu.
 void addCloseRunnable(java.lang.Runnable closeRunnable)
          What to do when closing...
 boolean close()
          Called to cause this view to close.
 void closeHook()
          Deprecated. see addCloseRunnable(java.lang.Runnable)
abstract  java.awt.Component getComponent()
          Return the GUI component.
 java.lang.String getDescriptor()
          The "descriptor" is a string that has both the name of the view and the name of the plugin owning the view encoded in it.
 Dock getDock()
          Get the dock that this view is in.
 javax.swing.Icon getIcon()
          Get the icon for this view.
 java.lang.String getName()
          Get the name of this view.
 javax.swing.JPopupMenu getPopupMenu()
          Get the popup menu.
 boolean isClosable()
          Called by close() in order to determine if this view can be closed.
 void removeAction(javax.swing.Action a)
          This can be called by the class implementing the view in order to remove view and/or plug-in specific actions to this view's popup menu.
 void removeCloseRunnable(java.lang.Runnable closeRunnable)
           
 void setIcon(javax.swing.Icon icon)
          Set the icon for this view.
 void setName(java.lang.String name)
          Set the name for this view.
 void toForeground()
          Make this view the one that is currently in focus.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

main

protected Main main
The main application.

Constructor Detail

View

public View(Main main,
            java.lang.String name,
            javax.swing.Icon icon)
Class Constructor.

Parameters:
main - the main application
name - the name of the view
icon - the optional icon, or null
Method Detail

getComponent

public abstract java.awt.Component getComponent()
Return the GUI component. This is what is displayed in the dock when this view's tab is in front. This method must return the same object each time it is called.

Care should be taken if the component is not a swing component, as heavyweight AWT components cause problems, especially when the docks are displayed in DESKTOP_MODE.

Returns:
a GUI component.

getPopupMenu

public final javax.swing.JPopupMenu getPopupMenu()
Get the popup menu. This is used to display a pop-up menu when the user right-clicks on this view's tab in the dock. It contains a set of standard actions, plus all the actions specific to this view.

Returns:
a popup menu
See Also:
addAction(javax.swing.Action)

isClosable

public boolean isClosable()
Called by close() in order to determine if this view can be closed. If this method returns false then the close is aborted. By default it always returns true, but can be overriden as needed.

Returns:
true to permit the view to be closed, and false to prevent it

close

public final boolean close()
Called to cause this view to close. If the plugin needs to perform cleanup, it should override the closeHook() method which is called by this method.

See Also:
closeHook()

closeHook

public void closeHook()
Deprecated. see addCloseRunnable(java.lang.Runnable)

This method can be overriden by the view implementation if needed. The default behaviour is a no-op.

See Also:
close()

toForeground

public void toForeground()
Make this view the one that is currently in focus.


getName

public java.lang.String getName()
Get the name of this view.

Returns:
the name

getDescriptor

public java.lang.String getDescriptor()
The "descriptor" is a string that has both the name of the view and the name of the plugin owning the view encoded in it. The purpose is to uniquely identify a view amongst all views.

The method for the encoding is currently unspecified, and possibly subject to change.

Returns:
a string

setName

public void setName(java.lang.String name)
Set the name for this view.

Parameters:
name - the name of the view

getIcon

public javax.swing.Icon getIcon()
Get the icon for this view.

Returns:
the icon, or null if no icon

setIcon

public void setIcon(javax.swing.Icon icon)
Set the icon for this view.

Parameters:
icon - the optional icon, or null

addAction

public void addAction(javax.swing.Action a)
This can be called by the class implementing the view in order to add view and/or plug-in specific actions to this view's popup menu.

Note: this is only public in order for it to be accessible to scripts that subclass this class. You should use it as if it were protected.

Parameters:
a - an action, or null to add seperator

removeAction

public void removeAction(javax.swing.Action a)
This can be called by the class implementing the view in order to remove view and/or plug-in specific actions to this view's popup menu.

Note: this is only public in order for it to be accessible to scripts that subclass this class. You should use it as if it were protected.

Parameters:
a - an action, or null to add seperator

getDock

public Dock getDock()
Get the dock that this view is in.

Returns:
a dock, or null if this view isn't in a dock

addCloseRunnable

public void addCloseRunnable(java.lang.Runnable closeRunnable)
What to do when closing... this is sort of non-standard, but will do for now. I wouldn't suggest anyone use this method who isn't willing to go back and change their code when I change this.


removeCloseRunnable

public void removeCloseRunnable(java.lang.Runnable closeRunnable)

toString

public java.lang.String toString()