de.hunsicker.jalopy.plugin
Class AbstractPlugin

java.lang.Object
  |
  +--de.hunsicker.jalopy.plugin.AbstractPlugin

public abstract class AbstractPlugin
extends java.lang.Object

Skeleton implementation of a Jalopy Plug-in for integrated development environments.

Version:
$Revision: 1.9.2.3 $
Author:
Marco Hunsicker

Nested Class Summary
static class AbstractPlugin.Action
          Represents an action that can be performed.
 
Field Summary
protected  SwingAppender appender
          Appender to write messages to.
protected  Jalopy jalopy
          The main Jalopy instance.
 
Constructor Summary
AbstractPlugin()
          Creates a new AbstractPlugin object.
AbstractPlugin(SwingAppender appender)
          Creates a new AbstractPlugin object.
 
Method Summary
 void afterEnd()
          Called on the event dispatching thread after an action was performed.
 void beforeStart()
          Called on the event dispatching thread before an action will be started.
protected  ProgressMonitor createProgressMonitor()
          Creates a monitor to be used for long-running operations.
protected  void displayError(java.lang.Throwable error, java.awt.Frame parent)
          Displays an error dialog.
protected  void executeAsynchron(java.lang.Runnable operation)
          Executes the given runnable asynchronously on the AWT event dispatching thread.
protected  void executeSynchron(java.lang.Runnable operation)
          Executes the given runnable synchronously on the AWT event dispatching thread.
abstract  Project getActiveProject()
          Returns the currently active project.
 long getElapsed()
          Returns the elapsed execution time of the run.
 Jalopy getEngine()
          Returns a Jalopy instance.
protected abstract  FileFormat getFileFormat()
          Returns the file format to use for writing Java source files.
 AbstractPlugin.Action getLastAction()
          Returns the action that was performed last.
abstract  java.awt.Frame getMainWindow()
          Returns the main window of the application.
 Jalopy.State getState()
          Returns the state info of Plug-in.
 StatusBar getStatusBar()
          Returns the active status bar.
protected  void hideWaitCursor()
          Hides the wait cursor.
 void interrupt()
          Interrupts the currently performed action, if any.
 boolean isRunning()
          Determines whether the Plug-in currently processes a request.
 void performAction(AbstractPlugin.Action action)
          Performs the given action.
protected  void showWaitCursor()
          Shows the wait cursor to indicate a long-running operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jalopy

protected Jalopy jalopy
The main Jalopy instance.


appender

protected SwingAppender appender
Appender to write messages to.

Constructor Detail

AbstractPlugin

public AbstractPlugin()
Creates a new AbstractPlugin object. Uses a default appender which outputs all messages to System.out.


AbstractPlugin

public AbstractPlugin(SwingAppender appender)
Creates a new AbstractPlugin object.

Parameters:
appender - appender to use for logging; if null all logging output goes to System.out.
Method Detail

getActiveProject

public abstract Project getActiveProject()
Returns the currently active project.

Returns:
the active user project.

getMainWindow

public abstract java.awt.Frame getMainWindow()
Returns the main window of the application.

Returns:
the main application window.

getElapsed

public long getElapsed()
Returns the elapsed execution time of the run.

Returns:
the elapsed execution time.

getLastAction

public final AbstractPlugin.Action getLastAction()
Returns the action that was performed last.

Returns:
Last performed action. Returns null if no action was ever performed.

getState

public final Jalopy.State getState()
Returns the state info of Plug-in. Use this method to query the state after a run finished.

Returns:
The run state.
See Also:
Jalopy.getState()

isRunning

public boolean isRunning()
Determines whether the Plug-in currently processes a request.

Returns:
true if an action is currently being performed.
Since:
1.0b8
See Also:
performAction(de.hunsicker.jalopy.plugin.AbstractPlugin.Action), interrupt()

getStatusBar

public StatusBar getStatusBar()
Returns the active status bar. Override to provide access to the status bar of the used application.

Returns:
the active status bar. The default implementation returns a dummy.

afterEnd

public void afterEnd()
Called on the event dispatching thread after an action was performed.

Override this method to perform any custom work after the formatting process finished.


beforeStart

public void beforeStart()
Called on the event dispatching thread before an action will be started.

Override this method to perform any custom work before the formatting process starts.


interrupt

public final void interrupt()
Interrupts the currently performed action, if any.

Since:
1.0b8

performAction

public final void performAction(AbstractPlugin.Action action)
Performs the given action.

Parameters:
action - action to perform.

getFileFormat

protected abstract FileFormat getFileFormat()
Returns the file format to use for writing Java source files.

Returns:
the file format to use.

getEngine

public final Jalopy getEngine()
Returns a Jalopy instance. The instance will be configured according to the current code convention.

Returns:
a Jalopy instance.
Since:
1.0b8

createProgressMonitor

protected ProgressMonitor createProgressMonitor()
Creates a monitor to be used for long-running operations.

Returns:
the progress monitor to use for long-running operations.

displayError

protected void displayError(java.lang.Throwable error,
                            java.awt.Frame parent)
Displays an error dialog.

Parameters:
error - the throwable which caused the error.
parent - parent frame of the dialog (used to position the dialog).

executeAsynchron

protected void executeAsynchron(java.lang.Runnable operation)
Executes the given runnable asynchronously on the AWT event dispatching thread.

Parameters:
operation - runnable to be invoked asynchronously on the AWT event dispatching thread.
See Also:
SwingUtilities.invokeLater(java.lang.Runnable)

executeSynchron

protected void executeSynchron(java.lang.Runnable operation)
                        throws java.lang.InterruptedException,
                               java.lang.reflect.InvocationTargetException
Executes the given runnable synchronously on the AWT event dispatching thread.

Parameters:
operation - runnable to be invoked synchronously on the AWT event dispatching thread.
Throws:
java.lang.InterruptedException - if another thread has interrupted this thread.
java.lang.reflect.InvocationTargetException - if an exception is thrown when running runnable.
See Also:
SwingUtilities.invokeAndWait(java.lang.Runnable)

hideWaitCursor

protected void hideWaitCursor()
Hides the wait cursor.


showWaitCursor

protected void showWaitCursor()
Shows the wait cursor to indicate a long-running operation. Keyboard and mouse input will be blocked.



Copyright © 1997-2005 Jalopy. All Rights Reserved.