public class CommandInfo extends PluginInfo<Command> implements ModuleInfo
Command
.
Unlike its more general superclass PluginInfo
, a CommandInfo
implements ModuleInfo
, allowing it to describe and instantiate the
command in Module
form.
- The interface which provides many methods for interrogating
structural details of a {@link Module}.
,
- An adapter class that bridges the gap between
{@link Command}s and the rich {@link Module} interface.
APPLICATION_MENU_ROOT
Modifier | Constructor and 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(PluginInfo<Command> info)
Creates a new command metadata object describing the same command as the
given
PluginInfo . |
protected |
CommandInfo(PluginInfo<Command> info,
String className,
Class<? extends Command> commandClass,
Plugin annotation) |
|
CommandInfo(String className)
Creates a new command metadata object.
|
|
CommandInfo(String className,
Plugin annotation)
Creates a new command metadata object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canCancel()
Gets whether the module condones cancellation.
|
boolean |
canPreview()
Gets whether the module supports previews.
|
boolean |
canRunHeadless()
Gets whether the module condones headless execution.
|
Command |
createInstance()
Creates an object.
|
Module |
createModule()
Instantiates the module described by this module info.
|
Module |
createModule(Command commandInstance)
Instantiates the module described by this module info, around the specified
existing command instance.
|
String |
getClassName()
Gets the fully qualified name of the
Class of the objects that can
be created. |
String |
getDelegateClassName()
Gets the fully qualified name of the class containing the module's actual
implementation.
|
URL |
getIconURL()
Gets the URL corresponding to the icon resource path.
|
String |
getIdentifier()
Gets a string intended to function as an identifier for the object.
|
String |
getInitializer()
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 the
Class of 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.
|
String |
getTitle()
Gets an appropriate title for the object, for use in a user interface.
|
Iterable<ModuleItem<?>> |
inputs()
Gets the list of input items.
|
boolean |
isInteractive()
Gets whether the module is intended to be run interactively.
|
boolean |
isValid()
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 by
Instantiable.createInstance() . |
Class<?> |
loadDelegateClass()
Loads the class containing the module's actual implementation.
|
Iterable<ModuleItem<?>> |
outputs()
Gets the list of output items.
|
void |
setPluginClass(Class<? extends Command> pluginClass)
Explicitly sets the
Class of the item objects. |
void |
setPresets(Map<String,Object> presets)
Sets the table of items with fixed, preset values.
|
String |
toString() |
void |
update(EventService eventService)
Notifies interested parties that the module info has been modified.
|
create, create, get, get, get, getAnnotation, getLocation, getOrCreate, getOrCreate, getPluginType, getVersion, inject, setPluginType
getIconPath, getMenuPath, getMenuRoot, getPriority, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setPriority, setSelectable, setSelected, setSelectionGroup, setVisible
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getLocation, getVersion
compareTo, getIconPath, getMenuPath, getMenuRoot, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setSelectable, setSelected, setSelectionGroup, setVisible
get, getDescription, getLabel, is, set, setDescription, setLabel
getPriority, setPriority
public CommandInfo(String className)
className
- The name of the class, which must implement
Command
.public CommandInfo(String className, Plugin annotation)
public CommandInfo(Class<? extends Command> commandClass)
commandClass
- The plugin class, which must implement Command
.public CommandInfo(Class<? extends Command> commandClass, Plugin annotation)
public CommandInfo(PluginInfo<Command> info)
PluginInfo
.info
- The plugin metadata to wrap.public void setPresets(Map<String,Object> presets)
public Map<String,Object> getPresets()
public Module createModule(Command commandInstance)
public void setPluginClass(Class<? extends Command> pluginClass)
PluginInfo
Class
of the item objects.
This is useful if your class is produced by something other than the system classloader.
setPluginClass
in class PluginInfo<Command>
public Class<? extends Command> getPluginClass()
PluginInfo
Class
of the item objects, if that class has already
been loaded.getPluginClass
in class PluginInfo<Command>
Class
, or null if it has not yet been loaded by
PluginInfo.loadClass()
.public URL getIconURL() throws InstantiableException
PluginInfo
getIconURL
in class PluginInfo<Command>
InstantiableException
AbstractUIDetails.getIconPath()
public String toString()
toString
in class PluginInfo<Command>
public String getClassName()
Instantiable
Class
of the objects that can
be created.getClassName
in interface Instantiable<Command>
getClassName
in class PluginInfo<Command>
public Class<? extends Command> loadClass() throws InstantiableException
Instantiable
Instantiable.createInstance()
.
Note that this class may not be precisely T.class
but instead a
subclass thereof.
loadClass
in interface Instantiable<Command>
loadClass
in class PluginInfo<Command>
InstantiableException
for an example of an
{@code Instantiable} type that typically instantiates objects of a
subtype of {@code T} rather than {@code T} itself.
public Command createInstance() throws InstantiableException
Instantiable
createInstance
in interface Instantiable<Command>
createInstance
in class PluginInfo<Command>
InstantiableException
public CommandModuleItem<?> getInput(String name)
ModuleInfo
getInput
in interface ModuleInfo
public <T> CommandModuleItem<T> getInput(String name, Class<T> type)
ModuleInfo
getInput
in interface ModuleInfo
public CommandModuleItem<?> getOutput(String name)
ModuleInfo
getOutput
in interface ModuleInfo
public <T> CommandModuleItem<T> getOutput(String name, Class<T> type)
ModuleInfo
getOutput
in interface ModuleInfo
public Iterable<ModuleItem<?>> inputs()
ModuleInfo
inputs
in interface ModuleInfo
public Iterable<ModuleItem<?>> outputs()
ModuleInfo
outputs
in interface ModuleInfo
public String getDelegateClassName()
ModuleInfo
createModule().getDelegateObject().getClass().getName()
, and hence
is also the class containing any callback methods specified by
ModuleItem.getCallback()
.
The nature of this method is implementation-specific; for example, a
CommandModule
will return the class name of its associated
Command
. 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 by createModule().getClass().getName()
).
getDelegateClassName
in interface ModuleInfo
public Class<?> loadDelegateClass() throws ClassNotFoundException
ModuleInfo
ModuleInfo.getDelegateClassName()
.loadDelegateClass
in interface ModuleInfo
ClassNotFoundException
Instantiable.loadClass()
public Module createModule() throws ModuleException
ModuleInfo
createModule
in interface ModuleInfo
ModuleException
public boolean isInteractive()
ModuleInfo
Runnable.run()
being called whenever any of the values change.isInteractive
in interface ModuleInfo
public boolean canPreview()
ModuleInfo
Runnable.run()
. If this method returns false, then
calling Module.preview()
will have no effect.canPreview
in interface ModuleInfo
public boolean canCancel()
ModuleInfo
Module.cancel()
will
have no effect.canCancel
in interface ModuleInfo
public boolean canRunHeadless()
ModuleInfo
canRunHeadless
in interface ModuleInfo
public String getInitializer()
ModuleInfo
getInitializer
in interface ModuleInfo
public void update(EventService eventService)
ModuleInfo
update
in interface ModuleInfo
public String getTitle()
UIDetails
getTitle
in interface ModuleInfo
getTitle
in interface UIDetails
public boolean isValid()
Validated
isValid
in interface ModuleInfo
isValid
in interface Validated
public List<ValidityProblem> getProblems()
Validated
getProblems
in interface ModuleInfo
getProblems
in interface Validated
Validated.isValid()
returning true.public String getIdentifier()
Identifiable
getIdentifier
in interface Identifiable
getIdentifier
in interface ModuleInfo
getIdentifier
in class PluginInfo<Command>
Copyright © 2015–2022 SciJava. All rights reserved.