Changeset 5849 in josm


Ignore:
Timestamp:
2013-04-14T00:05:26+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #8584 - see #8571 : Add "Report bug" button in Status report dialog, change bug report link in About dialog

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r5797 r5849  
    55
    66import java.awt.Dimension;
    7 import java.awt.Font;
    87import java.awt.GridBagLayout;
    98import java.awt.event.ActionEvent;
     
    2221import org.openstreetmap.josm.gui.util.GuiHelper;
    2322import org.openstreetmap.josm.plugins.PluginHandler;
     23import org.openstreetmap.josm.tools.BugReportExceptionHandler;
    2424import org.openstreetmap.josm.tools.GBC;
    2525import org.openstreetmap.josm.tools.ImageProvider;
    2626import org.openstreetmap.josm.tools.Shortcut;
    2727import org.openstreetmap.josm.tools.UrlLabel;
     28import org.openstreetmap.josm.tools.Utils;
    2829
    2930/**
     
    8384        info.add(GBC.glue(0,5), GBC.eol());
    8485        info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
    85         info.add(new UrlLabel("http://josm.openstreetmap.de/newticket",2), GBC.eol().fill(GBC.HORIZONTAL));
     86        info.add(BugReportExceptionHandler.getBugReportUrlLabel(Utils.strip(ShowStatusReportAction.getReportHeader())), GBC.eol().fill(GBC.HORIZONTAL));
    8687
    8788        about.addTab(tr("Info"), info);
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r5840 r5849  
    2828import org.openstreetmap.josm.gui.ExtendedDialog;
    2929import org.openstreetmap.josm.plugins.PluginHandler;
     30import org.openstreetmap.josm.tools.BugReportExceptionHandler;
     31import org.openstreetmap.josm.tools.OpenBrowser;
    3032import org.openstreetmap.josm.tools.Shortcut;
    3133import org.openstreetmap.josm.tools.Utils;
     
    113115    public void actionPerformed(ActionEvent e) {
    114116        StringBuilder text = new StringBuilder();
    115         text.append(getReportHeader());
     117        String reportHeader = getReportHeader();
     118        text.append(reportHeader);
    116119        try {
    117120            Map<String, Setting> settings = Main.pref.getAllSettings();
     
    141144        ExtendedDialog ed = new ExtendedDialog(Main.parent,
    142145                tr("Status Report"),
    143                 new String[] {tr("Copy to clipboard and close"), tr("Close") });
    144         ed.setButtonIcons(new String[] {"copy.png", "cancel.png" });
     146                new String[] {tr("Copy to clipboard and close"), tr("Report bug"), tr("Close") });
     147        ed.setButtonIcons(new String[] {"copy.png", "bug.png", "cancel.png" });
    145148        ed.setContent(sp, false);
    146149        ed.setMinimumSize(new Dimension(380, 200));
    147150        ed.setPreferredSize(new Dimension(700, Main.parent.getHeight()-50));
    148151
    149         if (ed.showDialog().getValue() != 1) return;
    150         Utils.copyToClipboard(text.toString());
     152        switch (ed.showDialog().getValue()) {
     153            case 1: Utils.copyToClipboard(text.toString()); break;
     154            case 2: OpenBrowser.displayUrl(BugReportExceptionHandler.getBugReportUrl(
     155                        Utils.strip(reportHeader)).toExternalForm()) ; break;
     156        }
    151157    }
    152158}
  • trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r5827 r5849  
    77import java.awt.GridBagLayout;
    88import java.io.ByteArrayOutputStream;
     9import java.io.IOException;
    910import java.io.PrintWriter;
    1011import java.io.StringWriter;
     
    121122                            }
    122123                           
    123                             ByteArrayOutputStream out = new ByteArrayOutputStream();
    124                             GZIPOutputStream gzip = new GZIPOutputStream(out);
    125                             gzip.write(urltext.getBytes("UTF-8"));
    126                             gzip.close();
    127 
    128                             URL url = new URL("http://josm.openstreetmap.de/josmticket?" +
    129                                     "gdata="+Base64.encode(ByteBuffer.wrap(out.toByteArray()), true));
    130 
    131124                            JPanel p = new JPanel(new GridBagLayout());
    132125                            p.add(new JMultilineLabel(
     
    137130                                    tr("You should also update your plugins. If neither of those help please " +
    138131                                            "file a bug report in our bugtracker using this link:")), GBC.eol());
    139                             p.add(new UrlLabel(url.toString(), "http://josm.openstreetmap.de/josmticket?...",2), GBC.eop().insets(8,0,0,0));
     132                            p.add(getBugReportUrlLabel(urltext), GBC.eop().insets(8,0,0,0));
    140133                            p.add(new JMultilineLabel(
    141134                                    tr("There the error information provided below should already be " +
     
    175168        return handlingInProgress;
    176169    }
     170   
     171    /**
     172     * Replies the URL to create a JOSM bug report with the given debug text
     173     * @param debugText The debug text to provide us
     174     * @return The URL to create a JOSM bug report with the given debug text
     175     * @since 5849
     176     */
     177    public static URL getBugReportUrl(String debugText) {
     178        try {
     179            ByteArrayOutputStream out = new ByteArrayOutputStream();
     180            GZIPOutputStream gzip = new GZIPOutputStream(out);
     181            gzip.write(debugText.getBytes("UTF-8"));
     182            gzip.close();
     183   
     184            return new URL("http://josm.openstreetmap.de/josmticket?" +
     185                    "gdata="+Base64.encode(ByteBuffer.wrap(out.toByteArray()), true));
     186        } catch (IOException e) {
     187            e.printStackTrace();
     188            return null;
     189        }
     190    }
     191   
     192    /**
     193     * Replies the URL label to create a JOSM bug report with the given debug text
     194     * @param debugText The debug text to provide us
     195     * @return The URL label to create a JOSM bug report with the given debug text
     196     * @since 5849
     197     */
     198    public static final UrlLabel getBugReportUrlLabel(String debugText) {
     199        URL url = getBugReportUrl(debugText);
     200        if (url != null) {
     201            return new UrlLabel(url.toString(), "http://josm.openstreetmap.de/josmticket?...", 2);
     202        }
     203        return null;
     204    }
    177205}
Note: See TracChangeset for help on using the changeset viewer.