use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class LibraryFeaturePanel method uninstallShortcut.
/**
* Removes a given shortcut
*
* @param shortcut The shortcut to be removed
*/
public void uninstallShortcut(ShortcutDTO shortcut) {
final String shortcutName = shortcut.getInfo().getName();
final SimpleConfirmDialog confirmMessage = SimpleConfirmDialog.builder().withTitle(tr("Uninstall {0}", shortcutName)).withMessage(tr("Are you sure you want to uninstall {0}?", shortcutName)).withOwner(getScene().getWindow()).withResizable(true).withYesCallback(() -> getShortcutManager().uninstallFromShortcut(shortcut, e -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error while uninstalling {0}", shortcutName)).withException(e).withOwner(getScene().getWindow()).build();
errorDialog.showAndWait();
})).build();
confirmMessage.showAndCallback();
}
use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class LibraryFeaturePanel method createShortcut.
/**
* Creates a new shortcut
*
* @param shortcutCreationDTO DTO describing the new shortcut
*/
public void createShortcut(ShortcutCreationDTO shortcutCreationDTO) {
// get container
// TODO: smarter way using container manager
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", "");
// TODO: better way to get engine ID
final String engineId = engine.toLowerCase();
final String container = split[1];
final InteractiveScriptSession interactiveScriptSession = getScriptInterpreter().createInteractiveSession();
final String scriptInclude = "const Shortcut = include(\"engines." + engineId + ".shortcuts." + engineId + "\");";
interactiveScriptSession.eval(scriptInclude, ignored -> interactiveScriptSession.eval("new Shortcut()", output -> {
final Value shortcutObject = (Value) output;
shortcutObject.invokeMember("name", shortcutCreationDTO.getName());
shortcutObject.invokeMember("category", shortcutCreationDTO.getCategory());
shortcutObject.invokeMember("description", shortcutCreationDTO.getDescription());
shortcutObject.invokeMember("miniature", shortcutCreationDTO.getMiniature());
shortcutObject.invokeMember("search", shortcutCreationDTO.getExecutable().getName());
shortcutObject.invokeMember("prefix", container);
shortcutObject.invokeMember("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();
}));
}
use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class LibraryController method showError.
private void showError(Exception e) {
Platform.runLater(() -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withOwner(getView().getScene().getWindow()).withException(e).withMessage(tr("Unable to load library, please try again.")).build();
errorDialog.showAndWait();
});
}
use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class EnginesController method fetchEngineSubcategories.
/**
* Fetches all engine subcategories that belong to a given list of engine categories
*
* @param engineCategories The engine categories
* @param result The temporary transport variable
* @param callback A callback method, which is called after all engine subcategories have been fetched
*/
private void fetchEngineSubcategories(Queue<EngineCategoryDTO> engineCategories, Map<EngineCategoryDTO, List<EngineSubCategoryDTO>> result, Consumer<Map<EngineCategoryDTO, List<EngineSubCategoryDTO>>> callback) {
final Queue<EngineCategoryDTO> queue = new ArrayDeque<>(engineCategories);
if (queue.isEmpty()) {
// recursion anchor
callback.accept(result);
} else {
final EngineCategoryDTO engineCategory = queue.poll();
final String engineId = engineCategory.getName().toLowerCase();
enginesManager.fetchAvailableVersions(engineId, versions -> {
// recursively process the remaining engine categories
fetchEngineSubcategories(queue, ImmutableMap.<EngineCategoryDTO, List<EngineSubCategoryDTO>>builder().putAll(result).put(engineCategory, versions).build(), callback);
}, e -> Platform.runLater(() -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error")).withException(e).withOwner(this.enginesView.getContent().getScene().getWindow()).build();
errorDialog.showAndWait();
}));
}
}
use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class ContainerToolsPanelSkin method createToolsContainer.
/**
* Creates the container for the tool buttons
*
* @return The container with the tool buttons
*/
private TilePane createToolsContainer() {
final TilePane toolsContainer = new TilePane();
final Button runExecutable = new Button(tr("Run executable"));
runExecutable.getStyleClass().addAll("toolButton", "runExecutable");
runExecutable.setOnMouseClicked(event -> {
getControl().setLockTools(true);
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(tr("Choose executable..."));
// open in container directory if it exists
final File containerDir = new File(getControl().getContainer().getPath());
if (containerDir.canRead()) {
fileChooser.setInitialDirectory(containerDir);
}
final File file = fileChooser.showOpenDialog(getControl().getScene().getWindow());
if (file != null) {
final ContainerDTO container = getControl().getContainer();
final String engineId = container.getEngine().toLowerCase();
getControl().getEnginesManager().getEngine(engineId, engine -> {
engine.setWorkingContainer(container.getName());
engine.run(file.getAbsolutePath(), new String[0], container.getPath(), false, true, new HashMap<>());
getControl().setLockTools(false);
}, exception -> Platform.runLater(() -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error")).withOwner(getControl().getScene().getWindow()).withException(exception).build();
errorDialog.showAndWait();
}));
} else {
// unlock if file chooser is closed
getControl().setLockTools(false);
}
});
toolsContainer.getChildren().add(runExecutable);
return toolsContainer;
}
Aggregations