Package org.scijava.command
Class DynamicCommand
- java.lang.Object
-
- org.scijava.module.AbstractModule
-
- org.scijava.module.DefaultMutableModule
-
- org.scijava.command.DynamicCommand
-
- All Implemented Interfaces:
Runnable,Cancelable,Command,Contextual,Module,MutableModule,SciJavaPlugin
- Direct Known Subclasses:
Inputs,InteractiveCommand,OptionsPlugin
public abstract class DynamicCommand extends DefaultMutableModule implements Cancelable, Command, Contextual
A command with a variable number of inputs and outputs. This class provides greater configurability, but also greater complexity, than implementing theCommandinterface and using only @Parameterannotations on instance fields.- Author:
- Curtis Rueden
-
-
Field Summary
Fields Modifier and Type Field Description protected ModuleServicemoduleServiceprotected PluginServicepluginService
-
Constructor Summary
Constructors Constructor Description DynamicCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel(String reason)Cancels the operation execution, with the given reason for doing so.Contextcontext()Gets the application context to which the object belongs.StringgetCancelReason()Gets a message describing why the operation was canceled.ContextgetContext()Gets the application context to which the object belongs, or null ifContextual.setContext(Context)has not yet been called on this object.DynamicCommandInfogetInfo()Gets metadata about this module.ObjectgetInput(String name)Gets the value of the input with the given name.ObjectgetOutput(String name)Gets the value of the output with the given name.booleanisCanceled()Gets whether the operation has been canceled.protected voidsaveInputs()Persists current input values.voidsetContext(Context context)Sets the application context to which the object belongs.voidsetInput(String name, Object value)Sets the value of the input with the given name.voidsetOutput(String name, Object value)Sets the value of the output with the given name.voiduncancel()-
Methods inherited from class org.scijava.module.AbstractModule
cancel, getDelegateObject, getInputs, getOutputs, initialize, isInputResolved, isOutputResolved, preview, resolveInput, resolveOutput, setInputs, setOutputs, unresolveInput, unresolveOutput
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.scijava.module.Module
cancel, getDelegateObject, getInputs, getOutputs, initialize, isInputResolved, isOutputResolved, isResolved, preview, resolveInput, resolveOutput, setInputs, setOutputs, setResolved, unresolveInput, unresolveOutput
-
Methods inherited from interface org.scijava.module.MutableModule
addInput, addInput, addOutput, addOutput, removeInput, removeOutput, run
-
-
-
-
Field Detail
-
pluginService
protected PluginService pluginService
-
moduleService
protected ModuleService moduleService
-
-
Method Detail
-
getInfo
public DynamicCommandInfo getInfo()
Description copied from interface:ModuleGets metadata about this module.- Specified by:
getInfoin interfaceModule- Specified by:
getInfoin interfaceMutableModule- Overrides:
getInfoin classDefaultMutableModule
-
getInput
public Object getInput(String name)
Description copied from interface:ModuleGets the value of the input with the given name.- Specified by:
getInputin interfaceModule- Overrides:
getInputin classAbstractModule
-
getOutput
public Object getOutput(String name)
Description copied from interface:ModuleGets the value of the output with the given name.- Specified by:
getOutputin interfaceModule- Overrides:
getOutputin classAbstractModule
-
setInput
public void setInput(String name, Object value)
Description copied from interface:ModuleSets the value of the input with the given name.- Specified by:
setInputin interfaceModule- Overrides:
setInputin classAbstractModule
-
setOutput
public void setOutput(String name, Object value)
Description copied from interface:ModuleSets the value of the output with the given name.- Specified by:
setOutputin interfaceModule- Overrides:
setOutputin classAbstractModule
-
context
public Context context()
Description copied from interface:ContextualGets the application context to which the object belongs.- Specified by:
contextin interfaceContextual- See Also:
Contextual.getContext()
-
getContext
public Context getContext()
Description copied from interface:ContextualGets the application context to which the object belongs, or null ifContextual.setContext(Context)has not yet been called on this object.- Specified by:
getContextin interfaceContextual- See Also:
Contextual.context()
-
setContext
public void setContext(Context context)
Description copied from interface:ContextualSets the application context to which the object belongs.Typically this method simply delegates to
Context.inject(Object), and should be called only once to populate the context. Most contextual objects do not support later alteration of the context, and will throwIllegalStateExceptionif this method is invoked again.- Specified by:
setContextin interfaceContextual- See Also:
Context.inject(Object)
-
isCanceled
public boolean isCanceled()
Description copied from interface:CancelableGets whether the operation has been canceled.- Specified by:
isCanceledin interfaceCancelable
-
cancel
public void cancel(String reason)
Description copied from interface:CancelableCancels the operation execution, with the given reason for doing so.This method merely sets the operation status to canceled; it cannot necessarily stop the operation itself. That is, it is the responsibility of each individual operation to check
Cancelable.isCanceled()in a timely manner during execution, and stop doing whatever it is doing if the flag has been tripped.- Specified by:
cancelin interfaceCancelable- Parameters:
reason- A message describing why the operation is being canceled.
-
getCancelReason
public String getCancelReason()
Description copied from interface:CancelableGets a message describing why the operation was canceled.- Specified by:
getCancelReasonin interfaceCancelable- Returns:
- The reason for cancelation, which may be null if no reason was given, or if the operation was not in fact canceled.
-
uncancel
public void uncancel()
-
saveInputs
protected void saveInputs()
Persists current input values. Use e.g. forInteractiveCommands that want to persist values as they change, since interactive commands do not complete the module execution lifecycle normally.
-
-