Skip to content

Commit

Permalink
Fallback to OS-independent file-saving dialog on macOS.
Browse files Browse the repository at this point in the history
On macOS, if we don't get a File from the macOS-specific
MacUIUtil#saveFile() method, assume this is due to a failure of that
method (or of the underlying JRE) to even show the native file-choosing
dialog (as was shown to happen, #1106), and fallback to the
OS-independent method.

This allow users affected by the "never-showing-native-dialog" bug to
still save their files, at the price of asking users not affected by
that same bug to click "cancel" on two consecutive dialogs if they do
want to cancel the save operation at the file-choosing step.
  • Loading branch information
gouttegd committed May 5, 2023
1 parent 9bfe1c5 commit 86f07f4
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ public static File saveFile(Component parent,
parentWindow = SwingUtilities.getWindowAncestor(parent);
}
if(OSUtils.isOSX() && parentWindow != null) {
return MacUIUtil.saveFile(parentWindow, title, extensions, initialName);
File f = MacUIUtil.saveFile(parentWindow, title, extensions, initialName);
if (f != null)
return f;
// Proceed with the OS-independent path below. This is a workaround for
// a bug on some Macs where the native file-choosing dialog in MacUIUtil
// is never shown to the user. On Macs where the dialog is actually
// shown as expected, if the user clicked "cancel" then they will
// be shown a second dialog that they will have to cancel again. :(
// See https://github.com/protegeproject/protege/issues/1106
}
JFileChooser fileDialog = new JFileChooser(getCurrentFileDirectory());
fileDialog.setDialogTitle(title);
Expand Down

0 comments on commit 86f07f4

Please sign in to comment.