Package org.scijava.command
Class CommandInfo
- java.lang.Object
-
- org.scijava.AbstractBasicDetails
-
- org.scijava.AbstractUIDetails
-
- org.scijava.plugin.PluginInfo<Command>
-
- org.scijava.command.CommandInfo
-
- All Implemented Interfaces:
Comparable<Prioritized>,BasicDetails,Identifiable,Instantiable<Command>,Locatable,ModuleInfo,Named,Prioritized,UIDetails,Validated,Versioned
public class CommandInfo extends PluginInfo<Command> implements ModuleInfo
A collection of metadata about a particularCommand.Unlike its more general superclass
PluginInfo, aCommandInfoimplementsModuleInfo, allowing it to describe and instantiate the command inModuleform.- Author:
- Curtis Rueden, Johannes Schindelin, Grant Harris
- See Also:
- The interface which provides many methods for interrogating structural details of a .,- An adapter class that bridges the gap between s and the rich interface.
-
-
Field Summary
-
Fields inherited from interface org.scijava.UIDetails
APPLICATION_MENU_ROOT
-
-
Constructor Summary
Constructors Modifier Constructor Description CommandInfo(Class<? extends Command> commandClass)Creates a new command metadata object.CommandInfo(Class<? extends Command> commandClass, Plugin annotation)Creates a new command metadata object.CommandInfo(String className)Creates a new command metadata object.CommandInfo(String className, Plugin annotation)Creates a new command metadata object.CommandInfo(PluginInfo<Command> info)Creates a new command metadata object describing the same command as the givenPluginInfo.protectedCommandInfo(PluginInfo<Command> info, String className, Class<? extends Command> commandClass, Plugin annotation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanCancel()Gets whether the module condones cancellation.booleancanPreview()Gets whether the module supports previews.booleancanRunHeadless()Gets whether the module condones headless execution.CommandcreateInstance()Creates an object.ModulecreateModule()Instantiates the module described by this module info.ModulecreateModule(Command commandInstance)Instantiates the module described by this module info, around the specified existing command instance.StringgetClassName()Gets the fully qualified name of theClassof the objects that can be created.StringgetDelegateClassName()Gets the fully qualified name of the class containing the module's actual implementation.URLgetIconURL()Gets the URL corresponding to the icon resource path.StringgetIdentifier()Gets a string intended to function as an identifier for the object.StringgetInitializer()Gets the function that is called to initialize the module's values.CommandModuleItem<?>getInput(String name)Gets the input item with the given name.<T> CommandModuleItem<T>getInput(String name, Class<T> type)Gets the input item with the given name and type.CommandModuleItem<?>getOutput(String name)Gets the output item with the given name.<T> CommandModuleItem<T>getOutput(String name, Class<T> type)Gets the output item with the given name and type.Class<? extends Command>getPluginClass()Obtains theClassof the item objects, if that class has already been loaded.Map<String,Object>getPresets()Gets the table of items with fixed, preset values.List<ValidityProblem>getProblems()Gets the list of problems encountered while initializing the object.StringgetTitle()Gets an appropriate title for the object, for use in a user interface.Iterable<ModuleItem<?>>inputs()Gets the list of input items.booleanisInteractive()Gets whether the module is intended to be run interactively.booleanisValid()Gets whether the object is completely valid (i.e., no problems during initialization).Class<? extends Command>loadClass()Loads the class corresponding to the objects that are created byInstantiable.createInstance().Class<?>loadDelegateClass()Loads the class containing the module's actual implementation.Iterable<ModuleItem<?>>outputs()Gets the list of output items.voidsetPluginClass(Class<? extends Command> pluginClass)Explicitly sets theClassof the item objects.voidsetPresets(Map<String,Object> presets)Sets the table of items with fixed, preset values.StringtoString()voidupdate(EventService eventService)Notifies interested parties that the module info has been modified.-
Methods inherited from class org.scijava.plugin.PluginInfo
create, create, get, get, get, getAnnotation, getLocation, getOrCreate, getOrCreate, getPluginType, getVersion, inject, setPluginType
-
Methods inherited from class org.scijava.AbstractUIDetails
getIconPath, getMenuPath, getMenuRoot, getPriority, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setPriority, setSelectable, setSelected, setSelectionGroup, setVisible
-
Methods inherited from class org.scijava.AbstractBasicDetails
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.scijava.BasicDetails
get, getDescription, getLabel, is, set, setDescription, setLabel
-
Methods inherited from interface org.scijava.module.ModuleInfo
getLocation, getVersion
-
Methods inherited from interface org.scijava.Prioritized
getPriority, setPriority
-
Methods inherited from interface org.scijava.UIDetails
compareTo, getIconPath, getMenuPath, getMenuRoot, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setSelectable, setSelected, setSelectionGroup, setVisible
-
-
-
-
Constructor Detail
-
CommandInfo
public CommandInfo(String className)
Creates a new command metadata object.- Parameters:
className- The name of the class, which must implementCommand.
-
CommandInfo
public CommandInfo(String className, Plugin annotation)
Creates a new command metadata object.
-
CommandInfo
public CommandInfo(Class<? extends Command> commandClass)
Creates a new command metadata object.- Parameters:
commandClass- The plugin class, which must implementCommand.
-
CommandInfo
public CommandInfo(Class<? extends Command> commandClass, Plugin annotation)
Creates a new command metadata object.
-
CommandInfo
public CommandInfo(PluginInfo<Command> info)
Creates a new command metadata object describing the same command as the givenPluginInfo.- Parameters:
info- The plugin metadata to wrap.
-
-
Method Detail
-
setPresets
public void setPresets(Map<String,Object> presets)
Sets the table of items with fixed, preset values.
-
getPresets
public Map<String,Object> getPresets()
Gets the table of items with fixed, preset values.
-
createModule
public Module createModule(Command commandInstance)
Instantiates the module described by this module info, around the specified existing command instance.
-
setPluginClass
public void setPluginClass(Class<? extends Command> pluginClass)
Description copied from class:PluginInfoExplicitly sets theClassof the item objects.This is useful if your class is produced by something other than the system classloader.
- Overrides:
setPluginClassin classPluginInfo<Command>
-
getPluginClass
public Class<? extends Command> getPluginClass()
Description copied from class:PluginInfoObtains theClassof the item objects, if that class has already been loaded.- Overrides:
getPluginClassin classPluginInfo<Command>- Returns:
- The
Class, or null if it has not yet been loaded byPluginInfo.loadClass().
-
getIconURL
public URL getIconURL() throws InstantiableException
Description copied from class:PluginInfoGets the URL corresponding to the icon resource path.- Overrides:
getIconURLin classPluginInfo<Command>- Throws:
InstantiableException- See Also:
AbstractUIDetails.getIconPath()
-
toString
public String toString()
- Overrides:
toStringin classPluginInfo<Command>
-
getClassName
public String getClassName()
Description copied from interface:InstantiableGets the fully qualified name of theClassof the objects that can be created.- Specified by:
getClassNamein interfaceInstantiable<Command>- Overrides:
getClassNamein classPluginInfo<Command>
-
loadClass
public Class<? extends Command> loadClass() throws InstantiableException
Description copied from interface:InstantiableLoads the class corresponding to the objects that are created byInstantiable.createInstance().Note that this class may not be precisely
T.classbut instead a subclass thereof.- Specified by:
loadClassin interfaceInstantiable<Command>- Overrides:
loadClassin classPluginInfo<Command>- Throws:
InstantiableException- See Also:
for an example of an type that typically instantiates objects of a subtype of rather than itself.
-
createInstance
public Command createInstance() throws InstantiableException
Description copied from interface:InstantiableCreates an object.- Specified by:
createInstancein interfaceInstantiable<Command>- Overrides:
createInstancein classPluginInfo<Command>- Throws:
InstantiableException
-
getInput
public CommandModuleItem<?> getInput(String name)
Description copied from interface:ModuleInfoGets the input item with the given name.- Specified by:
getInputin interfaceModuleInfo
-
getInput
public <T> CommandModuleItem<T> getInput(String name, Class<T> type)
Description copied from interface:ModuleInfoGets the input item with the given name and type.- Specified by:
getInputin interfaceModuleInfo
-
getOutput
public CommandModuleItem<?> getOutput(String name)
Description copied from interface:ModuleInfoGets the output item with the given name.- Specified by:
getOutputin interfaceModuleInfo
-
getOutput
public <T> CommandModuleItem<T> getOutput(String name, Class<T> type)
Description copied from interface:ModuleInfoGets the output item with the given name and type.- Specified by:
getOutputin interfaceModuleInfo
-
inputs
public Iterable<ModuleItem<?>> inputs()
Description copied from interface:ModuleInfoGets the list of input items.- Specified by:
inputsin interfaceModuleInfo
-
outputs
public Iterable<ModuleItem<?>> outputs()
Description copied from interface:ModuleInfoGets the list of output items.- Specified by:
outputsin interfaceModuleInfo
-
getDelegateClassName
public String getDelegateClassName()
Description copied from interface:ModuleInfoGets the fully qualified name of the class containing the module's actual implementation. By definition, this is the same value returned bycreateModule().getDelegateObject().getClass().getName(), and hence is also the class containing any callback methods specified byModuleItem.getCallback().The nature of this method is implementation-specific; for example, a
CommandModulewill return the class name of its associatedCommand. For modules that are not commands, the result may be something else.If you are implementing this interface directly, a good rule of thumb is to return the class name of the associated
Module(i.e., the same value given bycreateModule().getClass().getName()).- Specified by:
getDelegateClassNamein interfaceModuleInfo
-
loadDelegateClass
public Class<?> loadDelegateClass() throws ClassNotFoundException
Description copied from interface:ModuleInfoLoads the class containing the module's actual implementation. The name of the loaded class will match the value returned byModuleInfo.getDelegateClassName().- Specified by:
loadDelegateClassin interfaceModuleInfo- Throws:
ClassNotFoundException- See Also:
Instantiable.loadClass()
-
createModule
public Module createModule() throws ModuleException
Description copied from interface:ModuleInfoInstantiates the module described by this module info.- Specified by:
createModulein interfaceModuleInfo- Throws:
ModuleException
-
isInteractive
public boolean isInteractive()
Description copied from interface:ModuleInfoGets whether the module is intended to be run interactively. Typically this means its inputs are supposed to be presented in a non-modal dialog box, withRunnable.run()being called whenever any of the values change.- Specified by:
isInteractivein interfaceModuleInfo
-
canPreview
public boolean canPreview()
Description copied from interface:ModuleInfoGets whether the module supports previews. A preview is a quick approximation of the results that would be obtained by actually executing the module withRunnable.run(). If this method returns false, then callingModule.preview()will have no effect.- Specified by:
canPreviewin interfaceModuleInfo
-
canCancel
public boolean canCancel()
Description copied from interface:ModuleInfoGets whether the module condones cancellation. Strictly speaking, any module execution can be canceled during preprocessing, but this flag is a hint that doing so may be a bad idea, and the UI may want to disallow it. If this method returns false, then callingModule.cancel()will have no effect.- Specified by:
canCancelin interfaceModuleInfo
-
canRunHeadless
public boolean canRunHeadless()
Description copied from interface:ModuleInfoGets whether the module condones headless execution. Strictly speaking, there is no guarantee that any module will work headless just because it declares itself so, but this flag hints that headless execution is likely to succeed (if flag is true), or fail (if flag is false).- Specified by:
canRunHeadlessin interfaceModuleInfo
-
getInitializer
public String getInitializer()
Description copied from interface:ModuleInfoGets the function that is called to initialize the module's values.- Specified by:
getInitializerin interfaceModuleInfo
-
update
public void update(EventService eventService)
Description copied from interface:ModuleInfoNotifies interested parties that the module info has been modified. This mechanism is useful for updating any corresponding user interface such as menu items that are linked to the module.- Specified by:
updatein interfaceModuleInfo
-
getTitle
public String getTitle()
Description copied from interface:UIDetailsGets an appropriate title for the object, for use in a user interface. The result is prioritized as follows:- Item label
- Menu path's leaf entry name
- Item name
- Item's class name, without package prefix
- Specified by:
getTitlein interfaceModuleInfo- Specified by:
getTitlein interfaceUIDetails
-
isValid
public boolean isValid()
Description copied from interface:ValidatedGets whether the object is completely valid (i.e., no problems during initialization).- Specified by:
isValidin interfaceModuleInfo- Specified by:
isValidin interfaceValidated
-
getProblems
public List<ValidityProblem> getProblems()
Description copied from interface:ValidatedGets the list of problems encountered while initializing the object.- Specified by:
getProblemsin interfaceModuleInfo- Specified by:
getProblemsin interfaceValidated- Returns:
- The list of problems, or a zero-length list in the case of
Validated.isValid()returning true.
-
getIdentifier
public String getIdentifier()
Description copied from interface:IdentifiableGets a string intended to function as an identifier for the object.- Specified by:
getIdentifierin interfaceIdentifiable- Specified by:
getIdentifierin interfaceModuleInfo- Overrides:
getIdentifierin classPluginInfo<Command>
-
-