use of org.phoenicis.javafx.dialogs.SimpleConfirmDialog in project POL-POM-5 by PhoenicisOrg.
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;
}
use of org.phoenicis.javafx.dialogs.SimpleConfirmDialog 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();
}
use of org.phoenicis.javafx.dialogs.SimpleConfirmDialog in project POL-POM-5 by PlayOnLinux.
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();
});
}
Aggregations