mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-08 07:49:17 +00:00
Adding the capability to specify disks when launching AppleCommander GUI
from the commandline. #47
This commit is contained in:
parent
8a6a777d69
commit
0a2c2fd435
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user