create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / startup / Startup2.java
index b2e13195e49ca97c153567b9195a96dea3210d1e..6b7b49cdfc962aa351b6321b77f44831a8006788 100644 (file)
@@ -9,6 +9,8 @@ import javax.swing.SwingUtilities;
 import javax.swing.Timer;
 import javax.swing.ToolTipManager;
 
+import net.sf.openrocket.arch.SystemInfo;
+import net.sf.openrocket.arch.SystemInfo.Platform;
 import net.sf.openrocket.communication.UpdateInfo;
 import net.sf.openrocket.communication.UpdateInfoRetriever;
 import net.sf.openrocket.database.ComponentPresetDatabase;
@@ -52,6 +54,11 @@ public class Startup2 {
                VersionHelper.checkVersion();
                VersionHelper.checkOpenJDK();
                
+               // If running on a MAC set up OSX UI Elements.
+               if ( SystemInfo.getPlatform() == Platform.MAC_OS ){
+                       OSXStartup.setupOSX();
+               }
+               
                // Run the actual startup method in the EDT since it can use progress dialogs etc.
                log.info("Moving startup to EDT");
                SwingUtilities.invokeAndWait(new Runnable() {
@@ -77,11 +84,23 @@ public class Startup2 {
                Splash.init();
                
                // Must be done after localization is initialized
-               ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
-               ConcurrentComponentPresetDatabaseLoader presetLoader = new ConcurrentComponentPresetDatabaseLoader( componentPresetDao );
-               presetLoader.load();
-               
+               ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase(true) {
+
+                       @Override
+                       protected void load() {
+                               ConcurrentComponentPresetDatabaseLoader presetLoader = new ConcurrentComponentPresetDatabaseLoader( this );
+                               presetLoader.load();
+                               try {
+                                       presetLoader.await();
+                               } catch ( InterruptedException iex) {
+                                       
+                               }
+                       }
+                       
+               };
                Application.setComponentPresetDao( componentPresetDao );
+
+               componentPresetDao.startLoading();
                
                // Setup the uncaught exception handler
                log.info("Registering exception handler");
@@ -113,17 +132,10 @@ public class Startup2 {
                // Load motors etc.
                log.info("Loading databases");
                
-               ConcurrentLoadingThrustCurveMotorSetDatabase motorLoader = new ConcurrentLoadingThrustCurveMotorSetDatabase(THRUSTCURVE_DIRECTORY);
-               motorLoader.startLoading();
-               Application.setMotorSetDatabase(motorLoader);
-
+               loadMotor();
+               
                Databases.fakeMethod();
                
-               try {
-                       presetLoader.await();
-               } catch ( InterruptedException iex) {
-                       
-               }
 
                // Starting action (load files or open new document)
                log.info("Opening main application window");
@@ -137,6 +149,14 @@ public class Startup2 {
                
        }
        
+       /**
+        * this method is useful for the python bindings.
+        */
+       public static void loadMotor() {
+               ConcurrentLoadingThrustCurveMotorSetDatabase motorLoader = new ConcurrentLoadingThrustCurveMotorSetDatabase(THRUSTCURVE_DIRECTORY);
+               motorLoader.startLoading();
+               Application.setMotorSetDatabase(motorLoader);
+       }
        
        /**
         * Check that the JRE is not running headless.