Package org.omegat.gui.scripting
Class ScriptRunner
java.lang.Object
org.omegat.gui.scripting.ScriptRunner
Scripting window entry point.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringScripts that want to run on the Event Dispatch Thread should define a top-level function with this name and NOT evaluate it.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectexecuteScript(String script, ScriptEngine engine, Map<String, Object> additionalBindings) Execute a script with a given engine and bindings.static StringexecuteScript(String script, ScriptItem item, Map<String, Object> additionalBindings) Execute a script either in string form or, ifscriptis null, as read from the file associated with the suppliedScriptItem.static StringexecuteScript(ScriptItem item, Map<String, Object> additionalBindings) Execute as read from the file associated with the suppliedScriptItem.static List<ScriptEngineFactory>static ScriptEngineManager
-
Field Details
-
SCRIPT_GUI_FUNCTION_NAME
Scripts that want to run on the Event Dispatch Thread should define a top-level function with this name and NOT evaluate it.- See Also:
-
DEFAULT_SCRIPT
- See Also:
-
VAR_CONSOLE
- See Also:
-
VAR_MAINWINDOW
- See Also:
-
VAR_GLOSSARY
- See Also:
-
VAR_CORE
- See Also:
-
VAR_EDITOR
- See Also:
-
VAR_PROJECT
- See Also:
-
VAR_RESOURCES
- See Also:
-
-
Method Details
-
executeScript
public static String executeScript(ScriptItem item, Map<String, Object> additionalBindings) throws IOException, ScriptExceptionExecute as read from the file associated with the suppliedScriptItem. This is a convenience method forAbstractScriptRunner.executeScript(String, ScriptItem, Map).- Parameters:
item- The associatedScriptItem. Must not be null. Ifscriptis null, the script content will be read from the associated file. The script engine will be resolved from the filename. The resource bundle associated with theitemwill be included in the bindings asVAR_RESOURCES.additionalBindings- A map of bindings that will be included along with other bindings- Returns:
- result string.
- Throws:
IOException- when I/O error occurred.ScriptException- when script engine raises error.
-
executeScript
public static String executeScript(String script, ScriptItem item, Map<String, Object> additionalBindings) throws IOException, ScriptExceptionExecute a script either in string form or, ifscriptis null, as read from the file associated with the suppliedScriptItem. The engine is resolved via the filename extension associated withitem(defaults toDEFAULT_SCRIPT).This is a convenience method for
executeScript(String, ScriptEngine, Map).- Parameters:
script- The script in string form. Can be null.item- The associatedScriptItem. Must not be null. Ifscriptis null, the script content will be read from the associated file. The script engine will be resolved from the filename. The resource bundle associated with theitemwill be included in the bindings asVAR_RESOURCES.additionalBindings- A map of bindings that will be included along with other bindings- Returns:
- result string.
- Throws:
IOException- when I/O error occurred.ScriptException- when script engine raises error.
-
getManager
-
getEngineFactories
-
executeScript
public static Object executeScript(String script, ScriptEngine engine, Map<String, Object> additionalBindings) throws ScriptExceptionExecute a script with a given engine and bindings.- Parameters:
script- The script in string formengine- The engineadditionalBindings- A map of bindings that will be included along with other bindings- Returns:
- The evaluation result
- Throws:
ScriptException- when script engine raises error.
-
getAvailableScriptExtensions
-