Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

always use main window as owner of alert dialogs - ensures correct feedback when clicking on main window while alert is open - avoids additional entry in Windows task bar while alert is open

AuthorKarl Tauber <email>
Date2015-07-23 19:12:56 GMT+0200
Commit7757b9a36f19471b6cb561e1e39f94cb5a16e498
Parent9f4a452
src/main/java/org/markdownwriterfx/FileEditor.java
class FileEditor
{
+ private final MainWindow mainWindow;
private final Tab tab = new Tab();
private MarkdownEditorPane markdownEditorPane;
private MarkdownPreviewPane markdownPreviewPane;
- FileEditor(Path path) {
+ FileEditor(MainWindow mainWindow, Path path) {
+ this.mainWindow = mainWindow;
this.path.set(path);
markdownEditorPane.getUndoManager().mark();
} catch (IOException ex) {
- Alert alert = new Alert(AlertType.ERROR);
- alert.setTitle("Load");
- alert.setHeaderText(null);
- alert.setContentText(String.format(
- "Failed to load '%s'.\n\nReason: %s", path, ex.getMessage()));
+ Alert alert = mainWindow.createAlert(AlertType.ERROR, "Load",
+ "Failed to load '%s'.\n\nReason: %s", path, ex.getMessage());
alert.showAndWait();
}
return true;
} catch (IOException ex) {
- Alert alert = new Alert(AlertType.ERROR);
- alert.setTitle("Save");
- alert.setHeaderText(null);
- alert.setContentText(String.format(
- "Failed to save '%s'.\n\nReason: %s", path.get(), ex.getMessage()));
+ Alert alert = mainWindow.createAlert(AlertType.ERROR, "Save",
+ "Failed to save '%s'.\n\nReason: %s", path.get(), ex.getMessage());
alert.showAndWait();
return false;
src/main/java/org/markdownwriterfx/FileEditorTabPane.java
private FileEditor createFileEditor(Path path) {
- FileEditor fileEditor = new FileEditor(path);
+ FileEditor fileEditor = new FileEditor(mainWindow, path);
return fileEditor;
}
src/main/java/org/markdownwriterfx/MainWindow.java
}
+ Alert createAlert(AlertType alertType, String title,
+ String contentTextFormat, Object... contentTextArgs)
+ {
+ Alert alert = new Alert(alertType);
+ alert.setTitle(title);
+ alert.setHeaderText(null);
+ alert.setContentText(String.format(contentTextFormat, contentTextArgs));
+ alert.initOwner(getScene().getWindow());
+ return alert;
+ }
+
//---- File menu ----------------------------------------------------------
alert.setHeaderText("Markdown Writer FX");
alert.setContentText("Copyright (c) 2015 Karl Tauber <karl at jformdesigner dot com>\nAll rights reserved.");
+ alert.initOwner(getScene().getWindow());
alert.showAndWait();
Delta20 lines added, 12 lines removed, 8-line increase