Changeset 2784 in josm for trunk/src


Ignore:
Timestamp:
2010-01-09T00:50:20+01:00 (14 years ago)
Author:
mjulius
Message:

improve bug dialog

File:
1 edited

Legend:

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

    r2721 r2784  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
    67import java.awt.GridBagLayout;
    78import java.awt.Toolkit;
     
    1213import java.io.PrintWriter;
    1314import java.io.StringWriter;
     15import java.net.URL;
    1416
    1517import javax.swing.JLabel;
     
    2123import org.openstreetmap.josm.Main;
    2224import org.openstreetmap.josm.actions.ShowStatusReportAction;
     25import org.openstreetmap.josm.gui.JMultilineLabel;
    2326import org.openstreetmap.josm.plugins.PluginHandler;
    24 import org.openstreetmap.josm.tools.Base64;
    25 
    26 import java.net.URL;
    27 import java.net.URLEncoder;
    28 import org.openstreetmap.josm.tools.UrlLabel;
    2927
    3028/**
     
    4745                        "where ### is the number of MB assigned to JOSM (e.g. 256).\n" +
    4846                        "Currently, " + Runtime.getRuntime().maxMemory()/1024/1024 + " MB are available to JOSM.",
    49                         tr("Error"),
     47                        "Error",
    5048                        JOptionPane.ERROR_MESSAGE
    5149                );
     
    7371                    if(urltext.length() > maxlen)
    7472                    {
    75                          urltext = urltext.substring(0,maxlen);
    76                          int idx = urltext.lastIndexOf("\n");
    77                          /* cut whole line when not loosing too much */
    78                          if(maxlen-idx < 200)
    79                              urltext = urltext.substring(0,idx+1);
    80                          urltext += "...<snip>...\n";
     73                        urltext = urltext.substring(0,maxlen);
     74                        int idx = urltext.lastIndexOf("\n");
     75                        /* cut whole line when not loosing too much */
     76                        if(maxlen-idx < 200) {
     77                            urltext = urltext.substring(0,idx+1);
     78                        }
     79                        urltext += "...<snip>...\n";
    8180                    }
    8281
    8382                    URL url = new URL("http://josm.openstreetmap.de/josmticket?" +
    84                                       "data="+
    85                                       Base64.encode(
    86                                       // To note that it came from this code
    87                                       "keywords=template_report&" +
    88                                       "description=" + java.net.URLEncoder.encode(
    89                                                          // Note: This doesn't use tr() intentionally, we want bug reports in English
    90                                                          "What steps will reproduce the problem?\n"
    91                                                             + " 1. \n"
    92                                                             + " 2. \n"
    93                                                             + " 3. \n"
    94                                                             + "\n"
    95                                                             + "What is the expected result?\n\n"
    96                                                             + "What happens instead?\n\n"
    97                                                             + "Please provide any additional information below. Attach a screenshot if\n"
    98                                                             + "possible.\n\n"
    99                                                             + "{{{\n" + urltext + "\n}}}\n",
    100                                                          "UTF-8")));
     83                            "data="+
     84                            Base64.encode(
     85                                    // To note that it came from this code
     86                                    "keywords=template_report&" +
     87                                    "description=" + java.net.URLEncoder.encode(
     88                                            // Note: This doesn't use tr() intentionally, we want bug reports in English
     89                                            "What steps will reproduce the problem?\n"
     90                                            + " 1. \n"
     91                                            + " 2. \n"
     92                                            + " 3. \n"
     93                                            + "\n"
     94                                            + "What is the expected result?\n\n"
     95                                            + "What happens instead?\n\n"
     96                                            + "Please provide any additional information below. Attach a screenshot if\n"
     97                                            + "possible.\n\n"
     98                                            + "{{{\n" + urltext + "\n}}}\n",
     99                                    "UTF-8")));
    101100
    102101                    JPanel p = new JPanel(new GridBagLayout());
    103                     p.add(new JLabel(tr("<html>" +
    104                                         "<p>You've encountered an error in JOSM. Before you file a bug<br>" +
    105                                         "make sure you've updated to the latest version of JOSM here:</p></html>")), GBC.eol());
     102                    p.add(new JMultilineLabel(
     103                            tr("You have encountered an error in JOSM. Before you file a bug report" +
     104                            "make sure you have updated to the latest version of JOSM here:")), GBC.eol());
    106105                    p.add(new UrlLabel("http://josm.openstreetmap.de/#Download"), GBC.eop().insets(8,0,0,0));
    107                     p.add(new JLabel(tr("<html>You should also update your plugins. If neither of those help please<br>" +
    108                                         "file a bug in our bugtracker using this link:</p></html>")), GBC.eol());
     106                    p.add(new JMultilineLabel(
     107                            tr("You should also update your plugins. If neither of those help please" +
     108                            "file a bug report in our bugtracker using this link:")), GBC.eol());
    109109                    p.add(new UrlLabel(url.toString(), "http://josm.openstreetmap.de/josmticket?..."), GBC.eop().insets(8,0,0,0));
    110                     p.add(new JLabel(tr("<html><p>" +
    111                                         "There the error information provided below should already be<br>" +
    112                                         "filled out for you. Please include information on how to reproduce<br>" +
    113                                         "the error and try to supply as much detail as possible.</p></html>")), GBC.eop());
    114                     p.add(new JLabel(tr("<html><p>" +
    115                                         "Alternatively if that doesn't work you can manually fill in the information<br>" +
    116                                         "below at this URL:</p></html>")), GBC.eol());
     110                    p.add(new JMultilineLabel(
     111                            tr("There the error information provided below should already be" +
     112                                    "filled in for you. Please include information on how to reproduce" +
     113                            "the error and try to supply as much detail as possible.")), GBC.eop());
     114                    p.add(new JMultilineLabel(
     115                            tr("Alternatively, if that doesn't work you can manually fill in the information" +
     116                            "below at this URL:")), GBC.eol());
    117117                    p.add(new UrlLabel("http://josm.openstreetmap.de/newticket"), GBC.eop().insets(8,0,0,0));
    118118                    try {
     
    129129                    p.add(new JScrollPane(info), GBC.eop());
    130130
    131                     JOptionPane.showMessageDialog(Main.parent, p, tr("You've encountered a bug in JOSM"), JOptionPane.ERROR_MESSAGE);
     131                    for (Component c: p.getComponents()) {
     132                        if (c instanceof JMultilineLabel) {
     133                            ((JMultilineLabel)c).setMaxWidth(400);
     134                        }
     135                    }
     136
     137                    JOptionPane.showMessageDialog(Main.parent, p, tr("You have encountered a bug in JOSM"), JOptionPane.ERROR_MESSAGE);
    132138                } catch (Exception e1) {
    133139                    e1.printStackTrace();
Note: See TracChangeset for help on using the changeset viewer.