Moved all initializations into Base constructor

This commit is contained in:
Cristian Maglie 2016-11-07 15:27:02 +01:00
parent e7f51f225b
commit fbe6bf3792
1 changed files with 42 additions and 47 deletions

View File

@ -128,59 +128,13 @@ public class Base {
}
try {
guardedMain(args);
INSTANCE = new Base(args);
} catch (Throwable e) {
e.printStackTrace(System.err);
System.exit(255);
}
}
static public void guardedMain(String args[]) throws Exception {
Thread deleteFilesOnShutdownThread = new Thread(DeleteFilesOnShutdown.INSTANCE);
deleteFilesOnShutdownThread.setName("DeleteFilesOnShutdown");
Runtime.getRuntime().addShutdownHook(deleteFilesOnShutdownThread);
BaseNoGui.initLogger();
initLogger();
BaseNoGui.initPlatform();
BaseNoGui.getPlatform().init();
BaseNoGui.initPortableFolder();
BaseNoGui.initParameters(args);
splashScreenHelper.splashText(tr("Loading configuration..."));
BaseNoGui.initVersion();
// Use native popups so they don't look so crappy on osx
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
// Don't put anything above this line that might make GUI,
// because the platform has to be inited properly first.
// setup the theme coloring fun
Theme.init();
System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true"));
// Set the look and feel before opening the window
try {
BaseNoGui.getPlatform().setLookAndFeel();
} catch (Exception e) {
// ignore
}
// Create a location for untitled sketches
untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp");
DeleteFilesOnShutdown.add(untitledFolder);
INSTANCE = new Base(args);
}
static public void initLogger() {
Handler consoleHandler = new ConsoleLogger();
consoleHandler.setLevel(Level.ALL);
@ -227,6 +181,47 @@ public class Base {
}
public Base(String[] args) throws Exception {
Thread deleteFilesOnShutdownThread = new Thread(DeleteFilesOnShutdown.INSTANCE);
deleteFilesOnShutdownThread.setName("DeleteFilesOnShutdown");
Runtime.getRuntime().addShutdownHook(deleteFilesOnShutdownThread);
BaseNoGui.initLogger();
initLogger();
BaseNoGui.initPlatform();
BaseNoGui.getPlatform().init();
BaseNoGui.initPortableFolder();
BaseNoGui.initParameters(args);
splashScreenHelper.splashText(tr("Loading configuration..."));
BaseNoGui.initVersion();
// Use native popups so they don't look so crappy on osx
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
// Don't put anything above this line that might make GUI,
// because the platform has to be inited properly first.
// setup the theme coloring fun
Theme.init();
System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true"));
// Set the look and feel before opening the window
try {
BaseNoGui.getPlatform().setLookAndFeel();
} catch (Exception e) {
// ignore
}
// Create a location for untitled sketches
untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp");
DeleteFilesOnShutdown.add(untitledFolder);
BaseNoGui.notifier = new GUIUserNotifier(this);
CommandlineParser parser = new CommandlineParser(args);