kaikramer / keystore-explorer

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.
https://keystore-explorer.org/
GNU General Public License v3.0
1.7k stars 275 forks source link

"Examine File" in Mac shows "Save" dialog instead of "Open" #218

Closed fforneck closed 4 years ago

fforneck commented 4 years ago

On a Mac, clicking on the "Examine file" button opens a dialog that resembles more a "Save" dialog than an "Open" one (see screenshot below). I say it resembles more a "Save" dialog than an "Open" one because it has a "Save as" field on the very top. I first experienced this on a client's machine and then confirmed it on a colleague's.

Steps to reproduce the behavior:

  1. Open Keystore Explorer on a Mac
  2. Click on 'Examine File'
  3. See the "Save As:" field on the top of the dialog

Expected behavior When opening any file, the user shouldn't be asked to choose a file name to "Save As"

Screenshots image

Environment

kaikramer commented 4 years ago

Thanks for the ticket, but this text is not set by KSE.

Your screenshot shows the file chooser dialog of VAqua. If you use the default look and feel, the same dialog looks like this:

image

Maybe @lhaeger who added the VAqua laf to KSE knows a trick to change the text.

fforneck commented 4 years ago

What is the default laf for Mac? I doubt the laf has been changed, but I'll confirm with my co-worker.

fforneck commented 4 years ago

Just confirmed with my co-worker, the laf had not been changed. He was using whatever was selected out-of-the-box, which was "macOS (VAqua)" and not "Mac OS X".

fforneck commented 4 years ago

VAqua is the default laf when it is available according to this: https://github.com/kaikramer/keystore-explorer/blob/afdfcf0c4c7930293f2136920b7707ba3723e69d/kse/src/org/kse/gui/LnfUtil.java#L97-L130

derkork commented 4 years ago

I'm having the same issue here. Basically all open dialogs are "Save As" dialogs. This leads to a few more errors. E.g if you try to import a certificate a dialog opens where you can select your certificate. However it is actually a save as dialog:

image

If you now press "Import" you will get an error message that there is no certificate named "Untitled" in the path. I have this same issue for every open file dialog.

image

KSE 5.4.3 on OSX 10.15.3.

kaikramer commented 4 years ago

There is no question that the default look&feel should not show this weird behavior. Unless @lhaeger knows how to fix this, I'll change the default l&f back to the standard Java one with the next release.

lhaeger commented 4 years ago

I have no time to look into this short term, so please revert as suggested.

lhaeger commented 4 years ago

Maybe the VAqua author Alan Snyder @cbfiddle has an idea.

derkork commented 4 years ago

Until this can be addressed, there are currently two workarounds for this:

  1. you can type the name of the file into the "Save As" text field. This will correctly load the file then.
  2. for trusted certificates you can drag them directly onto the KSE window and press the Import button on the dialog that appears.
gcbartlett commented 4 years ago

@kaikramer, here's a patch that I think addresses this issue:

diff --git a/kse/src/org/kse/gui/actions/ExamineFileAction.java b/kse/src/org/kse/gui/actions/ExamineFileAction.java
index 7b26109..1f98f94 100644
--- a/kse/src/org/kse/gui/actions/ExamineFileAction.java
+++ b/kse/src/org/kse/gui/actions/ExamineFileAction.java
@@ -314,8 +314,9 @@ public class ExamineFileAction extends KeyStoreExplorerAction {
                chooser.setCurrentDirectory(CurrentDirectory.get());
                chooser.setDialogTitle(res.getString("ExamineFileAction.ExamineFile.Title"));
                chooser.setMultiSelectionEnabled(false);
+               chooser.setApproveButtonText(res.getString("ExamineFileAction.ExamineFile.button"));

-               int rtnValue = chooser.showDialog(frame, res.getString("ExamineFileAction.ExamineFile.button"));
+               int rtnValue = chooser.showOpenDialog(frame);
                if (rtnValue == JFileChooser.APPROVE_OPTION) {
                        File openFile = chooser.getSelectedFile();
                        CurrentDirectory.updateForFile(openFile);