Search in sources :

Example 11 with ErrorDialog

use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.

the class ContainersFeaturePanel method changeEngineVersion.

/**
 * Opens a dialog to change the engine version used for a given container
 *
 * @param container The container
 */
public void changeEngineVersion(final ContainerDTO container) {
    EnginesManager enginesManager = getEnginesManager();
    if (enginesManager != null) {
        final String engineId = container.getEngine().toLowerCase();
        enginesManager.getEngine(engineId, engine -> engine.changeVersion(container.getName()), exception -> Platform.runLater(() -> {
            final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error during engine version change")).withException(exception).withOwner(getScene().getWindow()).build();
            errorDialog.showAndWait();
        }));
    }
}
Also used : ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) EnginesManager(org.phoenicis.engines.EnginesManager)

Example 12 with ErrorDialog

use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.

the class ContainersFeaturePanel method openFileBrowser.

/**
 * Opens the given container in a file browser
 *
 * @param container The container
 */
public void openFileBrowser(final ContainerDTO container) {
    try {
        final File containerDir = new File(container.getPath());
        EventQueue.invokeLater(() -> {
            try {
                Desktop.getDesktop().open(containerDir);
            } catch (IOException e) {
                Platform.runLater(() -> {
                    final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Cannot open container {0} in file browser", container.getPath())).withException(e).withOwner(getScene().getWindow()).build();
                    errorDialog.showAndWait();
                });
            }
        });
    } catch (IllegalArgumentException e) {
        Platform.runLater(() -> {
            final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Cannot open container {0} in file browser", container.getPath())).withException(e).withOwner(getScene().getWindow()).build();
            errorDialog.showAndWait();
        });
    }
}
Also used : ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) IOException(java.io.IOException) File(java.io.File)

Example 13 with ErrorDialog

use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.

the class ContainersFeaturePanel method deleteContainer.

/**
 * Deletes a given container
 *
 * @param container The container
 */
public void deleteContainer(final ContainerDTO container) {
    final SimpleConfirmDialog confirmMessage = SimpleConfirmDialog.builder().withTitle(tr("Delete {0} container", container.getName())).withMessage(tr("Are you sure you want to delete the {0} container?", container.getName())).withOwner(getScene().getWindow()).withYesCallback(() -> {
        getContainersManager().deleteContainer(container, unused -> Platform.runLater(() -> setSelectedContainer(null)), e -> Platform.runLater(() -> {
            final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error")).withException(e).withOwner(getScene().getWindow()).build();
            errorDialog.showAndWait();
        }));
        getContainersManager().fetchContainers(containerCategories -> Platform.runLater(() -> categories.setAll(containerCategories)), e -> Platform.runLater(() -> {
            final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Loading containers failed.")).withException(e).withOwner(getScene().getWindow()).build();
            errorDialog.showAndWait();
        }));
    }).build();
    confirmMessage.showAndCallback();
}
Also used : FeaturePanel(org.phoenicis.javafx.components.common.control.FeaturePanel) EngineToolsManager(org.phoenicis.engines.EngineToolsManager) EnginesManager(org.phoenicis.engines.EnginesManager) ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) FXCollections(javafx.collections.FXCollections) ContainersFeaturePanelSkin(org.phoenicis.javafx.components.container.skin.ContainersFeaturePanelSkin) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) None(org.phoenicis.javafx.components.common.panelstates.None) EngineSetting(org.phoenicis.engines.EngineSetting) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) ContainersManager(org.phoenicis.containers.ContainersManager) VerbsManager(org.phoenicis.engines.VerbsManager) ObjectProperty(javafx.beans.property.ObjectProperty) ContainersFilter(org.phoenicis.javafx.views.mainwindow.containers.ContainersFilter) IOException(java.io.IOException) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) ObservableMap(javafx.collections.ObservableMap) File(java.io.File) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Platform(javafx.application.Platform) java.awt(java.awt) List(java.util.List) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) OpenDetailsPanel(org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel) ObservableList(javafx.collections.ObservableList) SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog)

Example 14 with ErrorDialog

use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PhoenicisOrg.

the class ContainerVerbsPanelSkin method createVerbManagementButtons.

/**
 * Creates a container with the buttons for the verb selection management. These buttons consist of:
 * - a button to install all selected verbs
 * - a button to clear/reset the selection
 *
 * @param verbs The {@link GridPane} containing the visual verb installation components
 * @return A container with the buttons for the verb selection management
 */
private HBox createVerbManagementButtons(final GridPane verbs) {
    final Button installButton = new Button(tr("Install selected"));
    installButton.disableProperty().bind(getControl().lockVerbsProperty());
    installButton.setOnAction(event -> {
        getControl().setLockVerbs(true);
        final ContainerDTO container = getControl().getContainer();
        // find the ids of all selected verbs
        final List<ScriptDTO> installationVerbs = verbs.getChildren().stream().filter(element -> element instanceof CheckBox && ((CheckBox) element).isSelected()).map(GridPane::getRowIndex).map(getControl().getVerbScripts()::get).collect(Collectors.toList());
        final List<String> verbNames = installationVerbs.stream().map(ScriptDTO::getScriptName).collect(Collectors.toList());
        final ListConfirmDialog confirmDialog = ListConfirmDialog.builder().withTitle(tr("Install Verbs")).withMessage(tr("Are you sure you want to install the following Verbs:")).withConfirmItems(verbNames).withOwner(getControl().getScene().getWindow()).withYesCallback(() -> {
            final List<String> verbIds = installationVerbs.stream().map(ScriptDTO::getId).collect(Collectors.toList());
            // install the selected verbs
            getControl().getVerbsManager().installVerbs(container.getEngine().toLowerCase(), container.getName(), verbIds, () -> getControl().setLockVerbs(false), e -> Platform.runLater(() -> {
                final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error installing Verbs")).withException(e).build();
                errorDialog.showAndWait();
            }));
        }).build();
        confirmDialog.showAndCallback();
        // after the dialog has been closed unlock the verb buttons
        getControl().setLockVerbs(false);
    });
    final Button clearButton = new Button(tr("Clear selection"));
    clearButton.disableProperty().bind(getControl().lockVerbsProperty());
    clearButton.setOnAction(event -> verbs.getChildren().stream().filter(element -> element instanceof CheckBox).map(element -> (CheckBox) element).forEach(verbCheckBox -> verbCheckBox.setSelected(false)));
    return new HBox(installButton, clearButton);
}
Also used : Button(javafx.scene.control.Button) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) ContainerVerbsPanel(org.phoenicis.javafx.components.container.control.ContainerVerbsPanel) CheckBox(javafx.scene.control.CheckBox) ListConfirmDialog(org.phoenicis.javafx.dialogs.ListConfirmDialog) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) List(java.util.List) ScrollPane(javafx.scene.control.ScrollPane) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) GridPane(javafx.scene.layout.GridPane) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ListConfirmDialog(org.phoenicis.javafx.dialogs.ListConfirmDialog) HBox(javafx.scene.layout.HBox) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) GridPane(javafx.scene.layout.GridPane) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) Button(javafx.scene.control.Button) CheckBox(javafx.scene.control.CheckBox) List(java.util.List)

Example 15 with ErrorDialog

use of org.phoenicis.javafx.dialogs.ErrorDialog in project POL-POM-5 by PlayOnLinux.

the class ContainerVerbsPanelSkin method createVerbManagementButtons.

/**
 * Creates a container with the buttons for the verb selection management. These buttons consist of:
 * - a button to install all selected verbs
 * - a button to clear/reset the selection
 *
 * @param verbs The {@link GridPane} containing the visual verb installation components
 * @return A container with the buttons for the verb selection management
 */
private HBox createVerbManagementButtons(final GridPane verbs) {
    final Button installButton = new Button(tr("Install selected"));
    installButton.disableProperty().bind(getControl().lockVerbsProperty());
    installButton.setOnAction(event -> {
        getControl().setLockVerbs(true);
        final ContainerDTO container = getControl().getContainer();
        // find the ids of all selected verbs
        final List<ScriptDTO> installationVerbs = verbs.getChildren().stream().filter(element -> element instanceof CheckBox && ((CheckBox) element).isSelected()).map(GridPane::getRowIndex).map(getControl().getVerbScripts()::get).collect(Collectors.toList());
        final List<String> verbNames = installationVerbs.stream().map(ScriptDTO::getScriptName).collect(Collectors.toList());
        final ListConfirmDialog confirmDialog = ListConfirmDialog.builder().withTitle(tr("Install Verbs")).withMessage(tr("Are you sure you want to install the following Verbs:")).withConfirmItems(verbNames).withOwner(getControl().getScene().getWindow()).withYesCallback(() -> {
            final List<String> verbIds = installationVerbs.stream().map(ScriptDTO::getId).collect(Collectors.toList());
            // install the selected verbs
            getControl().getVerbsManager().installVerbs(container.getEngine().toLowerCase(), container.getName(), verbIds, () -> getControl().setLockVerbs(false), e -> Platform.runLater(() -> {
                final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error installing Verbs")).withException(e).build();
                errorDialog.showAndWait();
            }));
        }).build();
        confirmDialog.showAndCallback();
        // after the dialog has been closed unlock the verb buttons
        getControl().setLockVerbs(false);
    });
    final Button clearButton = new Button(tr("Clear selection"));
    clearButton.disableProperty().bind(getControl().lockVerbsProperty());
    clearButton.setOnAction(event -> verbs.getChildren().stream().filter(element -> element instanceof CheckBox).map(element -> (CheckBox) element).forEach(verbCheckBox -> verbCheckBox.setSelected(false)));
    return new HBox(installButton, clearButton);
}
Also used : Button(javafx.scene.control.Button) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) ContainerVerbsPanel(org.phoenicis.javafx.components.container.control.ContainerVerbsPanel) CheckBox(javafx.scene.control.CheckBox) ListConfirmDialog(org.phoenicis.javafx.dialogs.ListConfirmDialog) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) List(java.util.List) ScrollPane(javafx.scene.control.ScrollPane) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) GridPane(javafx.scene.layout.GridPane) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ListConfirmDialog(org.phoenicis.javafx.dialogs.ListConfirmDialog) HBox(javafx.scene.layout.HBox) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) GridPane(javafx.scene.layout.GridPane) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) Button(javafx.scene.control.Button) CheckBox(javafx.scene.control.CheckBox) List(java.util.List)

Aggregations

ErrorDialog (org.phoenicis.javafx.dialogs.ErrorDialog)28 Platform (javafx.application.Platform)8 Button (javafx.scene.control.Button)8 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)8 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)6 ContainerDTO (org.phoenicis.containers.dto.ContainerDTO)6 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)6 File (java.io.File)5 SimpleConfirmDialog (org.phoenicis.javafx.dialogs.SimpleConfirmDialog)5 IOException (java.io.IOException)4 Label (javafx.scene.control.Label)4 Tab (javafx.scene.control.Tab)4 EnginesManager (org.phoenicis.engines.EnginesManager)4 List (java.util.List)3 ObjectProperty (javafx.beans.property.ObjectProperty)3 FXCollections (javafx.collections.FXCollections)3 ObservableList (javafx.collections.ObservableList)3 HBox (javafx.scene.layout.HBox)3 Value (org.graalvm.polyglot.Value)3 FeaturePanel (org.phoenicis.javafx.components.common.control.FeaturePanel)3