| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.gui.bugreport;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 5 |
|
|---|
| 6 | import java.awt.GridBagConstraints;
|
|---|
| 7 | import java.awt.GridBagLayout;
|
|---|
| 8 |
|
|---|
| 9 | import javax.swing.JOptionPane;
|
|---|
| 10 | import javax.swing.JPanel;
|
|---|
| 11 | import javax.swing.SwingUtilities;
|
|---|
| 12 |
|
|---|
| 13 | import org.openstreetmap.josm.gui.MainApplication;
|
|---|
| 14 | import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
|
|---|
| 15 | import org.openstreetmap.josm.gui.widgets.UrlLabel;
|
|---|
| 16 | import org.openstreetmap.josm.spi.preferences.Config;
|
|---|
| 17 | import org.openstreetmap.josm.tools.GBC;
|
|---|
| 18 | import org.openstreetmap.josm.tools.OpenBrowser;
|
|---|
| 19 | import org.openstreetmap.josm.tools.bugreport.BugReportSender.BugReportSendingHandler;
|
|---|
| 20 |
|
|---|
| 21 | /**
|
|---|
| 22 | * Default bug report callback that opens the bug report form in user browser
|
|---|
| 23 | * and displays a dialog in case of error.
|
|---|
| 24 | * @since 14176
|
|---|
| 25 | */
|
|---|
| 26 | public class DefaultBugReportSendingHandler implements BugReportSendingHandler {
|
|---|
| 27 |
|
|---|
| 28 | @Override
|
|---|
| 29 | public String sendingBugReport(String bugUrl, String statusText) {
|
|---|
| 30 | return OpenBrowser.displayUrl(bugUrl);
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | @Override
|
|---|
| 34 | public void failed(String errorMessage, String statusText) {
|
|---|
| 35 | SwingUtilities.invokeLater(() -> {
|
|---|
| 36 | JPanel errorPanel = new JPanel(new GridBagLayout());
|
|---|
| 37 | errorPanel.add(new JMultilineLabel(
|
|---|
| 38 | tr("Opening the bug report failed. Please report manually using this website:")),
|
|---|
| 39 | GBC.eol().fill(GridBagConstraints.HORIZONTAL));
|
|---|
| 40 | errorPanel.add(new UrlLabel(Config.getUrls().getJOSMWebsite() + "/newticket", 2), GBC.eop().insets(8, 0, 0, 0));
|
|---|
| 41 | errorPanel.add(new DebugTextDisplay(statusText));
|
|---|
| 42 |
|
|---|
| 43 | JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorPanel, tr("You have encountered a bug in JOSM"),
|
|---|
| 44 | JOptionPane.ERROR_MESSAGE);
|
|---|
| 45 | });
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|