Search in sources :

Example 71 with ScriptObjectMirror

use of jdk.nashorn.api.scripting.ScriptObjectMirror in project phoenicis by PhoenicisOrg.

the class ShortcutManager method uninstallFromShortcut.

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);
}
Also used : Logger(org.slf4j.Logger) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LoggerFactory(org.slf4j.LoggerFactory) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) File(java.io.File) ShortcutInfoDTO(org.phoenicis.library.dto.ShortcutInfoDTO) Consumer(java.util.function.Consumer) Safe(org.phoenicis.configuration.security.Safe) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) URI(java.net.URI) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 72 with ScriptObjectMirror

use of jdk.nashorn.api.scripting.ScriptObjectMirror 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);
}
Also used : Consumer(java.util.function.Consumer) RegistryWriter(org.phoenicis.win32.registry.RegistryWriter) RegistryParameter(org.phoenicis.containers.wine.parameters.RegistryParameter) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Example 73 with ScriptObjectMirror

use of jdk.nashorn.api.scripting.ScriptObjectMirror 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);
}
Also used : Consumer(java.util.function.Consumer) RegistryWriter(org.phoenicis.win32.registry.RegistryWriter) RegistryParameter(org.phoenicis.containers.wine.parameters.RegistryParameter) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) ScriptObjectMirror(jdk.nashorn.api.scripting.ScriptObjectMirror) InteractiveScriptSession(org.phoenicis.scripts.interpreter.InteractiveScriptSession)

Aggregations

ScriptObjectMirror (jdk.nashorn.api.scripting.ScriptObjectMirror)73 Test (org.junit.Test)34 InteractiveScriptSession (org.phoenicis.scripts.interpreter.InteractiveScriptSession)24 ScriptInterpreter (org.phoenicis.scripts.interpreter.ScriptInterpreter)24 Consumer (java.util.function.Consumer)23 List (java.util.List)20 LoggerFactory (org.slf4j.LoggerFactory)19 File (java.io.File)16 IOException (java.io.IOException)16 Logger (org.slf4j.Logger)13 WinePrefixContainerDTO (org.phoenicis.containers.dto.WinePrefixContainerDTO)12 Map (java.util.Map)10 RegistryParameter (org.phoenicis.containers.wine.parameters.RegistryParameter)10 LibraryManager (org.phoenicis.library.LibraryManager)10 ShortcutManager (org.phoenicis.library.ShortcutManager)10 ShortcutCategoryDTO (org.phoenicis.library.dto.ShortcutCategoryDTO)10 RegistryWriter (org.phoenicis.win32.registry.RegistryWriter)10 ArrayList (java.util.ArrayList)9 Platform (javafx.application.Platform)8 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)8