Ignore:
Timestamp:
2016-03-27T04:01:39+02:00 (4 years ago)
Author:
Don-vip
Message:

fix #12652 - Do not ...snip... bug report messages after 6000 characters (patch by michael2402, modified)

Location:
trunk/src/org/openstreetmap/josm/tools/bugreport
Files:
3 added
1 moved

Legend:

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

    r10049 r10055  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.tools;
     2package org.openstreetmap.josm.tools.bugreport;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    1616import java.util.zip.GZIPOutputStream;
    1717
     18import javax.swing.JButton;
    1819import javax.swing.JCheckBox;
    1920import javax.swing.JLabel;
    2021import javax.swing.JOptionPane;
    2122import javax.swing.JPanel;
    22 import javax.swing.JScrollPane;
    2323import javax.swing.SwingUtilities;
    2424
    2525import org.openstreetmap.josm.Main;
     26import org.openstreetmap.josm.actions.ReportBugAction;
    2627import org.openstreetmap.josm.actions.ShowStatusReportAction;
    2728import org.openstreetmap.josm.data.Version;
     
    2930import org.openstreetmap.josm.gui.preferences.plugin.PluginPreference;
    3031import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    31 import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    3232import org.openstreetmap.josm.gui.widgets.UrlLabel;
    3333import org.openstreetmap.josm.plugins.PluginDownloadTask;
    3434import org.openstreetmap.josm.plugins.PluginHandler;
     35import org.openstreetmap.josm.tools.Base64;
     36import org.openstreetmap.josm.tools.GBC;
     37import org.openstreetmap.josm.tools.WikiReader;
    3538
    3639/**
     
    194197    private static void askForBugReport(final Throwable e) {
    195198        try {
    196             final int maxlen = 6000;
    197199            StringWriter stack = new StringWriter();
    198200            e.printStackTrace(new PrintWriter(stack));
    199201
    200202            String text = ShowStatusReportAction.getReportHeader() + stack.getBuffer().toString();
    201             String urltext = text.replaceAll("\r", "");
    202             if (urltext.length() > maxlen) {
    203                 urltext = urltext.substring(0, maxlen);
    204                 int idx = urltext.lastIndexOf('\n');
    205                 // cut whole line when not loosing too much
    206                 if (maxlen-idx < 200) {
    207                     urltext = urltext.substring(0, idx+1);
    208                 }
    209                 urltext += "...<snip>...\n";
    210             }
     203            text = text.replaceAll("\r", "");
    211204
    212205            JPanel p = new JPanel(new GridBagLayout());
     
    220213                            "file a bug report in our bugtracker using this link:")),
    221214                            GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    222             p.add(getBugReportUrlLabel(urltext), GBC.eop().insets(8, 0, 0, 0));
     215            p.add(new JButton(new ReportBugAction(text)), GBC.eop().insets(8, 0, 0, 0));
    223216            p.add(new JMultilineLabel(
    224217                    tr("There the error information provided below should already be " +
     
    232225
    233226            // Wiki formatting for manual copy-paste
    234             text = "{{{\n"+text+"}}}";
    235 
    236             if (Utils.copyToClipboard(text)) {
     227            DebugTextDisplay textarea = new DebugTextDisplay(text);
     228
     229            if (textarea.copyToClippboard()) {
    237230                p.add(new JLabel(tr("(The text has already been copied to your clipboard.)")),
    238231                        GBC.eop().fill(GridBagConstraints.HORIZONTAL));
    239232            }
    240233
    241             JosmTextArea info = new JosmTextArea(text, 18, 60);
    242             info.setCaretPosition(0);
    243             info.setEditable(false);
    244             p.add(new JScrollPane(info), GBC.eop().fill());
     234            p.add(textarea, GBC.eop().fill());
    245235
    246236            for (Component c: p.getComponents()) {
     
    265255
    266256    /**
    267      * Replies the URL to create a JOSM bug report with the given debug text
     257     * Replies the URL to create a JOSM bug report with the given debug text. GZip is used to reduce the length of the parameter.
    268258     * @param debugText The debug text to provide us
    269259     * @return The URL to create a JOSM bug report with the given debug text
     260     * @see BugReportSender#reportBug(String) if you want to send long debug texts along.
    270261     * @since 5849
    271262     */
Note: See TracChangeset for help on using the changeset viewer.