import java.util.Locale;
import java.util.prefs.Preferences;
-import net.sf.openrocket.database.ComponentPresetDatabase;
import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.l10n.DebugTranslator;
import net.sf.openrocket.l10n.L10N;
private static final int LOG_BUFFER_LENGTH = 50;
-
/**
* OpenRocket startup main method.
*/
// Setup the translations
initializeL10n();
- // Must be done after localization is initialized
- ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
- componentPresetDao.load("datafiles/presets", "(?i).*orc");
- Application.setComponentPresetDao( componentPresetDao );
-
// Continue startup in Startup2 class (where Application is already set up)
Startup2.runMain(args);
}
-
/**
* Set proper system properties if openrocket.debug is defined.
import java.awt.event.ActionListener;
import java.io.File;
import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.SwingUtilities;
import net.sf.openrocket.communication.UpdateInfo;
import net.sf.openrocket.communication.UpdateInfoRetriever;
+import net.sf.openrocket.database.ComponentPresetDatabase;
import net.sf.openrocket.database.Databases;
import net.sf.openrocket.database.ThrustCurveMotorSet;
import net.sf.openrocket.database.ThrustCurveMotorSetDatabase;
log.info("Initializing the splash screen");
Splash.init();
+ // Latch which counts the number of background loading processes we need to complete.
+ CountDownLatch loading = new CountDownLatch(1);
+ ExecutorService exec = Executors.newFixedThreadPool(2, new ThreadFactory() {
+
+ @Override
+ public Thread newThread(Runnable r) {
+ Thread t = new Thread(r);
+ t.setPriority(Thread.MIN_PRIORITY);
+ return t;
+ }
+
+ });
+
+ // Must be done after localization is initialized
+ ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
+ exec.submit( new ComponentPresetLoader( loading, componentPresetDao));
+
+ Application.setComponentPresetDao( componentPresetDao );
+
// Setup the uncaught exception handler
log.info("Registering exception handler");
SwingExceptionHandler exceptionHandler = new SwingExceptionHandler();
loadMotor();
Databases.fakeMethod();
+ try {
+ loading.await();
+ } catch ( InterruptedException iex) {
+
+ }
+
// Starting action (load files or open new document)
log.info("Opening main application window");
if (!handleCommandLine(args)) {
timer.start();
}
+ private static class ComponentPresetLoader implements Callable {
+
+ CountDownLatch latch;
+ ComponentPresetDatabase componentPresetDao;
+
+ private ComponentPresetLoader( CountDownLatch latch, ComponentPresetDatabase componentPresetDao ) {
+ this.componentPresetDao = componentPresetDao;
+ this.latch = latch;
+ }
+
+ @Override
+ public Object call() throws Exception {
+ componentPresetDao.load("datafiles/presets", "(?i).*orc");
+ latch.countDown();
+ return null;
+ }
+
+ }
+
/**
* Handles arguments passed from the command line. This may be used either
* when starting the first instance of OpenRocket or later when OpenRocket is