As per feedback on PR #690: redid line wrapping, refactored signature for dialog builder method to include a default button, and the default button for the graceful shutdown dialog is now 'Force shutdown'.

This commit is contained in:
jellemdekker
2018-08-21 15:26:10 +02:00
parent 0ddd6d767d
commit 963a731202
2 changed files with 6 additions and 11 deletions

View File

@@ -217,16 +217,11 @@ public class MainController implements ViewController {
private void gracefulShutdown() {
vaults.filtered(Vault.NOT_LOCKED).forEach(Vault::prepareForShutdown);
if (!vaults.filtered(Vault.NOT_LOCKED).isEmpty()) {
ButtonType tryAgainButtonType = new ButtonType(
localization.getString("main.gracefulShutdown.button.tryAgain"));
ButtonType forceShutdownButtonType = new ButtonType(
localization.getString("main.gracefulShutdown.button.forceShutdown"));
ButtonType tryAgainButtonType = new ButtonType(localization.getString("main.gracefulShutdown.button.tryAgain"));
ButtonType forceShutdownButtonType = new ButtonType(localization.getString("main.gracefulShutdown.button.forceShutdown"));
Alert gracefulShutdownDialog = DialogBuilderUtil.buildGracefulShutdownDialog(
localization.getString("main.gracefulShutdown.dialog.title"),
localization.getString("main.gracefulShutdown.dialog.header"),
localization.getString("main.gracefulShutdown.dialog.content"),
tryAgainButtonType,
forceShutdownButtonType);
localization.getString("main.gracefulShutdown.dialog.title"), localization.getString("main.gracefulShutdown.dialog.header"), localization.getString("main.gracefulShutdown.dialog.content"),
forceShutdownButtonType, forceShutdownButtonType, tryAgainButtonType);
Optional<ButtonType> choice = gracefulShutdownDialog.showAndWait();
if (choice.isPresent()) {

View File

@@ -38,8 +38,8 @@ public class DialogBuilderUtil {
return buildDialog(title, header, content, Alert.AlertType.CONFIRMATION, defaultButton, ButtonType.YES, ButtonType.NO);
}
public static Alert buildGracefulShutdownDialog(String title, String header, String content, ButtonType tryAgainButton, ButtonType forceShutdownButton) {
return buildDialog(title, header, content, Alert.AlertType.WARNING, tryAgainButton, tryAgainButton, forceShutdownButton);
public static Alert buildGracefulShutdownDialog(String title, String header, String content, ButtonType defaultButton, ButtonType... buttons) {
return buildDialog(title, header, content, Alert.AlertType.WARNING, defaultButton, buttons);
}
private static Alert buildDialog(String title, String header, String content, Alert.AlertType type, ButtonType defaultButton, ButtonType... buttons) {