Package sc.fiji.snt.gui
Class ScriptInstaller
java.lang.Object
sc.fiji.snt.gui.ScriptInstaller
Utility class for discovery of SNT scripts
- Author:
- Tiago Ferreira
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringfillRecipe(String recipeName, Map<String, ?> values) Loads a recipe and replaces its#{KEY}placeholders.Returns a UI list of SNT's 'Batch' scriptsstatic StringgetBoilerplateScript(String extension) Returns a UI list with all the bundled non-demo SNT scriptsgetScriptsMenu(Pattern excludePattern, String... directories) Returns a UI list with the bundled SNT scripts (specified directories only).static StringloadRecipe(String recipeName) Loads a recipe from thescript_templates/Neuroanatomy/Recipes/resource directory.static voidOpens a recipe in the Script Editor after replacing its placeholders (seefillRecipe(java.lang.String, java.util.Map<java.lang.String, ?>))static voidvoidopenScript(String folder, String name) static booleanRuns the specified script known toScriptService.voidstatic boolean
-
Field Details
-
DEMO_SCRIPT
Pattern to match demo scripts (case-insensitive) -
NON_DEMO_SCRIPT
Pattern to match non-demo scripts (case-insensitive)
-
-
Constructor Details
-
ScriptInstaller
-
-
Method Details
-
getScriptsDir
-
getBatchScriptsMenu
Returns a UI list of SNT's 'Batch' scripts -
getScriptsMenu
Returns a UI list with all the bundled non-demo SNT scripts -
getScriptsMenu
Returns a UI list with the bundled SNT scripts (specified directories only).- Parameters:
excludePattern- the exclusion pattern (e.g.,DEMO_SCRIPT). Null allowed.directories- the subset of directories (e.g., Analysis, Batch, etc.)- Returns:
- the scripts menu
-
openScript
- Throws:
IllegalArgumentException
-
runScript
- Throws:
IllegalArgumentException
-
newScript
-
loadRecipe
Loads a recipe from thescript_templates/Neuroanatomy/Recipes/resource directory. The template note (the block delimited by// >>> TEMPLATE-NOTEand// <<< TEMPLATE-NOTE) is removed- Parameters:
recipeName- the file name, e.g., "BigViewerRecording.groovy"- Returns:
- the script contents
- Throws:
IOException- if the recipe could not be read
-
fillRecipe
Loads a recipe and replaces its#{KEY}placeholders. Numbers are inserted as is. Other values are inserted as text escaped for a single-quoted string (backslashes and single quotes), so the template must quote string placeholders itself- Parameters:
recipeName- the file name, e.g., "ChannelUnmixing.groovy"values- the value of each placeholder- Returns:
- the script contents
- Throws:
IOException- if the recipe could not be readIllegalStateException- if the recipe has placeholders without a value
-
newRecipe
public static void newRecipe(String recipeName, Map<String, ?> values, String scriptName) throws IOExceptionOpens a recipe in the Script Editor after replacing its placeholders (seefillRecipe(java.lang.String, java.util.Map<java.lang.String, ?>))- Parameters:
recipeName- the file name, e.g., "ChannelUnmixing.groovy"values- the value of each placeholder. Null if the recipe has nonescriptName- the name of the new script (with extension). Null to use the recipe name- Throws:
IOException- if the recipe could not be readIllegalStateException- if the recipe has placeholders without a value
-
getBoilerplateScript
-
runScript
-
runScript
Runs the specified script known toScriptService.- Parameters:
scriptPath- the script path as registered in ScriptService, (e.g., File/Open_Samples/Comparing_Lengths.ijm or File > Open Samples > Comparing Lengths)- Returns:
- whether the script was executed
-