Source:
public void createShortcut(ShortcutCreationDTO shortcutCreationDTO) { final String executablePath = shortcutCreationDTO.getExecutable().getAbsolutePath(); final String pathInContainers = executablePath.replace(getContainersPath(), ""); final String[] split = pathInContainers.split("/"); final String engineContainer = split[0]; final String engine = StringUtils.capitalize(engineContainer).replace("prefix", ""); final String engineId = engine.toLowerCase(); final String container = split[1]; final InteractiveScriptSession interactiveScriptSession = getScriptInterpreter().createInteractiveSession(); final String scriptInclude = "include(\"engines." + engineId + "\".shortcuts." + engineId + "\");"; interactiveScriptSession.eval(scriptInclude, ignored -> interactiveScriptSession.eval("new " + engine + "Shortcut()", output -> { final ScriptObjectMirror shortcutObject = (ScriptObjectMirror) output; shortcutObject.callMember("name", shortcutCreationDTO.getName()); shortcutObject.callMember("category", shortcutCreationDTO.getCategory()); shortcutObject.callMember("description", shortcutCreationDTO.getDescription()); shortcutObject.callMember("miniature", shortcutCreationDTO.getMiniature()); shortcutObject.callMember("search", shortcutCreationDTO.getExecutable().getName()); shortcutObject.callMember("prefix", container); shortcutObject.callMember("create"); }, e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error while creating shortcut")) .withException(e) .withOwner(getScene().getWindow()) .build(); errorDialog.showAndWait(); })), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error while creating shortcut")) .withException(e) .withOwner(getScene().getWindow()) .build(); errorDialog.showAndWait(); })); }

Target:
public void createShortcut(ShortcutCreationDTO shortcutCreationDTO) { final String executablePath = shortcutCreationDTO.getExecutable().getAbsolutePath(); final String pathInContainers = executablePath.replace(getContainersPath(), ""); final String[] split = pathInContainers.split("/"); final String engineContainer = split[0]; final String engine = StringUtils.capitalize(engineContainer).replace("prefix", ""); final String engineId = engine.toLowerCase(); final String container = split[1]; final InteractiveScriptSession interactiveScriptSession = getScriptInterpreter().createInteractiveSession(); final String scriptInclude = "include(\"engines." + engineId + ".shortcuts." + engineId + "\");"; interactiveScriptSession.eval(scriptInclude, ignored -> interactiveScriptSession.eval("new " + engine + "Shortcut()", output -> { final ScriptObjectMirror shortcutObject = (ScriptObjectMirror) output; shortcutObject.callMember("name", shortcutCreationDTO.getName()); shortcutObject.callMember("category", shortcutCreationDTO.getCategory()); shortcutObject.callMember("description", shortcutCreationDTO.getDescription()); shortcutObject.callMember("miniature", shortcutCreationDTO.getMiniature()); shortcutObject.callMember("search", shortcutCreationDTO.getExecutable().getName()); shortcutObject.callMember("prefix", container); shortcutObject.callMember("create"); }, e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error while creating shortcut")) .withException(e) .withOwner(getScene().getWindow()) .build(); errorDialog.showAndWait(); })), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error while creating shortcut")) .withException(e) .withOwner(getScene().getWindow()) .build(); errorDialog.showAndWait(); })); }