Search in sources :

Example 11 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class EnginesController method deleteEngine.

private void deleteEngine(EngineDTO engineDTO, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"" + engineDTO.getCategory() + "\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
        final ScriptObjectMirror wine = (ScriptObjectMirror) output;
        wine.callMember("delete", engineDTO.getCategory(), engineDTO.getSubCategory(), engineDTO.getVersion(), engineDTO.getUserData());
    }, errorCallback), errorCallback);
}
Also used : Files(java.nio.file.Files) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) LoggerFactory(org.slf4j.LoggerFactory) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) IOException(java.io.IOException) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) AppsController(org.phoenicis.javafx.controller.apps.AppsController) File(java.io.File) Platform(javafx.application.Platform) Consumer(java.util.function.Consumer) List(java.util.List) EngineDTO(org.phoenicis.engines.dto.EngineDTO) EnginesSource(org.phoenicis.engines.EnginesSource) EngineCategoryDTO(org.phoenicis.engines.dto.EngineCategoryDTO) ViewEngines(org.phoenicis.javafx.views.mainwindow.engines.ViewEngines) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) ConfirmMessage(org.phoenicis.javafx.views.common.ConfirmMessage) URI(java.net.URI) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) Path(java.nio.file.Path) ThemeManager(org.phoenicis.javafx.views.common.ThemeManager) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 12 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

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;
}
Also used : ConsoleTab(org.phoenicis.javafx.views.mainwindow.console.ConsoleTab) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 13 with InteractiveScriptSession

use of org.phoenicis.scripts.interpreter.InteractiveScriptSession in project POL-POM-5 by PlayOnLinux.

the class ShortcutRunner method run.

public void run(ShortcutDTO shortcutDTO, List<String> arguments, Consumer<Exception> errorCallback) {
    final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
    interactiveScriptSession.eval("include([\"Functions\", \"Shortcuts\", \"Reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> {
        final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output;
        shortcutReader.callMember("of", shortcutDTO);
        shortcutReader.callMember("run", arguments);
    }, errorCallback), errorCallback);
}
Also used : Consumer(java.util.function.Consumer) List(java.util.List) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Aggregations

InteractiveScriptSession (org.phoenicis.scripts.interpreter.InteractiveScriptSession)13 Consumer (java.util.function.Consumer)12 ScriptInterpreter (org.phoenicis.scripts.interpreter.ScriptInterpreter)12 List (java.util.List)11 ScriptObjectMirror (jdk.nashorn.api.scripting.ScriptObjectMirror)11 IOException (java.io.IOException)10 LoggerFactory (org.slf4j.LoggerFactory)10 File (java.io.File)9 Logger (org.slf4j.Logger)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 WinePrefixContainerDTO (org.phoenicis.containers.dto.WinePrefixContainerDTO)6 RegistryParameter (org.phoenicis.containers.wine.parameters.RegistryParameter)6 LibraryManager (org.phoenicis.library.LibraryManager)6 ShortcutManager (org.phoenicis.library.ShortcutManager)6 ShortcutCategoryDTO (org.phoenicis.library.dto.ShortcutCategoryDTO)6 FileUtilities (org.phoenicis.tools.files.FileUtilities)6 OperatingSystemFetcher (org.phoenicis.tools.system.OperatingSystemFetcher)6 TerminalOpener (org.phoenicis.tools.system.terminal.TerminalOpener)6 RegistryWriter (org.phoenicis.win32.registry.RegistryWriter)6