2002-12-01 02:21:00 +00:00
|
|
|
/*
|
|
|
|
* AppleCommander - An Apple ][ image utility.
|
2003-12-06 04:14:00 +00:00
|
|
|
* Copyright (C) 2002-3 by Robert Greene
|
2002-12-01 02:21:00 +00:00
|
|
|
* robgreene at users.sourceforge.net
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
package com.webcodepro.applecommander.ui;
|
|
|
|
|
2003-12-07 06:17:55 +00:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.lang.reflect.Method;
|
2002-12-01 02:21:00 +00:00
|
|
|
|
2004-07-11 15:07:56 +00:00
|
|
|
import com.webcodepro.applecommander.util.TextBundle;
|
|
|
|
|
2002-12-01 02:21:00 +00:00
|
|
|
/**
|
|
|
|
* Launch AppleCommander.
|
|
|
|
* This application attempts to identify which type of user-interface to
|
|
|
|
* launch. Additionally, there are some command-line interface switches
|
|
|
|
* available - see the about method.
|
|
|
|
* <p>
|
2003-12-07 06:17:55 +00:00
|
|
|
* Regarding SWT, this appliation launcher tries to not be SWT dependent.
|
|
|
|
* That means that SwtAppleCommander is launched purely by reflection.
|
|
|
|
* NOTE: This may yet prove to be a worthless trick. If it is, remove
|
2003-12-21 06:16:58 +00:00
|
|
|
* the crud. However, as the VERSION and COPYRIGHT are in this class and
|
2003-12-07 06:17:55 +00:00
|
|
|
* are referenced in various places, it may well be worth it.
|
|
|
|
* <p>
|
2002-12-01 02:21:00 +00:00
|
|
|
* Date created: Nov 16, 2002 9:13:25 PM
|
2004-06-18 05:15:33 +00:00
|
|
|
* @author Rob Greene
|
2002-12-01 02:21:00 +00:00
|
|
|
*/
|
|
|
|
public class AppleCommander {
|
2008-06-03 19:23:29 +00:00
|
|
|
public static final String VERSION = "1.3.5.1"; //$NON-NLS-1$
|
2004-07-11 15:07:56 +00:00
|
|
|
private static TextBundle textBundle = UiBundle.getInstance();
|
2002-12-01 02:21:00 +00:00
|
|
|
/**
|
|
|
|
* Launch AppleCommander.
|
|
|
|
*/
|
2004-07-04 03:34:35 +00:00
|
|
|
public static void main(String[] args) {
|
2002-12-01 02:21:00 +00:00
|
|
|
if (args.length == 0) {
|
2003-12-07 06:17:55 +00:00
|
|
|
if (isSwtAvailable()) {
|
|
|
|
launchSwtAppleCommander(args);
|
|
|
|
} else {
|
2003-12-13 03:05:21 +00:00
|
|
|
showHelp();
|
2002-12-01 02:21:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
String[] extraArgs = new String[args.length - 1];
|
|
|
|
System.arraycopy(args, 1, extraArgs, 0, extraArgs.length);
|
2004-07-04 03:34:35 +00:00
|
|
|
if ("-swt".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
2003-12-07 06:17:55 +00:00
|
|
|
launchSwtAppleCommander(args);
|
2004-07-04 03:34:35 +00:00
|
|
|
} else if ("-swing".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
|
|
|
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$
|
|
|
|
|| "-?".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
2003-12-13 03:05:21 +00:00
|
|
|
showHelp();
|
2002-12-01 02:21:00 +00:00
|
|
|
} else {
|
2003-12-12 04:21:59 +00:00
|
|
|
ac.main(args);
|
2002-12-01 02:21:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-12-07 06:17:55 +00:00
|
|
|
/**
|
|
|
|
* Launch the SWT version of AppleCommander. This method
|
|
|
|
* uses reflection to load SwtAppleCommander to minimize which
|
|
|
|
* classes get loaded. This is particularly important for the
|
|
|
|
* command-line version.
|
|
|
|
*/
|
|
|
|
protected static void launchSwtAppleCommander(String[] args) {
|
|
|
|
Class swtAppleCommander;
|
|
|
|
try {
|
|
|
|
swtAppleCommander = Class.forName(
|
2004-07-04 03:34:35 +00:00
|
|
|
"com.webcodepro.applecommander.ui.swt.SwtAppleCommander"); //$NON-NLS-1$
|
2003-12-07 06:17:55 +00:00
|
|
|
Object object = swtAppleCommander.newInstance();
|
|
|
|
Method launchMethod = swtAppleCommander.
|
2004-07-04 03:34:35 +00:00
|
|
|
getMethod("launch", null); //$NON-NLS-1$
|
2003-12-07 06:17:55 +00:00
|
|
|
launchMethod.invoke(object, null);
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (SecurityException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Test to see if SWT is available.
|
|
|
|
*/
|
|
|
|
protected static boolean isSwtAvailable() {
|
|
|
|
try {
|
2004-07-04 03:34:35 +00:00
|
|
|
Class.forName("org.eclipse.swt.SWT"); //$NON-NLS-1$
|
|
|
|
Class.forName("com.webcodepro.applecommander.ui.swt.SwtAppleCommander"); //$NON-NLS-1$
|
2003-12-07 06:17:55 +00:00
|
|
|
return true;
|
|
|
|
} catch (ClassNotFoundException ex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2003-12-13 03:05:21 +00:00
|
|
|
/**
|
|
|
|
* Display help message(s) for AppleCommander.
|
|
|
|
*/
|
|
|
|
protected static void showHelp() {
|
2004-07-04 03:34:35 +00:00
|
|
|
System.err.println(textBundle.get("AppleCommanderHelp")); //$NON-NLS-1$
|
2003-12-13 03:05:21 +00:00
|
|
|
System.err.println();
|
|
|
|
ac.help();
|
|
|
|
}
|
2002-12-01 02:21:00 +00:00
|
|
|
}
|