use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class EngineInformationPanelSkin method createEngineButtons.
/**
* Creates a new {@link HBox} containing the interaction buttons for selected engine.
* The interaction buttons consist of:
* <ul>
* <li>An install button</li>
* <li>An uninstall button</li>
* </ul>
*
* @return A new {@link HBox} containing the interaction buttons for the selected engine
*/
private HBox createEngineButtons() {
// binding to check whether the currently selected engine is installed
final BooleanBinding engineInstalledProperty = Bindings.createBooleanBinding(() -> {
final Engine engine = getControl().getEngine();
final EngineDTO engineDTO = getControl().getEngineDTO();
if (engine == null || engineDTO == null) {
return true;
}
return engine.isInstalled(engineDTO.getSubCategory(), engineDTO.getVersion());
}, getControl().engineProperty(), getControl().engineDTOProperty());
// the engine install button
final Button installButton = new Button(tr("Install"));
installButton.disableProperty().bind(engineInstalledProperty);
installButton.setOnMouseClicked(evt -> {
try {
Optional.ofNullable(getControl().getOnEngineInstall()).ifPresent(onEngineInstall -> onEngineInstall.accept(getControl().getEngineDTO()));
} catch (IllegalArgumentException e) {
LOGGER.error("Failed to get engine", e);
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("An error occurred while installing the engine")).withOwner(getControl().getScene().getWindow()).withException(e).build();
errorDialog.showAndWait();
}
});
// the engine delete button
final Button deleteButton = new Button(tr("Delete"));
deleteButton.disableProperty().bind(Bindings.not(engineInstalledProperty));
deleteButton.setOnMouseClicked(evt -> {
try {
Optional.ofNullable(getControl().getOnEngineDelete()).ifPresent(onEngineDelete -> onEngineDelete.accept(getControl().getEngineDTO()));
} catch (IllegalArgumentException e) {
LOGGER.error("Failed to get engine", e);
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("An error occurred while deleting the engine")).withOwner(getControl().getScene().getWindow()).withException(e).build();
errorDialog.showAndWait();
}
});
final HBox buttonBox = new HBox(installButton, deleteButton);
buttonBox.getStyleClass().add("engineButtons");
return buttonBox;
}
use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class ApplicationInformationPanelSkin method updateScripts.
/**
* Refreshes the shown scripts.
* When this method is called it begins by clearing the <code>scriptGrid</code>.
* Afterwards this method refills it.
*/
private void updateScripts(final GridPane scriptGrid) {
scriptGrid.getChildren().clear();
for (int i = 0; i < filteredScripts.size(); i++) {
ScriptDTO script = filteredScripts.get(i);
final Label scriptName = new Label(script.getScriptName());
GridPane.setHgrow(scriptName, Priority.ALWAYS);
if (getControl().isShowScriptSource()) {
final Tooltip tooltip = new Tooltip(tr("Source: {0}", script.getScriptSource()));
Tooltip.install(scriptName, tooltip);
}
final Button installButton = new Button(tr("Install"));
installButton.setOnMouseClicked(evt -> {
try {
installScript(script);
} catch (IllegalArgumentException e) {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error while trying to download the installer")).withException(e).build();
errorDialog.showAndWait();
}
});
OperatingSystem curOs = new OperatingSystemFetcher().fetchCurrentOperationSystem();
Label lTesting = new Label();
if (script.getTestingOperatingSystems().contains(curOs)) {
lTesting.getStyleClass().add("testingIcon");
lTesting.setTooltip(new Tooltip(tr("Testing")));
lTesting.setMinSize(30, 30);
}
Label lCommercial = new Label();
if (!script.isFree()) {
lCommercial.getStyleClass().add("commercialIcon");
lCommercial.setTooltip(new Tooltip(tr("Commercial")));
lCommercial.setMinSize(30, 30);
}
Label lPatch = new Label();
if (script.isRequiresPatch()) {
lPatch.getStyleClass().add("patchIcon");
lPatch.setTooltip(new Tooltip(tr("Patch required")));
lPatch.setMinSize(30, 30);
}
Label lOs = new Label();
if (!script.getCompatibleOperatingSystems().contains(curOs)) {
lOs.getStyleClass().add("osIcon");
lOs.setTooltip(new Tooltip(tr("All Operating Systems")));
lOs.setMinSize(30, 30);
}
Label lSpace = new Label();
lSpace.setPrefSize(30, 30);
HBox iconBox = new HBox(lTesting, lCommercial, lPatch, lOs, lSpace);
scriptGrid.addRow(i, scriptName, iconBox, installButton);
}
}
use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.
the class ApplicationInformationPanelSkin method installScript.
/**
* Install the given script
*
* @param script The script to be installed
*/
private void installScript(ScriptDTO script) {
final StringBuilder executeBuilder = new StringBuilder();
executeBuilder.append(String.format("TYPE_ID=\"%s\";\n", script.getTypeId()));
executeBuilder.append(String.format("CATEGORY_ID=\"%s\";\n", script.getCategoryId()));
executeBuilder.append(String.format("APPLICATION_ID=\"%s\";\n", script.getApplicationId()));
executeBuilder.append(String.format("SCRIPT_ID=\"%s\";\n", script.getId()));
executeBuilder.append(script.getScript());
executeBuilder.append("\n");
getControl().getScriptInterpreter().createInteractiveSession().eval(executeBuilder.toString(), result -> {
Value installer = (Value) result;
installer.as(Installer.class).go();
}, e -> Platform.runLater(() -> {
// no exception if installation is cancelled
if (!(e.getCause() instanceof InterruptedException)) {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("The script ended unexpectedly")).withException(e).build();
errorDialog.showAndWait();
}
}));
}
Aggregations