Пример #1
0
  @Override
  protected void finish() {
    if (canceled) return;
    if (lastException != null) {
      ExceptionDialogUtil.explainException(lastException);
    }
    Runnable r =
        new Runnable() {
          public void run() {
            ChangesetCache.getInstance().update(downloadedChangesets);
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      r.run();
    } else {
      try {
        SwingUtilities.invokeAndWait(r);
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        if (t instanceof RuntimeException) {
          BugReportExceptionHandler.handleException(t);
        } else if (t instanceof Exception) {
          ExceptionUtil.explainException(e);
        } else {
          BugReportExceptionHandler.handleException(t);
        }
      }
    }
  }
Пример #2
0
  /**
   * Sets up the viewport to prepare for drawing the view.
   *
   * @return <code>true</code> if the view can be drawn, <code>false</code> otherwise.
   */
  public boolean prepareToDraw() {
    if (initialViewport != null) {
      zoomTo(initialViewport);
      initialViewport = null;
    }
    if (BugReportExceptionHandler.exceptionHandlingInProgress()) return false;

    if (getCenter() == null) return false; // no data loaded yet.

    // if the position was remembered, we need to adjust center once before repainting
    if (oldLoc != null && oldSize != null) {
      Point l1 = getLocationOnScreen();
      final EastNorth newCenter =
          new EastNorth(
              getCenter().getX()
                  + (l1.x - oldLoc.x - (oldSize.width - getWidth()) / 2.0) * getScale(),
              getCenter().getY()
                  + (oldLoc.y - l1.y + (oldSize.height - getHeight()) / 2.0) * getScale());
      oldLoc = null;
      oldSize = null;
      zoomTo(newCenter);
    }

    return true;
  }
Пример #3
0
 /**
  * Explains a {@link InvocationTargetException }
  *
  * @param e the exception
  */
 public static void explainNestedInvocationTargetException(Exception e) {
   InvocationTargetException ex = getNestedException(e, InvocationTargetException.class);
   if (ex != null) {
     // Users should be able to submit a bug report for an invocation target exception
     //
     BugReportExceptionHandler.handleException(ex);
     return;
   }
 }
Пример #4
0
 @Override
 public void stateChanged(ChangeEvent e) {
   int index = getSelectedIndex();
   Component sel = getSelectedComponent();
   if (index > -1 && sel instanceof PreferenceTab) {
     PreferenceTab tab = (PreferenceTab) sel;
     TabPreferenceSetting preferenceSettings = tab.getTabPreferenceSetting();
     if (!settingsInitialized.contains(preferenceSettings)) {
       try {
         getModel().removeChangeListener(this);
         preferenceSettings.addGui(this);
         // Add GUI for sub preferences
         for (PreferenceSetting setting : settings) {
           if (setting instanceof SubPreferenceSetting) {
             SubPreferenceSetting sps = (SubPreferenceSetting) setting;
             if (sps.getTabPreferenceSetting(this) == preferenceSettings) {
               try {
                 sps.addGui(this);
               } catch (SecurityException ex) {
                 ex.printStackTrace();
               } catch (Throwable ex) {
                 BugReportExceptionHandler.handleException(ex);
               } finally {
                 settingsInitialized.add(sps);
               }
             }
           }
         }
         Icon icon = getIconAt(index);
         remove(index);
         insertGUITabsForSetting(icon, preferenceSettings, index);
         setSelectedIndex(index);
       } catch (SecurityException ex) {
         ex.printStackTrace();
       } catch (Throwable ex) {
         // allow to change most settings even if e.g. a plugin fails
         BugReportExceptionHandler.handleException(ex);
       } finally {
         settingsInitialized.add(preferenceSettings);
         getModel().addChangeListener(this);
       }
     }
   }
 }
Пример #5
0
 /**
  * Explains an exception with a generic message dialog
  *
  * @param e the exception
  */
 public static void explainGeneric(Exception e) {
   Main.error(e);
   BugReportExceptionHandler.handleException(e);
 }