public final class ScriptManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ScriptManager.ScriptThread
A
Thread subclass that manages the execution of a Groovy script. |
Constructor and Description |
---|
ScriptManager()
Construct a ScriptManager instance.
|
Modifier and Type | Method and Description |
---|---|
Map<String,groovy.lang.Script> |
getDefaultScripts()
The default scripts.
|
Set<ArrayVEventHandler> |
getEventHandlers(ArrayVEventHandler.EventType eventType)
Get the event handlers for the specified event type
|
groovy.lang.GroovyShell |
getGroovyShell()
The
GroovyShell associated with the script manager |
Map<String,groovy.lang.Script> |
loadDefaultScripts()
Load the default scripts.
|
groovy.lang.Script |
loadScript(File path)
Compile and run the script at the specified path
|
groovy.lang.Script |
loadScript(URL url)
Compile and run the script at the specified URL
|
void |
registerEventHandlers(ArrayVEventHandler... handlers)
Register event handlers.
|
void |
runEventHandlers(ArrayVEventHandler.EventType eventType)
Run the event handlers for the specified event type
|
ScriptManager.ScriptThread |
runInThread(File path)
Compile and run the specified script in a new thread
|
void |
unregisterEventHandlers(ArrayVEventHandler... handlers)
Unegister event handlers.
|
public ScriptManager() throws IllegalStateException
ArrayVisualizer
.
If you wish to get a reference to the ArrayV ScriptManager, use
ArrayVisualizer.getInstance().getScriptManager()
.IllegalStateException
- When you call this constructor.public groovy.lang.GroovyShell getGroovyShell()
GroovyShell
associated with the script managerGroovyShell
public Set<ArrayVEventHandler> getEventHandlers(ArrayVEventHandler.EventType eventType)
eventType
- The type of event to obtain handlers forpublic void runEventHandlers(ArrayVEventHandler.EventType eventType)
eventType
- The type of event to handlepublic void registerEventHandlers(ArrayVEventHandler... handlers)
ArrayVEventHandler.register()
is preferred
over this unless you're registering multiple handlers at once.handlers
- The event handlers to registerpublic void unregisterEventHandlers(ArrayVEventHandler... handlers)
ArrayVEventHandler.unregister()
is preferred
over this unless you're unregistering multiple handlers at once.handlers
- The event handlers to unregisterpublic groovy.lang.Script loadScript(File path) throws IOException
path
- The path of the scriptScript
objectIOException
public groovy.lang.Script loadScript(URL url) throws IOException
url
- The URL of the scriptScript
objectIOException
public ScriptManager.ScriptThread runInThread(File path) throws IOException
path
- The path of the scriptScriptManager.ScriptThread
the script was run inIOException
ScriptManager.ScriptThread
public Map<String,groovy.lang.Script> loadDefaultScripts() throws IOException, IllegalStateException
Load the default scripts. These are the union of the scripts embedded
in the ArrayV JAR and the scripts in the scripts
directory.
This method may only be called once, from ArrayVisualizer
IllegalStateException
- When you call this method.IOException
public Map<String,groovy.lang.Script> getDefaultScripts()
loadDefaultScripts()
for a description
of what default scripts areloadDefaultScripts()
Copyright © 2024. All rights reserved.