org.openjump.core.ui.plugin
Class AbstractUiPlugIn

java.lang.Object
  extended by org.openjump.core.ui.plugin.AbstractUiPlugIn
All Implemented Interfaces:
PlugIn, java.awt.event.ActionListener, java.util.EventListener
Direct Known Subclasses:
AbstractThreadedUiPlugIn, FileDragDropPlugin, MosaicInternalFramesPlugIn, OpenRecentPlugIn, SynchronizationPlugIn

public abstract class AbstractUiPlugIn
extends java.lang.Object
implements PlugIn, java.awt.event.ActionListener

Default implementation of PlugIn, with useful functions for auto-generating a name, converting a PlugIn into an ActionListener (for use with JButtons, for example), and supporting undo.


Field Summary
protected  EnableCheck enableCheck
           
protected  WorkbenchContext workbenchContext
          The workbench context.
 
Constructor Summary
AbstractUiPlugIn()
           
AbstractUiPlugIn(javax.swing.Icon icon)
           
AbstractUiPlugIn(java.lang.String name)
           
AbstractUiPlugIn(java.lang.String name, javax.swing.Icon icon)
           
AbstractUiPlugIn(java.lang.String name, javax.swing.Icon icon, java.lang.String toolTip)
           
AbstractUiPlugIn(java.lang.String name, java.lang.String toolTip)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Wrap the plug-in as an ActionListener.
static java.lang.String createName(java.lang.Class plugInClass)
          Create a name using the I18N String using the class name or by adding spaces between the words in the class name without the PlugIn suffix.
 boolean execute(PlugInContext context)
          Method to be overridden by implementations to execute the plug-in.
 EnableCheck getEnableCheck()
           
 javax.swing.Icon getIcon()
          Get the icon for the plug-in.
 java.lang.String getName()
          Get the name of the plug-in.
 java.lang.String getToolTip()
          Get the tool-tip for the plug-in.
 void initialize(PlugInContext context)
          Method to be overridden by implementations to initialize the plug-in.
protected  boolean isRollingBackInvalidEdits(PlugInContext context)
           
protected  void reportNothingToUndoYet(PlugInContext context)
          Indicates that this plug-in either (1) is undoable but hasn't modified the system yet or (2) does not modify the system.
protected  void setWorkbenchContext(WorkbenchContext workbenchContext)
           
 java.lang.String toString()
          Get the String representation of the plug-in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workbenchContext

protected WorkbenchContext workbenchContext
The workbench context.


enableCheck

protected EnableCheck enableCheck
Constructor Detail

AbstractUiPlugIn

public AbstractUiPlugIn()

AbstractUiPlugIn

public AbstractUiPlugIn(java.lang.String name)

AbstractUiPlugIn

public AbstractUiPlugIn(javax.swing.Icon icon)

AbstractUiPlugIn

public AbstractUiPlugIn(java.lang.String name,
                        java.lang.String toolTip)

AbstractUiPlugIn

public AbstractUiPlugIn(java.lang.String name,
                        javax.swing.Icon icon)

AbstractUiPlugIn

public AbstractUiPlugIn(java.lang.String name,
                        javax.swing.Icon icon,
                        java.lang.String toolTip)
Method Detail

initialize

public void initialize(PlugInContext context)
                throws java.lang.Exception
Method to be overridden by implementations to initialize the plug-in. Plug-ins must invoke super.initialize().

Specified by:
initialize in interface PlugIn
Parameters:
context - The plug-in context.
Throws:
java.lang.Exception

execute

public boolean execute(PlugInContext context)
                throws java.lang.Exception
Method to be overridden by implementations to execute the plug-in.

Specified by:
execute in interface PlugIn
Parameters:
context - The plug-in context.
Returns:
true if the action completed, false if it was aborted. Used by ThreadedPlugIns to indicate that their #run method needn't be called next.
Throws:
java.lang.Exception - if a problem occurs during plug-in execution
See Also:
ThreadedPlugIn

reportNothingToUndoYet

protected void reportNothingToUndoYet(PlugInContext context)
Indicates that this plug-in either (1) is undoable but hasn't modified the system yet or (2) does not modify the system. In either case, the undo history will be preserved. If this method is not called, then this plug-in will be assumed to be non-undoable, and the undo history will be truncated.


isRollingBackInvalidEdits

protected boolean isRollingBackInvalidEdits(PlugInContext context)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Wrap the plug-in as an ActionListener.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The action event.

getEnableCheck

public EnableCheck getEnableCheck()

getIcon

public javax.swing.Icon getIcon()
Get the icon for the plug-in.

Returns:
The icon.

getName

public java.lang.String getName()
Get the name of the plug-in. If a name was not specified create a name using createName(Class).

Specified by:
getName in interface PlugIn
Returns:
The plug-in name.

getToolTip

public java.lang.String getToolTip()
Get the tool-tip for the plug-in.

Returns:
The tool-tip.

createName

public static java.lang.String createName(java.lang.Class plugInClass)
Create a name using the I18N String using the class name or by adding spaces between the words in the class name without the PlugIn suffix.

Parameters:
plugInClass - The plug-in's class.
Returns:
The plug-in's name.

setWorkbenchContext

protected void setWorkbenchContext(WorkbenchContext workbenchContext)
Parameters:
workbenchContext - the workbenchContext to set

toString

public java.lang.String toString()
Get the String representation of the plug-in.

Overrides:
toString in class java.lang.Object
Returns:
The string.