mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-26 03:33:00 +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);
|
System.arraycopy(args, 1, extraArgs, 0, extraArgs.length);
|
||||||
if ("-swt".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
if ("-swt".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||||
if (isSwtAvailable()) {
|
if (isSwtAvailable()) {
|
||||||
launchSwtAppleCommander(args);
|
launchSwtAppleCommander(extraArgs);
|
||||||
} else {
|
} else {
|
||||||
System.err.println(textBundle.get("SwtVersionNotAvailable")); //$NON-NLS-1$
|
System.err.println(textBundle.get("SwtVersionNotAvailable")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} else if ("-swing".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
} else if ("-swing".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||||
if (isSwingAvailable()) {
|
if (isSwingAvailable()) {
|
||||||
launchSwingAppleCommander(args);
|
launchSwingAppleCommander(extraArgs);
|
||||||
} else {
|
} else {
|
||||||
System.err.println(textBundle.get("SwingVersionNotAvailable")); //$NON-NLS-1$
|
System.err.println(textBundle.get("SwingVersionNotAvailable")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
@ -99,8 +99,8 @@ public class AppleCommander {
|
|||||||
Constructor<?> constructor = swtAppleCommander.getConstructor();
|
Constructor<?> constructor = swtAppleCommander.getConstructor();
|
||||||
Object object = constructor.newInstance();
|
Object object = constructor.newInstance();
|
||||||
Method launchMethod = swtAppleCommander.
|
Method launchMethod = swtAppleCommander.
|
||||||
getMethod("launch", (Class[]) null); //$NON-NLS-1$
|
getMethod("launch", args.getClass()); //$NON-NLS-1$
|
||||||
launchMethod.invoke(object, (Object[]) null);
|
launchMethod.invoke(object, new Object[] { args });
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
@ -68,17 +68,40 @@ public class SwtAppleCommander implements Listener {
|
|||||||
* Launch SwtAppleCommander.
|
* Launch SwtAppleCommander.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SwtAppleCommander().launch();
|
new SwtAppleCommander().launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch SwtAppleCommander.
|
* Launch SwtAppleCommander.
|
||||||
*/
|
*/
|
||||||
public void launch() {
|
public void launch(String[] args) {
|
||||||
Display display = new Display();
|
Display display = new Display();
|
||||||
|
display.asyncExec(() -> {
|
||||||
|
for (String arg : args) {
|
||||||
|
open(arg);
|
||||||
|
}
|
||||||
|
});
|
||||||
launch(display);
|
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.
|
* Launch SwtAppleCommander with a given display.
|
||||||
* Primary motivation is getting S-Leak to work!
|
* Primary motivation is getting S-Leak to work!
|
||||||
@ -171,17 +194,7 @@ public class SwtAppleCommander implements Listener {
|
|||||||
|
|
||||||
if (fullpath != null) {
|
if (fullpath != null) {
|
||||||
userPreferences.setDiskImageDirectory(fileDialog.getFilterPath());
|
userPreferences.setDiskImageDirectory(fileDialog.getFilterPath());
|
||||||
try {
|
open(fullpath);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user