source: josm/trunk/src/org/openstreetmap/josm/gui/bugreport/DefaultBugReportSendingHandler.java@ 14176

Last change on this file since 14176 was 14176, checked in by Don-vip, 6 years ago

see #16666 - extract DefaultBugReportSendingHandler to its own class in order to control AWT loading. Having it defined as a public static field of BugReportDialog class makes Java load AWT way too early.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.bugreport;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagConstraints;
7import java.awt.GridBagLayout;
8
9import javax.swing.JOptionPane;
10import javax.swing.JPanel;
11import javax.swing.SwingUtilities;
12
13import org.openstreetmap.josm.gui.MainApplication;
14import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
15import org.openstreetmap.josm.gui.widgets.UrlLabel;
16import org.openstreetmap.josm.spi.preferences.Config;
17import org.openstreetmap.josm.tools.GBC;
18import org.openstreetmap.josm.tools.OpenBrowser;
19import 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 */
26public 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}
Note: See TracBrowser for help on using the repository browser.