Package org.scijava.command
Class ModuleCommand
- java.lang.Object
-
- org.scijava.module.AbstractModule
-
- org.scijava.command.ModuleCommand
-
- All Implemented Interfaces:
Runnable,Cancelable,Command,Contextual,Module,SciJavaPlugin
public abstract class ModuleCommand extends AbstractModule implements Cancelable, Command, Contextual
A command which implementsModuledirectly (rather than using theCommandModuleadapter class). This is useful for commands which want to inspect and manipulate their own inputs and outputs programmatically.- Author:
- Curtis Rueden
-
-
Constructor Summary
Constructors Constructor Description ModuleCommand()
-
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.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.CommandInfogetInfo()Gets metadata about this module.booleanisCanceled()Gets whether the operation has been canceled.voidsetContext(Context context)Sets the application context to which the object belongs.-
Methods inherited from class org.scijava.module.AbstractModule
cancel, getDelegateObject, getInput, getInputs, getOutput, getOutputs, initialize, isInputResolved, isOutputResolved, preview, resolveInput, resolveOutput, setInput, setInputs, setOutput, 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.Contextual
context
-
Methods inherited from interface org.scijava.module.Module
isResolved, setResolved
-
-
-
-
Method Detail
-
getInfo
public CommandInfo getInfo()
Description copied from interface:ModuleGets metadata about this module.
-
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.
-
-