Search in sources :

Example 1 with SimpleConfirmDialog

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

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 2 with SimpleConfirmDialog

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

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();
}
Also used : SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog)

Example 3 with SimpleConfirmDialog

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

the class RepositoriesPanelSkin method createRepositoryButtons.

/**
 * Creates a new container for the repository buttons.
 * These buttons consist of:
 * - an add button
 * - a delete button
 * - a restore defaults button
 *
 * @param repositoryLocationTable The repository location table
 * @return A new container for the repository buttons
 */
private HBox createRepositoryButtons(TableView<RepositoryLocation<? extends Repository>> repositoryLocationTable) {
    final Button addButton = new Button(tr("Add"));
    addButton.getStyleClass().add("repositories-add");
    addButton.setOnAction((ActionEvent event) -> {
        final AddRepositoryDialog dialog = new AddRepositoryDialog();
        dialog.initOwner(getControl().getScene().getWindow());
        final Optional<RepositoryLocation<? extends Repository>> successResult = dialog.showAndWait();
        successResult.ifPresent(repositoryLocation -> getControl().getRepositoryLocations().add(0, repositoryLocation));
    });
    final Button removeButton = new Button(tr("Remove"));
    removeButton.getStyleClass().add("repositories-remove");
    removeButton.setOnAction((ActionEvent event) -> {
        final List<RepositoryLocation<? extends Repository>> toRemove = repositoryLocationTable.getSelectionModel().getSelectedItems();
        getControl().getRepositoryLocations().removeAll(toRemove);
    });
    final Button restoreDefault = new Button(tr("Restore defaults"));
    restoreDefault.getStyleClass().add("repositories-restore");
    restoreDefault.setOnAction(event -> {
        final SimpleConfirmDialog dialog = SimpleConfirmDialog.builder().withTitle(tr("Restore default repositories")).withMessage(tr("Are you sure you want to restore the default repositories?")).withYesCallback(() -> Platform.runLater(() -> getControl().getRepositoryLocations().setAll(getControl().getRepositoryLocationLoader().getDefaultRepositoryLocations()))).withOwner(getControl().getScene().getWindow()).withResizable(true).build();
        dialog.showAndCallback();
    });
    final HBox container = new HBox(addButton, removeButton, restoreDefault);
    container.getStyleClass().add("repositories-buttons-container");
    return container;
}
Also used : Repository(org.phoenicis.repository.types.Repository) HBox(javafx.scene.layout.HBox) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog) ActionEvent(javafx.event.ActionEvent) SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation)

Example 4 with SimpleConfirmDialog

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

the class UiQuestionFactoryJavaFX method create.

@Override
public void create(String questionText, Runnable yesCallback, Runnable noCallback) {
    Platform.runLater(() -> {
        final SimpleConfirmDialog confirmMessage = SimpleConfirmDialog.builder().withTitle(wizardTitle).withMessage(questionText).withResizable(true).withYesCallback(yesCallback).withNoCallback(noCallback).build();
        confirmMessage.showAndCallback();
    });
}
Also used : SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog)

Example 5 with SimpleConfirmDialog

use of org.phoenicis.javafx.dialogs.SimpleConfirmDialog 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();
}
Also used : SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog)

Aggregations

SimpleConfirmDialog (org.phoenicis.javafx.dialogs.SimpleConfirmDialog)8 ErrorDialog (org.phoenicis.javafx.dialogs.ErrorDialog)4 java.awt (java.awt)2 File (java.io.File)2 IOException (java.io.IOException)2 List (java.util.List)2 Platform (javafx.application.Platform)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 FXCollections (javafx.collections.FXCollections)2 ObservableList (javafx.collections.ObservableList)2 ObservableMap (javafx.collections.ObservableMap)2 ActionEvent (javafx.event.ActionEvent)2 HBox (javafx.scene.layout.HBox)2 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)2 ContainersManager (org.phoenicis.containers.ContainersManager)2 ContainerCategoryDTO (org.phoenicis.containers.dto.ContainerCategoryDTO)2 ContainerDTO (org.phoenicis.containers.dto.ContainerDTO)2 EngineSetting (org.phoenicis.engines.EngineSetting)2 EngineToolsManager (org.phoenicis.engines.EngineToolsManager)2