Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
* This file is available and licensed under the following license:
Expand Down Expand Up @@ -273,13 +273,12 @@ void open() {
FileChooser ch = new FileChooser();
ch.setTitle("Open File");
ch.getExtensionFilters().addAll(
filterAll(),
filterRich(),
filterRtf()
filterRtf(),
filterAll()
);

Window w = FX.getParentWindow(control);
File f = ch.showOpenDialog(w);
File f = ch.showOpenDialog(parentWindow());
if (f != null) {
try {
DataFormat fmt = guessFormat(f);
Expand All @@ -294,11 +293,12 @@ void save() {
File f = getFile();
if (f == null) {
f = chooseFileForSave();
if (f != null) {
if (f == null) {
return;
}
}

file.set(f);
try {
writeFile(f);
} catch (Exception e) {
Expand All @@ -309,7 +309,6 @@ void save() {
boolean saveAs() {
File f = chooseFileForSave();
if (f != null) {
// TODO ask to overwrite if file exists
file.set(f);
try {
writeFile(f);
Expand All @@ -333,10 +332,9 @@ private File chooseFileForSave() {
filterRich(),
filterRtf(),
filterTxt()
//filterAll()
);
Window w = FX.getParentWindow(control);
return ch.showSaveDialog(w);

return ch.showSaveDialog(parentWindow());
}

private void readFile(File f, DataFormat fmt) throws Exception {
Expand Down Expand Up @@ -500,7 +498,7 @@ enum UserChoiceToSave {

private UserChoiceToSave askSaveChanges() {
Dialog<UserChoiceToSave> d = new Dialog<>();
d.initOwner(FX.getParentWindow(control));
d.initOwner(parentWindow());
d.setTitle("Save Changes?");
d.setContentText("Do you want to save changes?");

Expand Down Expand Up @@ -540,4 +538,8 @@ public boolean askToSave() {
}
return false;
}

private Window parentWindow() {
return FX.getParentWindow(control);
}
}