org.scijava.command
Class DynamicCommandInfo

java.lang.Object
  extended by org.scijava.AbstractBasicDetails
      extended by org.scijava.AbstractUIDetails
          extended by org.scijava.module.AbstractModuleInfo
              extended by org.scijava.module.DefaultMutableModuleInfo
                  extended by org.scijava.command.DynamicCommandInfo
All Implemented Interfaces:
Comparable<Prioritized>, BasicDetails, Identifiable, ModuleInfo, MutableModuleInfo, Prioritized, UIDetails, Validated

public class DynamicCommandInfo
extends DefaultMutableModuleInfo

Helper class for maintaining a DynamicCommand's associated ModuleInfo.

The CommandService has a plain CommandInfo object in its index, populated from the DynamicCommand's @Plugin annotation. So this class adapts that object, delegating to it for the UIDetails methods. The plain CommandInfo cannot be used as-is, however, because we need to override the ModuleInfo methods as well as provide metadata manipulation functionality such as MutableModuleInfo.addInput(ModuleItem).

Author:
Curtis Rueden

Field Summary
 
Fields inherited from interface org.scijava.UIDetails
APPLICATION_MENU_ROOT
 
Constructor Summary
DynamicCommandInfo(CommandInfo info, Class<? extends DynamicCommand> moduleClass)
           
 
Method Summary
 boolean canCancel()
          Gets whether the module condones cancellation.
 boolean canPreview()
          Gets whether the module supports previews.
 String getDescription()
          Gets a string describing the object.
 String getIconPath()
          Gets the resource path to an icon representing the object.
 String getInitializer()
          Gets the function that is called to initialize the module's values.
protected  Field getInputField(String name)
          Gets the Field corresponding to the given @Parameter annotated module input, or null if the input does not exist or was not declared using the @Parameter mechanism.
 String getLabel()
          Gets the name to appear in a UI, if applicable.
 MenuPath getMenuPath()
          Gets the path to the object's suggested position in the menu structure.
 String getMenuRoot()
          Gets the name of the menu structure to which the object belongs.
<T> MutableModuleItem<T>
getMutableInput(String name, Class<T> type)
          Gets the mutable input with the given name and type.
<T> MutableModuleItem<T>
getMutableOutput(String name, Class<T> type)
          Gets the mutable output with the given name and type.
 String getName()
          Gets the unique name of the object.
protected  Field getOutputField(String name)
          Gets the Field corresponding to the given @Parameter annotated module output, or null if the output does not exist or was not declared using the @Parameter mechanism.
 double getPriority()
          Gets the sort priority of the object.
 List<ValidityProblem> getProblems()
          Gets the list of problems encountered while initializing the object.
 String getSelectionGroup()
          Gets the name of the selection group to which the object belongs.
 String getTitle()
          Gets an appropriate title for the object, for use in a user interface.
 boolean isEnabled()
          Gets whether the object should be enabled in the user interface.
 boolean isInteractive()
          Gets whether the module is intended to be run interactively.
 boolean isSelectable()
          Gets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.
 boolean isSelected()
          Gets whether the object is selected (e.g., its menu item is checked) in the user interface.
 boolean isValid()
          Gets whether the object is completely valid (i.e., no problems during initialization).
 void setDescription(String description)
          Sets a string describing the object.
 void setEnabled(boolean enabled)
          Sets whether the object should be enabled in the user interface.
 void setIconPath(String iconPath)
          Sets the resource path to an icon representing the object.
 void setLabel(String label)
          Sets the name to appear in a UI, if applicable.
 void setMenuPath(MenuPath menuPath)
          Sets the path to the object's suggested position in the menu structure.
 void setMenuRoot(String menuRoot)
          Sets the name of the menu structure to which the object belongs.
 void setName(String name)
          Sets the unique name of the object.
 void setPriority(double priority)
          Sets the sort priority of the object.
 void setSelectable(boolean selectable)
          Sets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.
 void setSelected(boolean selected)
          Sets whether the object is selected (e.g., its menu item is checked) in the user interface.
 void setSelectionGroup(String selectionGroup)
          Sets the name of the selection group to which the object belongs.
 
Methods inherited from class org.scijava.module.DefaultMutableModuleInfo
addInput, addOutput, createModule, getDelegateClassName, getModuleClass, loadDelegateClass, removeInput, removeOutput, setModuleClass
 
Methods inherited from class org.scijava.module.AbstractModuleInfo
canRunHeadless, clearParameters, getIdentifier, getInput, getInput, getOutput, getOutput, inputList, inputMap, inputs, outputList, outputMap, outputs, parseParameters, registerInput, registerOutput, update
 
Methods inherited from class org.scijava.AbstractUIDetails
compareTo, isVisible, setVisible, toString
 
Methods inherited from class org.scijava.AbstractBasicDetails
get, is, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.scijava.module.ModuleInfo
canRunHeadless, getInput, getInput, getOutput, getOutput, inputs, outputs, update
 
Methods inherited from interface org.scijava.UIDetails
isVisible, setVisible
 
Methods inherited from interface org.scijava.BasicDetails
get, is, set
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

DynamicCommandInfo

public DynamicCommandInfo(CommandInfo info,
                          Class<? extends DynamicCommand> moduleClass)
Method Detail

getMutableInput

public <T> MutableModuleItem<T> getMutableInput(String name,
                                                Class<T> type)
Gets the mutable input with the given name and type.

If the input is not mutable (i.e., a MutableModuleItem), a ClassCastException will be thrown. However, this method is always safe to call for inputs declared using the @Parameter notation of Commands; it is only unsafe when called to retrieve inputs added dynamically using DefaultMutableModuleInfo.addInput(ModuleItem), where the ModuleItem in question was of unknown (i.e., potentially non-mutable) origin.

Throws:
ClassCastException - if input is not a MutableModuleItem.

getMutableOutput

public <T> MutableModuleItem<T> getMutableOutput(String name,
                                                 Class<T> type)
Gets the mutable output with the given name and type.

If the output is not mutable (i.e., a MutableModuleItem), a ClassCastException will be thrown. However, this method is always safe to call for outputs declared using the @Parameter notation of Commands; it is only unsafe when called to retrieve outputs added dynamically using DefaultMutableModuleInfo.addInput(ModuleItem), where the ModuleItem in question was of unknown (i.e., potentially non-mutable) origin.

Throws:
ClassCastException - if output is not a MutableModuleItem.

getInputField

protected Field getInputField(String name)
Gets the Field corresponding to the given @Parameter annotated module input, or null if the input does not exist or was not declared using the @Parameter mechanism.


getOutputField

protected Field getOutputField(String name)
Gets the Field corresponding to the given @Parameter annotated module output, or null if the output does not exist or was not declared using the @Parameter mechanism.


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
Overrides:
isInteractive in class AbstractModuleInfo

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
Overrides:
canPreview in class AbstractModuleInfo

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
Overrides:
canCancel in class AbstractModuleInfo

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
Overrides:
getInitializer in class AbstractModuleInfo

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 AbstractModuleInfo

getMenuPath

public MenuPath getMenuPath()
Description copied from interface: UIDetails
Gets the path to the object's suggested position in the menu structure.

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

getMenuRoot

public String getMenuRoot()
Description copied from interface: UIDetails
Gets the name of the menu structure to which the object belongs.

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

getIconPath

public String getIconPath()
Description copied from interface: UIDetails
Gets the resource path to an icon representing the object.

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

getPriority

public double getPriority()
Description copied from interface: Prioritized
Gets the sort priority of the object.

Specified by:
getPriority in interface Prioritized
Overrides:
getPriority in class AbstractUIDetails
See Also:
Priority

isSelectable

public boolean isSelectable()
Description copied from interface: UIDetails
Gets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.

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

getSelectionGroup

public String getSelectionGroup()
Description copied from interface: UIDetails
Gets the name of the selection group to which the object belongs. Only one object in a particular selection group can be selected at a time.

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

isSelected

public boolean isSelected()
Description copied from interface: UIDetails
Gets whether the object is selected (e.g., its menu item is checked) in the user interface.

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

isEnabled

public boolean isEnabled()
Description copied from interface: UIDetails
Gets whether the object should be enabled in the user interface.

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

setMenuPath

public void setMenuPath(MenuPath menuPath)
Description copied from interface: UIDetails
Sets the path to the object's suggested position in the menu structure.

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

setMenuRoot

public void setMenuRoot(String menuRoot)
Description copied from interface: UIDetails
Sets the name of the menu structure to which the object belongs.

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

setIconPath

public void setIconPath(String iconPath)
Description copied from interface: UIDetails
Sets the resource path to an icon representing the object.

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

setPriority

public void setPriority(double priority)
Description copied from interface: Prioritized
Sets the sort priority of the object.

Specified by:
setPriority in interface Prioritized
Overrides:
setPriority in class AbstractUIDetails
See Also:
Priority

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: UIDetails
Sets whether the object should be enabled in the user interface.

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

setSelectable

public void setSelectable(boolean selectable)
Description copied from interface: UIDetails
Sets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.

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

setSelectionGroup

public void setSelectionGroup(String selectionGroup)
Description copied from interface: UIDetails
Sets the name of the selection group to which the object belongs. Only one object in a particular selection group can be selected at a time.

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

setSelected

public void setSelected(boolean selected)
Description copied from interface: UIDetails
Sets whether the object is selected (e.g., its menu item is checked) in the user interface.

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

getName

public String getName()
Description copied from interface: BasicDetails
Gets the unique name of the object.

Specified by:
getName in interface BasicDetails
Overrides:
getName in class AbstractBasicDetails

getLabel

public String getLabel()
Description copied from interface: BasicDetails
Gets the name to appear in a UI, if applicable.

Specified by:
getLabel in interface BasicDetails
Overrides:
getLabel in class AbstractBasicDetails

getDescription

public String getDescription()
Description copied from interface: BasicDetails
Gets a string describing the object.

Specified by:
getDescription in interface BasicDetails
Overrides:
getDescription in class AbstractBasicDetails

setName

public void setName(String name)
Description copied from interface: BasicDetails
Sets the unique name of the object.

Specified by:
setName in interface BasicDetails
Overrides:
setName in class AbstractBasicDetails

setLabel

public void setLabel(String label)
Description copied from interface: BasicDetails
Sets the name to appear in a UI, if applicable.

Specified by:
setLabel in interface BasicDetails
Overrides:
setLabel in class AbstractBasicDetails

setDescription

public void setDescription(String description)
Description copied from interface: BasicDetails
Sets a string describing the object.

Specified by:
setDescription in interface BasicDetails
Overrides:
setDescription in class AbstractBasicDetails

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
Overrides:
isValid in class AbstractModuleInfo

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
Overrides:
getProblems in class AbstractModuleInfo
Returns:
The list of problems, or a zero-length list in the case of Validated.isValid() returning true.


Copyright © 2009–2014 SciJava. All rights reserved.