Adding the capability to specify disks when launching AppleCommander GUI

from the commandline. #47
This commit is contained in:
Rob Greene 2020-11-21 16:30:50 -06:00
parent 8a6a777d69
commit 0a2c2fd435
2 changed files with 30 additions and 17 deletions

View File

@ -65,13 +65,13 @@ public class AppleCommander {
System.arraycopy(args, 1, extraArgs, 0, extraArgs.length);
if ("-swt".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
if (isSwtAvailable()) {
launchSwtAppleCommander(args);
launchSwtAppleCommander(extraArgs);
} else {
System.err.println(textBundle.get("SwtVersionNotAvailable")); //$NON-NLS-1$
}
} else if ("-swing".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
if (isSwingAvailable()) {
launchSwingAppleCommander(args);
launchSwingAppleCommander(extraArgs);
} else {
System.err.println(textBundle.get("SwingVersionNotAvailable")); //$NON-NLS-1$
}
@ -99,8 +99,8 @@ public class AppleCommander {
Constructor<?> constructor = swtAppleCommander.getConstructor();
Object object = constructor.newInstance();
Method launchMethod = swtAppleCommander.
getMethod("launch", (Class[]) null); //$NON-NLS-1$
launchMethod.invoke(object, (Object[]) null);
getMethod("launch", args.getClass()); //$NON-NLS-1$
launchMethod.invoke(object, new Object[] { args });
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SecurityException e) {

View File

@ -68,17 +68,40 @@ public class SwtAppleCommander implements Listener {
* Launch SwtAppleCommander.
*/
public static void main(String[] args) {
new SwtAppleCommander().launch();
new SwtAppleCommander().launch(args);
}
/**
* Launch SwtAppleCommander.
*/
public void launch() {
public void launch(String[] args) {
Display display = new Display();
display.asyncExec(() -> {
for (String arg : args) {
open(arg);
}
});
launch(display);
}
/**
* Open a specific file.
*/
public void open(String fullpath) {
try {
Disk disk = new Disk(fullpath);
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
DiskWindow window = new DiskWindow(shell, formattedDisks, imageManager);
window.open();
} catch (DiskUnrecognizedException e) {
showUnrecognizedDiskFormatMessage(fullpath);
} catch (Exception ignored) {
ignored.printStackTrace();
showUnexpectedErrorMessage(fullpath);
}
}
/**
* Launch SwtAppleCommander with a given display.
* Primary motivation is getting S-Leak to work!
@ -171,17 +194,7 @@ public class SwtAppleCommander implements Listener {
if (fullpath != null) {
userPreferences.setDiskImageDirectory(fileDialog.getFilterPath());
try {
Disk disk = new Disk(fullpath);
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
DiskWindow window = new DiskWindow(shell, formattedDisks, imageManager);
window.open();
} catch (DiskUnrecognizedException e) {
showUnrecognizedDiskFormatMessage(fullpath);
} catch (Exception ignored) {
ignored.printStackTrace();
showUnexpectedErrorMessage(fullpath);
}
open(fullpath);
}
}
/**