예제 #1
0
파일: Main.java 프로젝트: p2y/arx
 /**
  * Loads a project.
  *
  * @param main
  * @param path
  */
 private static void load(MainWindow main, String path) {
   if (loaded == null) {
     loaded = path;
     if (splash != null) splash.hide();
     main.getController().actionOpenProject(path);
   }
 }
예제 #2
0
파일: Main.java 프로젝트: p2y/arx
  /**
   * Main entry point.
   *
   * @param args
   */
  public static void main(Display display, final String[] args) {

    try {
      // Make fall-back toolkit look like the native UI
      if (!isUnix()) { // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=341799
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      }
    } catch (ClassNotFoundException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException e) {
      // Ignore
    }

    try {

      // Display
      if (display == null) {
        display = new Display();
      }

      // Monitor
      Monitor monitor = getMonitor(display);

      // Splash
      splash = new MainSplash(display, monitor);
      splash.show();

      // Create main window
      main = new MainWindow(display, monitor);

      // Handler for loading a project
      if (args.length > 0 && args[0].endsWith(".deid")) { // $NON-NLS-1$
        main.onShow(
            new Runnable() {
              public void run() {
                load(main, args[0]);
              }
            });
      }

      // Show window
      main.show();

      new Update(main.getShell());

      // Main event loop
      while (!main.isDisposed()) {
        try {

          // Event handling
          if (!display.readAndDispatch()) {
            display.sleep();
          }
        } catch (final Exception e) {

          // Error handling
          main.showErrorDialog(
              Resources.getMessage("MainWindow.9") + Resources.getMessage("MainWindow.10"),
              e); //$NON-NLS-1$ //$NON-NLS-2$
          StringWriter sw = new StringWriter();
          PrintWriter pw = new PrintWriter(sw);
          e.printStackTrace(pw);
          main.getController().getResources().getLogger().info(sw.toString());
        }
      }

      // Dispose display
      if (!display.isDisposed()) {
        display.dispose();
      }
    } catch (Throwable e) {

      // Error handling outside of SWT
      if (splash != null) splash.hide();
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      final String trace = sw.toString();

      // Show message
      JOptionPane.showMessageDialog(
          null, trace, "Unexpected error", JOptionPane.ERROR_MESSAGE); // $NON-NLS-1$
      System.exit(1);
    }
  }