@Override public InteractiveScriptSession createInteractiveSession() { final InteractiveScriptSession interactiveScriptSession = delegated.createInteractiveSession(); return (evaluation, responseCallback, errorCallback) -> { executorService.execute(() -> interactiveScriptSession.eval(evaluation, responseCallback, errorCallback)); }; } }
/** * fetches the required engine * @param engineId engine ID (e.g. "wine") * @param doneCallback callback which will be executed with the fetched engine * @param errorCallback callback which will be executed if an error occurs */ public void getEngine(String engineId, Consumer<Engine> doneCallback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"engine\", \"implementation\"]); new Engine();", output -> { final Engine engine = (Engine) output; doneCallback.accept(engine); }, errorCallback); }
/** * fetches the required setting * @param engineId setting ID (e.g. "glsl") * @param settingId setting ID (e.g. "glsl") * @param doneCallback callback which will be executed with the fetched setting * @param errorCallback callback which will be executed if an error occurs */ public void getSetting(String engineId, String settingId, Consumer<EngineSetting> doneCallback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"settings\", \"" + settingId + "\"]); new Setting();", output -> { final EngineSetting setting = (EngineSetting) output; doneCallback.accept(setting); }, errorCallback); }
/** * runs a tool in a given container * @param engineId ID of the engine which provides the tool (e.g. "Wine") * @param container name of the container * @param toolId ID of the tool * @param doneCallback callback executed after the script ran * @param errorCallback callback executed in case of an error */ public void runTool(String engineId, String container, String toolId, Runnable doneCallback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"tools\", \"" + toolId + "\"]);", ignored -> interactiveScriptSession.eval("new Tool()", output -> { final EngineTool toolObject = (EngineTool) output; toolObject.run(container); doneCallback.run(); }, errorCallback), errorCallback); }
/** * installs a Verb in a given container * @param engineId ID of the engine which provides the Verb (e.g. "Wine") * @param container name of the container * @param verbId ID of the Verb * @param doneCallback callback executed after the script ran * @param errorCallback callback executed in case of an error */ public void installVerb(String engineId, String container, String verbId, Runnable doneCallback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"verbs\", \"" + verbId + "\"]);", ignored -> interactiveScriptSession.eval("new Verb()", output -> { final Verb verbObject = (Verb) output; verbObject.install(container); doneCallback.run(); }, errorCallback), errorCallback); }
public void run(ShortcutDTO shortcutDTO, List<String> arguments, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval("include([\"engines\", \"wine\", \"shortcuts\", \"reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> { final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output; shortcutReader.callMember("of", shortcutDTO); shortcutReader.callMember("run", arguments); }, errorCallback), errorCallback); }
public void stop(ShortcutDTO shortcutDTO, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval("include([\"engines\", \"wine\", \"shortcuts\", \"reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> { final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output; shortcutReader.callMember("of", shortcutDTO); shortcutReader.callMember("stop"); }, errorCallback), errorCallback); }
public void uninstallFromShortcut(ShortcutDTO shortcutDTO, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval("include([\"engines\", \"wine\", \"shortcuts\", \"reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> { final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output; shortcutReader.callMember("of", shortcutDTO); shortcutReader.callMember("uninstall"); }, errorCallback), errorCallback); }
/** * fetches the available engines * @param repositoryDTO * @param callback * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableEngines(RepositoryDTO repositoryDTO, Consumer<Map<String, Engine>> callback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval(this.createFetchScript(repositoryDTO), output -> callback.accept((Map<String, Engine>) output), errorCallback); }
/** * fetches the available engine settings * @param repositoryDTO * @param callback * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableEngineSettings(RepositoryDTO repositoryDTO, Consumer<Map<String, List<EngineSetting>>> callback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval(this.createFetchScript(repositoryDTO), output -> callback.accept((Map<String, List<EngineSetting>>) output), errorCallback); }
final InteractiveScriptSession interactiveScriptSession = this.scriptInterpreter .createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"shortcuts\", \"reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> { final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output; shortcutReader.callMember("of", shortcutDTO);
public ConsoleTab createConsole() { final ConsoleTab consoleTab = consoleTabFactory.createInstance(); final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); consoleTab.setOnSendCommand(command -> { consoleTab.appendTextToConsole("> " + command + "\n", ConsoleTextType.NORMAL); consoleTab.disableCommand(); interactiveScriptSession.eval(command, result -> { consoleTab.appendTextToConsole(result == null ? "null\n" : result.toString() + "\n"); consoleTab.enableCommand(); }, error -> { consoleTab.appendTextToConsole(ExceptionUtils.getFullStackTrace(error), ConsoleTextType.ERROR); consoleTab.enableCommand(); }); }); return consoleTab; } }