Changeset 4607 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2011-11-23T20:31:30+01:00 (12 years ago)
Author:
bastiK
Message:

fixed #7072 - add option to exception dialog to suppress all further error dialogs for the current session

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r4380 r4607  
    1111import java.nio.ByteBuffer;
    1212
     13import javax.swing.JCheckBox;
    1314import javax.swing.JLabel;
    1415import javax.swing.JOptionPane;
     
    2223import org.openstreetmap.josm.plugins.PluginHandler;
    2324
     25import javax.swing.JPanel;
     26import org.openstreetmap.josm.gui.ExtendedDialog;
     27import org.openstreetmap.josm.tools.GBC;
     28import java.awt.GridBagLayout;
     29
    2430/**
    2531 * An exception handler that asks the user to send a bug report.
     
    3036
    3137    private static boolean handlingInProgress = false;
     38    private static int exceptionCounter = 0;
     39    private static boolean suppressExceptionDialogs = false;
    3240
    3341    public void uncaughtException(Thread t, Throwable e) {
     
    4351        if (handlingInProgress)
    4452            return;                  // we do not handle secondary exceptions, this gets too messy
     53        if (suppressExceptionDialogs)
     54            return;
    4555        handlingInProgress = true;
     56        exceptionCounter++;
    4657        try {
    4758            e.printStackTrace();
     
    6677                // Then ask for submitting a bug report, for exceptions thrown from a plugin too
    6778                //
    68                 Object[] options = new String[]{tr("Do nothing"), tr("Report Bug")};
    69                 int answer = JOptionPane.showOptionDialog(
    70                         Main.parent,
     79                ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Unexpected Exception"), new String[] {tr("Do nothing"), tr("Report Bug")});
     80                ed.setIcon(JOptionPane.ERROR_MESSAGE);
     81                JPanel pnl = new JPanel(new GridBagLayout());
     82                pnl.add(new JLabel(
    7183                        "<html>"
    7284                        + tr("An unexpected exception occurred.<br>" +
     
    7486                                "version of JOSM, please consider being kind and file a bug report."
    7587                        )
    76                         + "</html>",
    77                         tr("Unexpected Exception"),
    78                         JOptionPane.YES_NO_OPTION,
    79                         JOptionPane.ERROR_MESSAGE,
    80                         null,
    81                         options, options[0]
    82                 );
    83                 if (answer != 1)  return;
    84 
     88                        + "</html>"), GBC.eol());
     89                JCheckBox cbSuppress = null;
     90                if (exceptionCounter > 1) {
     91                    cbSuppress = new JCheckBox(tr("Suppress further error dialogs for this session."));
     92                    pnl.add(cbSuppress, GBC.eol());
     93                }
     94                ed.setContent(pnl);
     95                ed.showDialog();
     96                if (cbSuppress != null && cbSuppress.isSelected()) {
     97                    suppressExceptionDialogs = true;
     98                }
     99                if (ed.getValue() != 2) return;
     100               
    85101                try {
    86102                    final int maxlen = 6000;
Note: See TracChangeset for help on using the changeset viewer.