public abstract class AbstractPluginBase extends AbstractOptionsParser implements IQuimpPlugin
This template provides template of run(String)
method specified in
PlugIn.run(String)
interface that detects context of caller by testing if there is valid
parameter string specified and then sets proper AbstractOptionsParser.errorSink
and
AbstractOptionsParser.apiCall
. Thus depending on context plugin will report errors in
correct place. Using run(String)
errors can be directed to QuimpException.MessageSinkTypes.GUI
or QuimpException.MessageSinkTypes.IJERROR
. For having them in QuimpException.MessageSinkTypes.CONSOLE
override
executer()
or use other method for executing plugin.
QuimpException.handleException(java.awt.Frame, String)
apiCall, errorSink, logger, options
Constructor and Description |
---|
AbstractPluginBase()
This default constructor must be overridden in concrete class.
|
AbstractPluginBase(AbstractPluginOptions options,
String pluginName)
Default constructor.
|
AbstractPluginBase(String argString,
AbstractPluginOptions options,
String pluginName)
Constructor that allows to provide own parameter string.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
executer()
Executed if
run(String) got parsable parameter string. |
void |
run(String arg)
Called on plugin run by ImageJ or from API.
|
void |
setPluginName(String pluginName)
Set plugin name, should be that recognisable by IJ, usually plugins.config.
|
abstract void |
showUi(boolean val)
Open plugin UI.
|
getOptions, parseArgumentString, publishMacroString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
about
public AbstractPluginBase()
AbstractPluginOptions
class should be
created there and then passed to
AbstractOptionsParser.AbstractOptionsParser(AbstractPluginOptions)
. One needs to call
setPluginName(String)
here as well.public AbstractPluginBase(AbstractPluginOptions options, String pluginName)
Set api call to false and assign provided options to object.
options
- Reference to plugin configuration container.pluginName
- name of the plugin that will be displayed in Macro Recorderpublic AbstractPluginBase(String argString, AbstractPluginOptions options, String pluginName) throws QuimpPluginException
Intended to run from API. Set AbstractOptionsParser.apiCall
to true and AbstractOptionsParser.errorSink
to
QuimpException.MessageSinkTypes.CONSOLE
.
AbstractPluginOptions
is initialised from specified string and assigned to this
instance.
argString
- parameters string like that passed in macro. If it is empty string or null
constructor exits before deserialisation.options
- Reference to plugin configuration container.pluginName
- name of the plugin that will be displayed in Macro RecorderQuimpPluginException
- on any error in plugin execution.public void run(String arg)
Overrides PlugIn.run(String)
. If input string is null or empty it sets
AbstractOptionsParser.errorSink
to
QuimpException.MessageSinkTypes.GUI
. Note that AbstractOptionsParser.apiCall
is set by
choosing proper constructor. Then it tries to parse specified parameter string, if it succeeds,
AbstractOptionsParser.options
is set and deserialised and executer()
method is
executed. If parsing fails, showUi(boolean)
is called with option true. If there is
parsable string AbstractOptionsParser.errorSink
is set to
QuimpException.MessageSinkTypes.IJERROR
Finally, macro string is published to ImageJ that represents current state of
AbstractOptionsParser.options
.
All exceptions thrown by plugin logic (from executer()
) are handled here depending
on AbstractOptionsParser.errorSink
value.
run
in interface ij.plugin.PlugIn
AbstractOptionsParser.parseArgumentString(String)
public abstract void showUi(boolean val) throws Exception
Executed if run(String)
could not parse parameters.
val
- true to show UIException
- on any error. Handled by run(String)
protected abstract void executer() throws QuimpException
run(String)
got parsable parameter string.QuimpException
- on any error. Exception is handled depending on
AbstractOptionsParser.errorSink
set by run(String)
public void setPluginName(String pluginName)
pluginName
- the pluginName to setCopyright © 2002–2019 Department of Computer Science, Warwick University. All rights reserved.