From 44fd1cb010f7d72212001ec7ee7fde178b392114 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sat, 11 Nov 2017 19:43:11 -0800 Subject: [PATCH] Make GUI request errors clean MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you don't request a specific GUI, we try SWT and then Swing. Okay. But if you do, we don't even try to see if it works—we just assume SWT works. If the user requested Swing, we just unconditionally spit out an error message and try to start the GUI anyway. Let's make the errors conditional on the GUIs being unavailable. Note, a Swing GUI is available. It is just incomplete and doesn't work very well. :) --- .../applecommander/ui/AppleCommander.java | 13 ++++++++++--- .../applecommander/ui/UiBundle.properties | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/com/webcodepro/applecommander/ui/AppleCommander.java b/src/com/webcodepro/applecommander/ui/AppleCommander.java index bbb0bb7..ecef1df 100644 --- a/src/com/webcodepro/applecommander/ui/AppleCommander.java +++ b/src/com/webcodepro/applecommander/ui/AppleCommander.java @@ -58,10 +58,17 @@ public class AppleCommander { String[] extraArgs = new String[args.length - 1]; System.arraycopy(args, 1, extraArgs, 0, extraArgs.length); if ("-swt".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ - launchSwtAppleCommander(args); + if (isSwtAvailable()) { + launchSwtAppleCommander(args); + } else { + System.err.println(textBundle.get("SwtVersionNotAvailable")); //$NON-NLS-1$ + } } else if ("-swing".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ - System.err.println(textBundle.get("SwingVersionNotAvailable")); //$NON-NLS-1$ - launchSwingAppleCommander(args); + if (isSwingAvailable()) { + launchSwingAppleCommander(args); + } else { + System.err.println(textBundle.get("SwingVersionNotAvailable")); //$NON-NLS-1$ + } } else if ("-command".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ System.err.println(textBundle.get("CommandLineNotAvailable")); //$NON-NLS-1$ } else if ("-help".equalsIgnoreCase(args[0]) //$NON-NLS-1$ diff --git a/src/com/webcodepro/applecommander/ui/UiBundle.properties b/src/com/webcodepro/applecommander/ui/UiBundle.properties index 200dea6..5742885 100644 --- a/src/com/webcodepro/applecommander/ui/UiBundle.properties +++ b/src/com/webcodepro/applecommander/ui/UiBundle.properties @@ -110,6 +110,7 @@ CommandLineDC42Bad = Unable to interpret this DiskCopy 42 image. UserPreferencesComment = AppleCommander user preferences # AppleCommander +SwtVersionNotAvailable = Sorry, the SWT GUI is not available. SwingVersionNotAvailable = Sorry, the Swing GUI is not available. CommandLineNotAvailable = Sorry, the command line user interface is not available. AppleCommanderHelp = AppleCommander general options:\n-swt will launch the SWT version of AppleCommander.\n This requires the SWT jar and dll files to be present.\n-swing will launch the Swing version of AppleCommander.\n (This is not implemented yet.)\n-command will enter command interpreter mode. (This is also\n not implemented yet.)\n-help will show this help text.