/*
* Starter.java
*
* Created on 22. November 2005, 18:38
*
* TODO: Delete: This is a test for subversion
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package xplanetconfigurator;
import java.io.File;
import java.util.logging.Logger;
import xplanetconfigurator.downloader.DownloadTimer;
import xplanetconfigurator.util.logging.LoggingInitializer;
import xplanetconfigurator.gui.MainFrame;
import xplanetconfigurator.util.XPlanetRessourceFinder;
/**
*
* @author wiedthom
*/
public class Starter {
private static Logger logger;
private static String version = "0.9.6 (2009-12-27)";
private static String author = "Tom Wiedenhoeft";
private static String licence = "GPLv3";
/** Creates a new instance of Starter */
public Starter() {
logger = Logger.getLogger(this.getClass().getName());
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
startLoggging();
logger = Logger.getLogger(Starter.class.getName());
if (args != null) {
int length = args.length;
if (length > 0) {
for (int i = 0; i < args.length; i++) {
String arg = args[i];
logger.fine("Found parameter: " + arg);
if (arg.toLowerCase().startsWith("-version") || arg.toLowerCase().equals("--version")) {
System.out.println("Version: XPlanet Configurator " + version);
System.out.println("Author: " + author);
System.out.println("Licence: " + licence);
} else if (arg.toLowerCase().startsWith("-h") || arg.toLowerCase().startsWith("-help") || arg.toLowerCase().startsWith("--h") || arg.toLowerCase().startsWith("--help")) {
System.out.println("Usage");
System.out.println("java -jar xplanet.jar [-help | -version | -nogui]");
System.out.println();
System.out.println("Parameters");
System.out.println("-help or -h");
System.out.println("\tDisplays this message.");
System.out.println("-version or --version");
System.out.println("\tPrints the version, licence and author.");
System.out.println("-nogui or -n");
System.out.println("\tStarts the Downloader only.");
System.out.println("\tIf -nogui is ommited a GUI ist showing");
System.out.println("\twhere you can configure XPlanet.");
System.out.println("\tExample: java -jar xplanet.jar -nogui");
System.out.println();
System.out.println("Version: XPlanet Configurator " + version);
System.out.println("Author: " + author);
System.out.println("Licence: " + licence);
System.out.println();
System.out.println("Please report bugs and comments to tom@jfellow.net.");
System.out.println("For more help on XPlanet refer to http://xplanet.sourceforge.net/");
System.exit(0);
} else if (arg.toLowerCase().startsWith("-nogui") || arg.toLowerCase().startsWith("-n")) {
XPlanetRessourceFinder f = new XPlanetRessourceFinder();
String dirOnDisc = f.getRessourceDirectory("downloader");
String fileOnDisc = dirOnDisc + File.separator + MainFrame.FILE_NAME_DOWNLOADER_CONFIG;
DownloadTimer timer = new DownloadTimer(fileOnDisc);
timer.run();
} else {
System.err.println("Found no valid parameter");
System.exit(0);
}
}
}
}
startApplication();
}
private static void startApplication() {
logger.info("Starting application...");
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
MainFrame.getInstance().setVisible(true);
}
});
}
private static void startLoggging() {
LoggingInitializer initializer = new LoggingInitializer();
try {
initializer.initLoggging();
} catch (Exception e) {
logger.warning("Failed to initialise logging");
}
}
}