Package gov.nih.mipav.model.scripting
Class ScriptableActionLoader
java.lang.Object
gov.nih.mipav.model.scripting.ScriptableActionLoader
Given the name of a script action, this class searches a number of locations for a class to load with that name and
returns a new instance of that class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionTry MIPAV dialogs, then special script actions, then plugins (which are in the default package). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddScriptActionLocation(String packageString) Adds a new package where we should look for scriptable actions.protected static ClassattemptLoadFromPackage(String packageString, String action) Trys to load a action's class, searching in a specific package.static final ScriptableActionInterfacegetScriptableAction(String action) Returns a new instance of the class associated with a given script action.Gets the script action location vector, needed for figuring out the possible short name of a non-MIPAV scriptable tool.protected static ClassTrys to find and load an action's corresponding class from a list of package prefixes.
-
Field Details
-
SCRIPT_ACTION_LOCATIONS
Try MIPAV dialogs, then special script actions, then plugins (which are in the default package).
-
-
Constructor Details
-
ScriptableActionLoader
public ScriptableActionLoader()
-
-
Method Details
-
getScriptableAction
public static final ScriptableActionInterface getScriptableAction(String action) throws ParserException Returns a new instance of the class associated with a given script action.- Parameters:
action- The action to search for a class of.- Returns:
- A new instance of a script action's class.
- Throws:
ParserException- If an associated class was not found or could not be loaded.
-
attemptLoadFromPackage
protected static Class attemptLoadFromPackage(String packageString, String action) throws ParserException Trys to load a action's class, searching in a specific package.- Parameters:
packageString- The prefix to append to the action before trying to load it (may be a package, a package and a class name prefix, or empty for the default package).action- The script action to search for.- Returns:
- The action's corresponding class, from the given package prefix.
- Throws:
ParserException- If the action's class could not be found or loaded from the given package prefix.
-
loadClass
Trys to find and load an action's corresponding class from a list of package prefixes. The first place where a suitable class is found is the one returned.- Parameters:
action- The script action to search for.- Returns:
- The action's corresponding class, found using one of the package prefixes.
- Throws:
ParserException- If the action's class could not be found or loaded from any of the script action locations.
-
addScriptActionLocation
Adds a new package where we should look for scriptable actions. To be used to register the package paths used by more complex plugins (probably called from the plugin run() method).- Parameters:
packageString- The java package in which to look for scriptable actions.
-
getScriptActionLocations
Gets the script action location vector, needed for figuring out the possible short name of a non-MIPAV scriptable tool.
-