use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project phoenicis by PhoenicisOrg.
the class WinePrefixContainerController method changeSetting.
public void changeSetting(WinePrefixContainerDTO winePrefix, RegistryParameter setting, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
final String registryPatch = registryWriter.generateRegFileContent(setting.toRegistryPatch());
LOGGER.info("Updating registry for prefix: " + winePrefix.getPath());
LOGGER.info(registryPatch);
interactiveScriptSession.eval("include([\"Engines\", \"Wine\", \"Engine\", \"Object\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("prefix", winePrefix.getName());
final ScriptObjectMirror regedit = (ScriptObjectMirror) wine.callMember("regedit");
regedit.callMember("patch", registryPatch);
wine.callMember("wait");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project phoenicis by PhoenicisOrg.
the class WinePrefixContainerController method runInContainer.
public void runInContainer(ContainerDTO container, String command, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Engines\", \"" + container.getEngine() + "\", \"Engine\", \"Object\"]);", ignored -> interactiveScriptSession.eval("new " + container.getEngine() + "()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("prefix", container.getName());
wine.callMember("run", command);
wine.callMember("wait");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project phoenicis by PhoenicisOrg.
the class ConsoleController method createConsole.
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;
}
Aggregations