- updateInfo = null;
- }
-
-
- // Set the best available look-and-feel
- GUIUtil.setBestLAF();
-
- // Set tooltip delay time. Tooltips are used in MotorChooserDialog extensively.
- ToolTipManager.sharedInstance().setDismissDelay(30000);
-
-
- // Setup the uncaught exception handler
- ExceptionHandler.registerExceptionHandler();
-
-
- // Load defaults
- Prefs.loadDefaultUnits();
-
-
- // Load motors etc.
- Databases.fakeMethod();
-
- // Starting action (load files or open new document)
- if (!handleCommandLine(args)) {
- newAction();
- }
-
-
- // Check whether update info has been fetched or whether it needs more time
- checkUpdateStatus(updateInfo);
- }
-
-
- private static void checkUpdateStatus(final UpdateInfoRetriever updateInfo) {
- if (updateInfo == null)
- return;
-
- int delay = 1000;
- if (!updateInfo.isRunning())
- delay = 100;
-
- final Timer timer = new Timer(delay, null);
-
- ActionListener listener = new ActionListener() {
- private int count = 5;
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (!updateInfo.isRunning()) {
- timer.stop();
-
- String current = Prefs.getVersion();
- String last = Prefs.getString(Prefs.LAST_UPDATE, "");
-
- UpdateInfo info = updateInfo.getUpdateInfo();
- if (info != null && info.getLatestVersion() != null &&
- !current.equals(info.getLatestVersion()) &&
- !last.equals(info.getLatestVersion())) {
-
- UpdateInfoDialog infoDialog = new UpdateInfoDialog(info);
- infoDialog.setVisible(true);
- if (infoDialog.isReminderSelected()) {
- Prefs.putString(Prefs.LAST_UPDATE, "");
- } else {
- Prefs.putString(Prefs.LAST_UPDATE, info.getLatestVersion());
- }
- }
- }
- count--;
- if (count <= 0)
- timer.stop();
- }
- };
- timer.addActionListener(listener);
- timer.start();
- }
-
-
- /**
- * Handles arguments passed from the command line. This may be used either
- * when starting the first instance of OpenRocket or later when OpenRocket is
- * executed again while running.
- *
- * @param args the command-line arguments.
- * @return whether a new frame was opened or similar user desired action was
- * performed as a result.
- */
- public static boolean handleCommandLine(String[] args) {
-
- // Check command-line for files
- boolean opened = false;
- for (String file : args) {
- if (open(new File(file), null)) {
- opened = true;
- }