Class DynamicCommandInfo
- java.lang.Object
-
- org.scijava.AbstractBasicDetails
-
- org.scijava.AbstractUIDetails
-
- org.scijava.module.AbstractModuleInfo
-
- org.scijava.module.DefaultMutableModuleInfo
-
- org.scijava.command.DynamicCommandInfo
-
- All Implemented Interfaces:
Comparable<Prioritized>,BasicDetails,Identifiable,Locatable,ModuleInfo,MutableModuleInfo,Named,Prioritized,UIDetails,Validated,Versioned
public class DynamicCommandInfo extends DefaultMutableModuleInfo
Helper class for maintaining aDynamicCommand's associatedModuleInfo.This class wraps a plain
CommandInfoobject (e.g. from theCommandService's index, present due to an @Pluginannotation on theDynamicCommandclass), delegating to it for theUIDetailsmethods. The plainCommandInfocannot be used as-is, however, because we need to override theModuleInfomethods as well as provide metadata manipulation functionality such asMutableModuleInfo.addInput(ModuleItem).- Author:
- Curtis Rueden
-
-
Field Summary
-
Fields inherited from interface org.scijava.UIDetails
APPLICATION_MENU_ROOT
-
-
Constructor Summary
Constructors Constructor Description DynamicCommandInfo(CommandInfo info, Class<? extends DynamicCommand> moduleClass)
-
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.StringgetDescription()Gets a string describing the object.StringgetIconPath()Gets the resource path to an icon representing the object.StringgetInitializer()Gets the function that is called to initialize the module's values.protected FieldgetInputField(String name)StringgetLabel()Gets the name to appear in a UI, if applicable.MenuPathgetMenuPath()Gets the path to the object's suggested position in the menu structure.StringgetMenuRoot()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.StringgetName()Gets the name of the object.protected FieldgetOutputField(String name)doublegetPriority()Gets the sort priority of the object.List<ValidityProblem>getProblems()Gets the list of problems encountered while initializing the object.StringgetSelectionGroup()Gets the name of the selection group to which the object belongs.StringgetTitle()Gets an appropriate title for the object, for use in a user interface.booleanisEnabled()Gets whether the object should be enabled in the user interface.booleanisInteractive()Gets whether the module is intended to be run interactively.booleanisSelectable()Gets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.booleanisSelected()Gets whether the object is selected (e.g., its menu item is checked) in the user interface.booleanisValid()Gets whether the object is completely valid (i.e., no problems during initialization).voidsetDescription(String description)Sets a string describing the object.voidsetEnabled(boolean enabled)Sets whether the object should be enabled in the user interface.voidsetIconPath(String iconPath)Sets the resource path to an icon representing the object.voidsetLabel(String label)Sets the name to appear in a UI, if applicable.voidsetMenuPath(MenuPath menuPath)Sets the path to the object's suggested position in the menu structure.voidsetMenuRoot(String menuRoot)Sets the name of the menu structure to which the object belongs.voidsetName(String name)Sets the name of the object.voidsetPriority(double priority)Sets the sort priority of the object.voidsetSelectable(boolean selectable)Sets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.voidsetSelected(boolean selected)Sets whether the object is selected (e.g., its menu item is checked) in the user interface.voidsetSelectionGroup(String selectionGroup)Sets the name of the selection group to which the object belongs.-
Methods inherited from class org.scijava.module.DefaultMutableModuleInfo
addInput, addOutput, getModuleClass, removeInput, removeOutput, setModuleClass
-
Methods inherited from class org.scijava.module.AbstractModuleInfo
clearParameters, getInput, getInput, getOutput, getOutput, inputList, inputMap, inputs, outputList, outputMap, outputs, parseParameters, registerInput, registerOutput
-
Methods inherited from class org.scijava.AbstractUIDetails
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.BasicDetails
get, is, set
-
Methods inherited from interface org.scijava.module.ModuleInfo
canRunHeadless, getIdentifier, getInput, getInput, getLocation, getOutput, getOutput, getVersion, inputs, outputs, update
-
Methods inherited from interface org.scijava.module.MutableModuleInfo
createModule, getDelegateClassName, loadDelegateClass
-
Methods inherited from interface org.scijava.UIDetails
compareTo, isVisible, setVisible
-
-
-
-
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), aClassCastExceptionwill be thrown. However, this method is always safe to call for inputs declared using the @Parameternotation ofCommands; it is only unsafe when called to retrieve inputs added dynamically usingDefaultMutableModuleInfo.addInput(ModuleItem), where theModuleItemin question was of unknown (i.e., potentially non-mutable) origin.- Throws:
ClassCastException- if input is not aMutableModuleItem.
-
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), aClassCastExceptionwill be thrown. However, this method is always safe to call for outputs declared using the @Parameternotation ofCommands; it is only unsafe when called to retrieve outputs added dynamically usingDefaultMutableModuleInfo.addInput(ModuleItem), where theModuleItemin question was of unknown (i.e., potentially non-mutable) origin.- Throws:
ClassCastException- if output is not aMutableModuleItem.
-
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.
-
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.
-
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.
-
getInitializer
public String getInitializer()
Description copied from interface:ModuleInfoGets the function that is called to initialize the module's values.
-
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
-
getMenuPath
public MenuPath getMenuPath()
Description copied from interface:UIDetailsGets the path to the object's suggested position in the menu structure.- Specified by:
getMenuPathin interfaceUIDetails- Overrides:
getMenuPathin classAbstractUIDetails
-
getMenuRoot
public String getMenuRoot()
Description copied from interface:UIDetailsGets the name of the menu structure to which the object belongs.- Specified by:
getMenuRootin interfaceUIDetails- Overrides:
getMenuRootin classAbstractUIDetails
-
getIconPath
public String getIconPath()
Description copied from interface:UIDetailsGets the resource path to an icon representing the object.- Specified by:
getIconPathin interfaceUIDetails- Overrides:
getIconPathin classAbstractUIDetails
-
getPriority
public double getPriority()
Description copied from interface:PrioritizedGets the sort priority of the object.- Specified by:
getPriorityin interfacePrioritized- Overrides:
getPriorityin classAbstractUIDetails- See Also:
Priority
-
isSelectable
public boolean isSelectable()
Description copied from interface:UIDetailsGets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.- Specified by:
isSelectablein interfaceUIDetails- Overrides:
isSelectablein classAbstractUIDetails
-
getSelectionGroup
public String getSelectionGroup()
Description copied from interface:UIDetailsGets 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:
getSelectionGroupin interfaceUIDetails- Overrides:
getSelectionGroupin classAbstractUIDetails
-
isSelected
public boolean isSelected()
Description copied from interface:UIDetailsGets whether the object is selected (e.g., its menu item is checked) in the user interface.- Specified by:
isSelectedin interfaceUIDetails- Overrides:
isSelectedin classAbstractUIDetails
-
isEnabled
public boolean isEnabled()
Description copied from interface:UIDetailsGets whether the object should be enabled in the user interface.- Specified by:
isEnabledin interfaceUIDetails- Overrides:
isEnabledin classAbstractUIDetails
-
setMenuPath
public void setMenuPath(MenuPath menuPath)
Description copied from interface:UIDetailsSets the path to the object's suggested position in the menu structure.- Specified by:
setMenuPathin interfaceUIDetails- Overrides:
setMenuPathin classAbstractUIDetails
-
setMenuRoot
public void setMenuRoot(String menuRoot)
Description copied from interface:UIDetailsSets the name of the menu structure to which the object belongs.- Specified by:
setMenuRootin interfaceUIDetails- Overrides:
setMenuRootin classAbstractUIDetails
-
setIconPath
public void setIconPath(String iconPath)
Description copied from interface:UIDetailsSets the resource path to an icon representing the object.- Specified by:
setIconPathin interfaceUIDetails- Overrides:
setIconPathin classAbstractUIDetails
-
setPriority
public void setPriority(double priority)
Description copied from interface:PrioritizedSets the sort priority of the object.- Specified by:
setPriorityin interfacePrioritized- Overrides:
setPriorityin classAbstractUIDetails- See Also:
Priority
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:UIDetailsSets whether the object should be enabled in the user interface.- Specified by:
setEnabledin interfaceUIDetails- Overrides:
setEnabledin classAbstractUIDetails
-
setSelectable
public void setSelectable(boolean selectable)
Description copied from interface:UIDetailsSets whether the object can be selected (e.g., checking and unchecking its menu item) in the user interface.- Specified by:
setSelectablein interfaceUIDetails- Overrides:
setSelectablein classAbstractUIDetails
-
setSelectionGroup
public void setSelectionGroup(String selectionGroup)
Description copied from interface:UIDetailsSets 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:
setSelectionGroupin interfaceUIDetails- Overrides:
setSelectionGroupin classAbstractUIDetails
-
setSelected
public void setSelected(boolean selected)
Description copied from interface:UIDetailsSets whether the object is selected (e.g., its menu item is checked) in the user interface.- Specified by:
setSelectedin interfaceUIDetails- Overrides:
setSelectedin classAbstractUIDetails
-
getLabel
public String getLabel()
Description copied from interface:BasicDetailsGets the name to appear in a UI, if applicable.- Specified by:
getLabelin interfaceBasicDetails- Overrides:
getLabelin classAbstractBasicDetails
-
getDescription
public String getDescription()
Description copied from interface:BasicDetailsGets a string describing the object.- Specified by:
getDescriptionin interfaceBasicDetails- Overrides:
getDescriptionin classAbstractBasicDetails
-
setLabel
public void setLabel(String label)
Description copied from interface:BasicDetailsSets the name to appear in a UI, if applicable.- Specified by:
setLabelin interfaceBasicDetails- Overrides:
setLabelin classAbstractBasicDetails
-
setDescription
public void setDescription(String description)
Description copied from interface:BasicDetailsSets a string describing the object.- Specified by:
setDescriptionin interfaceBasicDetails- Overrides:
setDescriptionin classAbstractBasicDetails
-
getName
public String getName()
Description copied from interface:NamedGets the name of the object.- Specified by:
getNamein interfaceNamed- Overrides:
getNamein classAbstractBasicDetails
-
setName
public void setName(String name)
Description copied from interface:NamedSets the name of the object.- Specified by:
setNamein interfaceNamed- Overrides:
setNamein classAbstractBasicDetails
-
isValid
public boolean isValid()
Description copied from interface:ValidatedGets whether the object is completely valid (i.e., no problems during initialization).
-
getProblems
public List<ValidityProblem> getProblems()
Description copied from interface:ValidatedGets the list of problems encountered while initializing the object.- Returns:
- The list of problems, or a zero-length list in the case of
Validated.isValid()returning true.
-
-