de.fho.jump.pirol.utilities.plugIns
Class StandardPirolPlugIn

java.lang.Object
  extended by com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
      extended by de.fho.jump.pirol.utilities.plugIns.StandardPirolPlugIn
All Implemented Interfaces:
PlugIn, ErrorHandler

public abstract class StandardPirolPlugIn
extends AbstractPlugIn
implements ErrorHandler

Overrides most of the abstract methods of the AbstractPlugIn to implement a default behavior, that fits the needs for a plugIn in the PIROL context. Also implements the ErrorHandler interface and offers methods to post error messages to the GUI.

Version:
$Rev: 1670 $
Author:
Ole Rahn, Stefan Ostermann

FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement

Field Summary
protected  boolean bringUpMessages
          Are errors to be shown in the statusbar (bringUpMessages = false, DEFAULT) or in an output window (bringUpMessages = true)?
protected static EnableCheckFactory checkFactory
           
protected static com.vividsolutions.jts.geom.GeometryFactory geometryFactory
           
protected  javax.swing.ImageIcon icon
          see description for method getIconString() for more information
protected  PersonalLogger logger
          logger reference for use with the StandardPirolPlugIn.
protected  java.lang.StringBuffer messages
          buffer for messages of errors that occured during execution - needed to implement the ErrorHandler interface
protected  boolean useToolIconSize
           
 
Constructor Summary
StandardPirolPlugIn(PersonalLogger logger)
          Please, use this constructor in the deriving class!
 
Method Summary
static MultiEnableCheck createEnableCheck(WorkbenchContext workbenchContext, boolean needFence)
           
abstract  boolean execute(PlugInContext context)
          This method is called to execute the PlugIn.
protected  boolean finishExecution(PlugInContext context, boolean retVal)
          To be called, when leaving the execute()-method.
 java.lang.String getCategoryName()
          The name of the category, a PlugIn can be found in - this method should be overridden by any derived class!
static Feature[] getFeaturesInFenceOrInLayer(PlugInContext context, Layer layer)
          Get a List of Features (from the given Layer) that reside within the fence (if there is a fence) or just the features of the layer (if there is currently no fence)
 javax.swing.Icon getIcon()
          Method to load an icon from the surrounding jar-file if necessary.
abstract  java.lang.String getIconString()
          Method to enable loading an icon from the surrounding jar-file if necessary.
 PersonalLogger getLogger()
           
static TaskMonitorDialog getMonitor(PlugInContext context)
           
 java.lang.String getName()
          Name of the PlugIn to be shown in the menus or as a tooltip in JUMP.
static Layer getSelectedLayer(PlugInContext context)
          get one Layer that is selected
static Layer[] getSelectedLayers(PlugInContext context, int num)
          Get a given number of selected Layers.
 java.lang.String getShortClassName()
           
 void handleThrowable(java.lang.Throwable t)
          Note that this method may or may not be called from the AWT event-dispatch thread.
 void initialize(PlugInContext context)
          The PlugIn will be added to the PIROL Tools/[return value of getCategoryName()] menu and a standard EnableCheck is applied.
 void initialize(PlugInContext context, java.lang.String subMenuName)
          Deprecated.  
protected  void postMessagesToGui(PlugInContext context)
           
static void println(java.lang.Class c, java.lang.String function, java.lang.String message)
          Deprecated. use logger instead!
protected  void println(java.lang.String function, java.lang.String msg)
          Deprecated. use logger instead!
 void setLogger(PersonalLogger logger)
          Sets the personal logger - enables debug statement handling
 void setUseInToolbox(boolean toolboxUse)
           
static void warnUser(PlugInContext context, java.lang.String msg)
          Puts a warning message into the statusbar of JUMP
 
Methods inherited from class com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
createName, execute, execute, isRollingBackInvalidEdits, reportNothingToUndoYet, toActionListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

messages

protected java.lang.StringBuffer messages
buffer for messages of errors that occured during execution - needed to implement the ErrorHandler interface


bringUpMessages

protected boolean bringUpMessages
Are errors to be shown in the statusbar (bringUpMessages = false, DEFAULT) or in an output window (bringUpMessages = true)?


checkFactory

protected static EnableCheckFactory checkFactory

icon

protected javax.swing.ImageIcon icon
see description for method getIconString() for more information


useToolIconSize

protected boolean useToolIconSize

geometryFactory

protected static com.vividsolutions.jts.geom.GeometryFactory geometryFactory

logger

protected PersonalLogger logger
logger reference for use with the StandardPirolPlugIn. Since loggers are personalized, this member has to be initialized in derived classes by the programmer, before it can be used. For downward compatibility no abstract method or constructur parameter was introduced to do this.

Since:
rev.1.12
Constructor Detail

StandardPirolPlugIn

public StandardPirolPlugIn(PersonalLogger logger)
Please, use this constructor in the deriving class!

Parameters:
logger - the logger that will controll console outputs
Since:
rev.1.17
Method Detail

getShortClassName

public java.lang.String getShortClassName()

createEnableCheck

public static MultiEnableCheck createEnableCheck(WorkbenchContext workbenchContext,
                                                 boolean needFence)

getIconString

public abstract java.lang.String getIconString()
Method to enable loading an icon from the surrounding jar-file if necessary. If the plugin doesn't need an icon, just return null else return the file name, e.g. "xyz.png" and put the picture in the same folder (package) as the deriving class.

Returns:
the filename of the icon or null if the plugin has no icon.

execute

public abstract boolean execute(PlugInContext context)
                         throws java.lang.Exception
This method is called to execute the PlugIn.

Specified by:
execute in interface PlugIn
Overrides:
execute in class AbstractPlugIn
Parameters:
context - the snapshot of the current workbench.
Returns:
always true ?
Throws:
java.lang.Exception
See Also:
AbstractPlugIn.execute(com.vividsolutions.jump.workbench.plugin.PlugInContext)

getName

public java.lang.String getName()
Name of the PlugIn to be shown in the menus or as a tooltip in JUMP.
Looks for a key (the PlugIn's name with no path) in the i18n resources, if none is found the standard jump name generation will be used.

Specified by:
getName in interface PlugIn
Overrides:
getName in class AbstractPlugIn
Returns:
the class name, minus "PlugIn", with spaces inserted at the appropriate point before each uppercase+lowercase and lowercase+uppercase combination.

initialize

public void initialize(PlugInContext context)
                throws java.lang.Exception
The PlugIn will be added to the PIROL Tools/[return value of getCategoryName()] menu and a standard EnableCheck is applied.

Specified by:
initialize in interface PlugIn
Overrides:
initialize in class AbstractPlugIn
Parameters:
context - PlugInContext
Throws:
java.lang.Exception
See Also:
getCategoryName()

getCategoryName

public java.lang.String getCategoryName()
The name of the category, a PlugIn can be found in - this method should be overridden by any derived class!

Returns:
name of the category, a PlugIn can be found in

initialize

public void initialize(PlugInContext context,
                       java.lang.String subMenuName)
                throws java.lang.Exception
Deprecated. 

Standard intialization: PlugIn is added to the PIROL Tools/subMenuName (or localized menu name) menu and a standard EnableCheck is applied.

Throws:
java.lang.Exception

getMonitor

public static TaskMonitorDialog getMonitor(PlugInContext context)
Parameters:
context - the current PlugIn context
Returns:
a TaskMonitorDialog, to show progress information to the user

println

protected void println(java.lang.String function,
                       java.lang.String msg)
Deprecated. use logger instead!

Prints output to the stdout. Can be invoked by deriving classes.

Parameters:
function - the name of the method from within this one is called. E.g. "myMethod()".
msg - the message String.
See Also:
println(Class, String, String)

println

public static void println(java.lang.Class c,
                           java.lang.String function,
                           java.lang.String message)
Deprecated. use logger instead!

Writes the given message and function string to the stdout. The output will be formated as "classname.function: message".

Parameters:
c - the calling class
function - the method from within this one is called.
message - the text with some useful information.

warnUser

public static void warnUser(PlugInContext context,
                            java.lang.String msg)
Puts a warning message into the statusbar of JUMP

Parameters:
context - curr. PlugInContext
msg - message to be shown to the user

getSelectedLayers

public static Layer[] getSelectedLayers(PlugInContext context,
                                        int num)
Get a given number of selected Layers.

Parameters:
context - the current PlugInContext
num - max. number of layers to return, -1 returns all selected layers
Returns:
a given number of selected Layers, null if no Layers are selected

getSelectedLayer

public static Layer getSelectedLayer(PlugInContext context)
get one Layer that is selected

Parameters:
context - the current PlugInContext
Returns:
one selected Layer, null if no Layers are selected

finishExecution

protected boolean finishExecution(PlugInContext context,
                                  boolean retVal)
To be called, when leaving the execute()-method. Puts out the error messages collected during execution if any and returns the given boolean value. Example:
return finishExecution(context, true);

Parameters:
context - the current PlugInContext
retVal - the value to be returned by execute()
Returns:
retVal

postMessagesToGui

protected void postMessagesToGui(PlugInContext context)

handleThrowable

public void handleThrowable(java.lang.Throwable t)
Description copied from interface: ErrorHandler
Note that this method may or may not be called from the AWT event-dispatch thread.

Specified by:
handleThrowable in interface ErrorHandler

getIcon

public javax.swing.Icon getIcon()
Method to load an icon from the surrounding jar-file if necessary.

Returns:
the icon or null if the getIconString() returned null (or problems occured)

getFeaturesInFenceOrInLayer

public static Feature[] getFeaturesInFenceOrInLayer(PlugInContext context,
                                                    Layer layer)
Get a List of Features (from the given Layer) that reside within the fence (if there is a fence) or just the features of the layer (if there is currently no fence)

Parameters:
context - the plugIn context
layer - the layer holding the features
Returns:
List of features within fence if present or just within the layer

getLogger

public PersonalLogger getLogger()
Returns:
the personal logger
See Also:
PersonalLogger

setLogger

public void setLogger(PersonalLogger logger)
Sets the personal logger - enables debug statement handling

Parameters:
logger - the new personal logger
See Also:
PersonalLogger

setUseInToolbox

public void setUseInToolbox(boolean toolboxUse)