org.openjump.test
Class TestToolsTest.ExamplePlugInWithDialog

java.lang.Object
  extended by com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
      extended by org.openjump.test.TestToolsTest.ExamplePlugInWithDialog
All Implemented Interfaces:
PlugIn, ThreadedPlugIn
Enclosing class:
TestToolsTest

public static class TestToolsTest.ExamplePlugInWithDialog
extends AbstractPlugIn
implements ThreadedPlugIn

Fixture that outlines a plugin which accepts parameters in an user dialog. Both an user dialog and a map can be used to provide execution parameters.

Configuration: #execute(PlugInContext) shows a MultiInputDialog, in which the user can set field values. The dialog uses static fields with strings from I18N to name its fields. When the dialog is closed it contains the execution parameters to provide them for operations.

Programmatic configuration: Calling #execute(PlugInContext) can be omitted by providing the execution parameters directly as a new dialog instance using TestTools.configurePlugIn(PlugIn, java.util.Map, boolean). The keys in the map are the names from the static I18N fields.

Execution: All operations take place in #run(TaskMonitor, PlugInContext) which uses the execution parameters provided by the dialog. That means that this method has a dependency to the dialog. To execute operations without showing the user dialog use TestTools.executePlugIn(PlugIn, WorkbenchContext) after the parameters in the dialog were configured.

The only methods allowed to be called on the dialog within the #run method are getText(), getDouble(), getInteger(), getLayer() and getBoolean() in order to use the operations without showing the user dialog.

See Also:
TestTools.configurePlugIn(PlugIn, java.util.Map, boolean), TestTools.executePlugIn(PlugIn, WorkbenchContext)

Constructor Summary
TestToolsTest.ExamplePlugInWithDialog()
           
 
Method Summary
 boolean execute(PlugInContext context)
          Configures plugin.
 void run(TaskMonitor monitor, PlugInContext context)
          Executes operations.
 
Methods inherited from class com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
createName, execute, execute, getName, initialize, isRollingBackInvalidEdits, reportNothingToUndoYet, toActionListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vividsolutions.jump.workbench.plugin.PlugIn
getName, initialize
 

Constructor Detail

TestToolsTest.ExamplePlugInWithDialog

public TestToolsTest.ExamplePlugInWithDialog()
Method Detail

execute

public boolean execute(PlugInContext context)
                throws java.lang.Exception
Configures plugin.

Specified by:
execute in interface PlugIn
Overrides:
execute in class AbstractPlugIn
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

run

public void run(TaskMonitor monitor,
                PlugInContext context)
         throws java.lang.Exception
Executes operations.

Specified by:
run in interface ThreadedPlugIn
Parameters:
monitor - context to which this task can report its progress and check whether a party has requested its cancellation
Throws:
java.lang.Exception