use of java.util.function.Consumer in project POL-POM-5 by PlayOnLinux.
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([\"Functions\", \"Engines\", \"Wine\"]);", 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 java.util.function.Consumer in project POL-POM-5 by PlayOnLinux.
the class WinePrefixContainerController method createShortcut.
/**
* creates a shortcut for a given executable in a Wine prefix
* @param winePrefix the Wine prefix
* @param name name which is shown in the library
* @param executable filename of the executable (WineShortcut will search for this file in the given prefix)
* @param doneCallback callback executed after the shortcut has been created
* @param errorCallback callback executed if there is an error
*/
public void createShortcut(WinePrefixContainerDTO winePrefix, String name, String executable, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Functions\", \"Shortcuts\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new WineShortcut()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("name", name);
wine.callMember("search", executable);
wine.callMember("prefix", winePrefix.getName());
wine.callMember("create");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of java.util.function.Consumer in project POL-POM-5 by PlayOnLinux.
the class EnginesController method installEngine.
private void installEngine(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("install", engineDTO.getCategory(), engineDTO.getSubCategory(), engineDTO.getVersion(), engineDTO.getUserData());
}, errorCallback), errorCallback);
}
use of java.util.function.Consumer in project Skree by Skelril.
the class JarResourceLoader method loadFromResources.
public void loadFromResources(Consumer<Function<String, Path>> execute) {
try {
URI uri = getClass().getResource(baseResourcePathName).toURI();
if (uri.getScheme().equals("jar")) {
try (FileSystem fileSystem = getFileSystem(uri)) {
Function<String, Path> providerFunction = (resourceName) -> {
return fileSystem.getPath(baseResourcePathName + resourceName);
};
execute.accept(providerFunction);
}
} else {
execute.accept(Paths::get);
}
} catch (Exception e) {
System.err.println("Error loading: " + baseResourcePathName);
e.printStackTrace();
}
}
use of java.util.function.Consumer in project POL-POM-5 by PlayOnLinux.
the class ShortcutManager method uninstallFromShortcut.
public void uninstallFromShortcut(ShortcutDTO shortcutDTO, 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("uninstall");
}, errorCallback), errorCallback);
}
Aggregations