/** * Displays a window in which the user can edit a journal entry object. * * @param data the JournalEntry object to edit */ public static boolean display(JournalEntry data) { try { JournalEntryEditController controller = (JournalEntryEditController) BetonQuestEditor.createWindow( "view/window/JournalEntryEditWindow.fxml", "edit-entry", 500, 300); if (controller == null) { return false; } controller.stage = (Stage) controller.root.getScene().getWindow(); controller.data = data; controller.id.setText(data.getId().get()); controller.entry = data.getText().get(); controller.text.setText(controller.entry.get()); controller .root .getScene() .addEventFilter( KeyEvent.KEY_PRESSED, event -> { if (event.getCode() == KeyCode.ESCAPE) { controller.cancel(); event.consume(); return; } if (event.getCode() == KeyCode.ENTER) { controller.ok(); event.consume(); return; } }); controller.stage.showAndWait(); return controller.result; } catch (Exception e) { ExceptionController.display(e); return false; } }
/** * Displays the errors in a window. * * @param exception exception to display */ public static void display(String errors) { try { ErrorController controller = (ErrorController) BetonQuestEditor.createWindow( "view/window/ErrorWindow.fxml", "errors-found", 700, 500); controller.stage = (Stage) controller.root.getScene().getWindow(); controller.error.setText(errors); controller .root .getScene() .addEventFilter( KeyEvent.KEY_PRESSED, event -> { if (event.getCode() == KeyCode.ESCAPE || event.getCode() == KeyCode.ENTER) { controller.close(); } }); controller.stage.showAndWait(); } catch (Exception e) { ExceptionController.display(e); } }