src/ui/dialog/Dialogs.java
/*
     * Create and show a backup error dialog. This is probably overkill, but I
     * created this method just to make sure there always is an error dialog,
     * even when ErrorDialog.fxml cannot be loaded.
     */
Create and show a backup error dialog. This is probably overkill, but I
created this method just to make sure there always is an error dialog,
even when ErrorDialog.fxml cannot be loaded.
Create and show a backup error dialog . This is probably overkill but I created this method just to make sure there always is an error dialog even when ErrorDialog . fxml cannot be loaded .
private static void showBackupErrorDialog() {
        final RemindersException exception = Model.getInstance().getNextException();
        final VBox root = new VBox(15);
        root.setPadding(new Insets(15));
        root.getStylesheets().add(Dialogs.class.getResource("/resources/css/styles.css").toExternalForm());
        root.getChildren().add(TextBuilder.create().text("Oops...").styleClass("heading").build());
        if (exception.isRecoverable()) {
            root.getChildren().add(new Label("Looks like something went wrong here.\nYou can continue working or quit and call it a day."));
        } else {
            root.getChildren().add(new Label("Looks like something went wrong here.\nUnfortunately, the application cannot continue working."));
        }
        HBox buttons = new HBox(15);
        buttons.setAlignment(Pos.CENTER_RIGHT);
        Button quitButton = ButtonBuilder.create()
                .text("Quit")
                .styleClass("quit-button")
                .graphic(LabelBuilder.create()
                    .text(Icons.QUIT)
                    .styleClass("button-icon")
                    .build())
                .onAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent t) {
                        System.exit(1);
                    }
                })
                .build();
        buttons.getChildren().add(quitButton);
        final Button continueButton = ButtonBuilder.create()
                .text("Continue")
                .onAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent t) {
                        root.getScene().getWindow().hide();
                    }
                })
                .build();
        if (exception.isRecoverable()) {
            continueButton.setDefaultButton(true);
            buttons.getChildren().add(continueButton);
        } else {
            quitButton.setDefaultButton(true);
        }
        root.getChildren().add(buttons);
        showDialog(root, new OnShownAction() {
            @Override
            public void perform() {
                for (Node node : root.lookupAll(".button")) {
                    if (node instanceof Button && ((Button)node).isDefaultButton()) {
                        node.requestFocus();
                    }
                }
            }
        });
    }
private static void showBackupErrorDialog ( ) { final RemindersException exception = Model . getInstance ( ) . getNextException ( ) ; final VBox root = new VBox ( 15 ) ; root . setPadding ( new Insets ( 15 ) ) ; root . getStylesheets ( ) . add ( Dialogs . class . getResource ( "/resources/css/styles.css" ) . toExternalForm ( ) ) ; root . getChildren ( ) . add ( TextBuilder . create ( ) . text ( "Oops..." ) . styleClass ( "heading" ) . build ( ) ) ; if ( exception . isRecoverable ( ) ) { root . getChildren ( ) . add ( new Label ( "Looks like something went wrong here.\nYou can continue working or quit and call it a day." ) ) ; } else { root . getChildren ( ) . add ( new Label ( "Looks like something went wrong here.\nUnfortunately, the application cannot continue working." ) ) ; } HBox buttons = new HBox ( 15 ) ; buttons . setAlignment ( Pos . CENTER_RIGHT ) ; Button quitButton = ButtonBuilder . create ( ) . text ( "Quit" ) . styleClass ( "quit-button" ) . graphic ( LabelBuilder . create ( ) . text ( Icons . QUIT ) . styleClass ( "button-icon" ) . build ( ) ) . onAction ( new EventHandler < ActionEvent > ( ) { @ Override public void handle ( ActionEvent t ) { System . exit ( 1 ) ; } } ) . build ( ) ; buttons . getChildren ( ) . add ( quitButton ) ; final Button continueButton = ButtonBuilder . create ( ) . text ( "Continue" ) . onAction ( new EventHandler < ActionEvent > ( ) { @ Override public void handle ( ActionEvent t ) { root . getScene ( ) . getWindow ( ) . hide ( ) ; } } ) . build ( ) ; if ( exception . isRecoverable ( ) ) { continueButton . setDefaultButton ( true ) ; buttons . getChildren ( ) . add ( continueButton ) ; } else { quitButton . setDefaultButton ( true ) ; } root . getChildren ( ) . add ( buttons ) ; showDialog ( root , new OnShownAction ( ) { @ Override public void perform ( ) { for ( Node node : root . lookupAll ( ".button" ) ) { if ( node instanceof Button && ( ( Button ) node ) . isDefaultButton ( ) ) { node . requestFocus ( ) ; } } } } ) ; }
Create and show a backup error dialog.
Create and show a backup error dialog .