org.scijava.command
Class CommandInfo

java.lang.Object
  extended by org.scijava.AbstractBasicDetails
      extended by org.scijava.AbstractUIDetails
          extended by org.scijava.plugin.PluginInfo<Command>
              extended by org.scijava.command.CommandInfo
All Implemented Interfaces:
Comparable<Prioritized>, BasicDetails, Identifiable, Instantiable<Command>, ModuleInfo, Prioritized, UIDetails, Validated

public class CommandInfo
extends PluginInfo<Command>
implements ModuleInfo, Identifiable

A collection of metadata about a particular Command.

Unlike its more general superclass PluginInfo, a CommandInfo implements ModuleInfo, allowing it to describe and instantiate the command in Module form.

Author:
Curtis Rueden, Johannes Schindelin, Grant Harris
See Also:
- The interface which provides many methods for interrogating structural details of a {@link Module}., - An adapter class that bridges the gap between ImageJ commands and the rich {@link Module} interface.

Field Summary
 
Fields inherited from interface org.scijava.UIDetails
APPLICATION_MENU_ROOT
 
Constructor Summary
  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.
 
Method Summary
 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().
 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.
 
Methods inherited from class org.scijava.plugin.PluginInfo
getAnnotation, getPluginType, inject, setPluginType
 
Methods inherited from class org.scijava.AbstractUIDetails
compareTo, 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.UIDetails
getIconPath, getMenuPath, getMenuRoot, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setSelectable, setSelected, setSelectionGroup, setVisible
 
Methods inherited from interface org.scijava.BasicDetails
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
 
Methods inherited from interface org.scijava.Prioritized
getPriority, setPriority
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

CommandInfo

public CommandInfo(String className)
Creates a new command metadata object.

Parameters:
className - The name of the class, which must implement Command.

CommandInfo

public CommandInfo(String className,
                   Plugin annotation)
Creates a new command metadata object.

Parameters:
className - The name of the class, which must implement Command.
annotation - The @Plugin annotation to associate with this metadata object.

CommandInfo

public CommandInfo(Class<? extends Command> commandClass)
Creates a new command metadata object.

Parameters:
commandClass - The plugin class, which must implement Command.

CommandInfo

public CommandInfo(Class<? extends Command> commandClass,
                   Plugin annotation)
Creates a new command metadata object.

Parameters:
commandClass - The plugin class, which must implement Command.
annotation - The @Plugin annotation to associate with this metadata object.

CommandInfo

public CommandInfo(PluginInfo<Command> info)
Creates a new command metadata object describing the same command as the given PluginInfo.

Parameters:
info - The plugin metadata to wrap.

CommandInfo

protected CommandInfo(PluginInfo<Command> info,
                      String className,
                      Class<? extends Command> commandClass,
                      Plugin annotation)
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: PluginInfo
Explicitly sets the Class of the item objects.

This is useful if your class is produced by something other than the system classloader.

Overrides:
setPluginClass in class PluginInfo<Command>

getPluginClass

public Class<? extends Command> getPluginClass()
Description copied from class: PluginInfo
Obtains the Class of the item objects, if that class has already been loaded.

Overrides:
getPluginClass in class PluginInfo<Command>
Returns:
The Class, or null if it has not yet been loaded by PluginInfo.loadClass().

getIconURL

public URL getIconURL()
               throws InstantiableException
Description copied from class: PluginInfo
Gets the URL corresponding to the icon resource path.

Overrides:
getIconURL in class PluginInfo<Command>
Throws:
InstantiableException
See Also:
AbstractUIDetails.getIconPath()

toString

public String toString()
Overrides:
toString in class PluginInfo<Command>

getClassName

public String getClassName()
Description copied from interface: Instantiable
Gets the fully qualified name of the Class of the objects that can be created.

Specified by:
getClassName in interface Instantiable<Command>
Overrides:
getClassName in class PluginInfo<Command>

loadClass

public Class<? extends Command> loadClass()
                                   throws InstantiableException
Description copied from interface: Instantiable
Loads the class corresponding to the objects that are created by Instantiable.createInstance().

Note that this class may not be precisely T.class but instead a subclass thereof.

Specified by:
loadClass in interface Instantiable<Command>
Overrides:
loadClass in class PluginInfo<Command>
Throws:
InstantiableException
See Also:
for an example of an {@code Instantiable} type that typically instantiates objects of a subtype of {@code T} rather than {@code T} itself.

createInstance

public Command createInstance()
                       throws InstantiableException
Description copied from interface: Instantiable
Creates an object.

Specified by:
createInstance in interface Instantiable<Command>
Overrides:
createInstance in class PluginInfo<Command>
Throws:
InstantiableException

getInput

public CommandModuleItem<?> getInput(String name)
Description copied from interface: ModuleInfo
Gets the input item with the given name.

Specified by:
getInput in interface ModuleInfo

getInput

public <T> CommandModuleItem<T> getInput(String name,
                                         Class<T> type)
Description copied from interface: ModuleInfo
Gets the input item with the given name and type.

Specified by:
getInput in interface ModuleInfo

getOutput

public CommandModuleItem<?> getOutput(String name)
Description copied from interface: ModuleInfo
Gets the output item with the given name.

Specified by:
getOutput in interface ModuleInfo

getOutput

public <T> CommandModuleItem<T> getOutput(String name,
                                          Class<T> type)
Description copied from interface: ModuleInfo
Gets the output item with the given name and type.

Specified by:
getOutput in interface ModuleInfo

inputs

public Iterable<ModuleItem<?>> inputs()
Description copied from interface: ModuleInfo
Gets the list of input items.

Specified by:
inputs in interface ModuleInfo

outputs

public Iterable<ModuleItem<?>> outputs()
Description copied from interface: ModuleInfo
Gets the list of output items.

Specified by:
outputs in interface ModuleInfo

getDelegateClassName

public String getDelegateClassName()
Description copied from interface: ModuleInfo
Gets the fully qualified name of the class containing the module's actual implementation. By definition, this is the same value returned by 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()).

Specified by:
getDelegateClassName in interface ModuleInfo

createModule

public Module createModule()
                    throws ModuleException
Description copied from interface: ModuleInfo
Instantiates the module described by this module info.

Specified by:
createModule in interface ModuleInfo
Throws:
ModuleException

isInteractive

public boolean isInteractive()
Description copied from interface: ModuleInfo
Gets 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, with Runnable.run() being called whenever any of the values change.

Specified by:
isInteractive in interface ModuleInfo

canPreview

public boolean canPreview()
Description copied from interface: ModuleInfo
Gets whether the module supports previews. A preview is a quick approximation of the results that would be obtained by actually executing the module with Runnable.run(). If this method returns false, then calling Module.preview() will have no effect.

Specified by:
canPreview in interface ModuleInfo

canCancel

public boolean canCancel()
Description copied from interface: ModuleInfo
Gets 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 calling Module.cancel() will have no effect.

Specified by:
canCancel in interface ModuleInfo

canRunHeadless

public boolean canRunHeadless()
Description copied from interface: ModuleInfo
Gets 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:
canRunHeadless in interface ModuleInfo

getInitializer

public String getInitializer()
Description copied from interface: ModuleInfo
Gets the function that is called to initialize the module's values.

Specified by:
getInitializer in interface ModuleInfo

update

public void update(EventService eventService)
Description copied from interface: ModuleInfo
Notifies 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.

For classes implementing this interface directly, this method should publish a ModulesUpdatedEvent to the event bus (see AbstractModuleInfo.update(EventService) for an example).

Specified by:
update in interface ModuleInfo

getTitle

public String getTitle()
Description copied from interface: UIDetails
Gets an appropriate title for the object, for use in a user interface. The result is prioritized as follows:
  1. Item label
  2. Menu path's leaf entry name
  3. Item name
  4. Item's class name, without package prefix

Specified by:
getTitle in interface UIDetails
Overrides:
getTitle in class AbstractUIDetails

isValid

public boolean isValid()
Description copied from interface: Validated
Gets whether the object is completely valid (i.e., no problems during initialization).

Specified by:
isValid in interface Validated

getProblems

public List<ValidityProblem> getProblems()
Description copied from interface: Validated
Gets the list of problems encountered while initializing the object.

Specified by:
getProblems in interface Validated
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: Identifiable
Gets a string intended to function as an identifier for the object.

Specified by:
getIdentifier in interface Identifiable


Copyright © 2009–2014 SciJava. All rights reserved.