Changeset 10062 in josm
- Timestamp:
- 2016-03-28T00:22:42+02:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r10055 r10062 18 18 import javax.swing.ImageIcon; 19 19 import javax.swing.JLabel; 20 import javax.swing.JOptionPane;21 20 import javax.swing.JPanel; 22 21 import javax.swing.JScrollPane; … … 26 25 import org.openstreetmap.josm.Main; 27 26 import org.openstreetmap.josm.data.Version; 27 import org.openstreetmap.josm.gui.ExtendedDialog; 28 28 import org.openstreetmap.josm.gui.util.GuiHelper; 29 29 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 34 34 import org.openstreetmap.josm.tools.ImageProvider; 35 35 import org.openstreetmap.josm.tools.Shortcut; 36 import org.openstreetmap.josm.tools.Utils;37 import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;38 36 39 37 /** … … 96 94 info.add(new UrlLabel(Main.getJOSMWebsite(), 2), GBC.eol().fill(GBC.HORIZONTAL)); 97 95 info.add(GBC.glue(0, 5), GBC.eol()); 98 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10, 0, 10, 0));99 info.add(BugReportExceptionHandler.getBugReportUrlLabel(Utils.strip(ShowStatusReportAction.getReportHeader())),100 GBC.eol().fill(GBC.HORIZONTAL));101 96 102 97 about.addTab(tr("Info"), info); … … 109 104 // Intermediate panel to allow proper optionPane resizing 110 105 JPanel panel = new JPanel(new GridBagLayout()); 111 panel.setPreferredSize(new Dimension(600, 300)); 106 panel.setPreferredSize(new Dimension(890, 300)); 107 panel.add(new JLabel("", new ImageIcon(ImageProvider.get("logo.svg").getImage().getScaledInstance(256, 258, Image.SCALE_SMOOTH)), 108 JLabel.CENTER), GBC.std().insets(0, 5, 0, 0)); 112 109 panel.add(about, GBC.std().fill()); 113 110 114 111 GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize()); 115 JOptionPane.showMessageDialog(Main.parent, panel, tr("About JOSM..."), JOptionPane.INFORMATION_MESSAGE, 116 new ImageIcon(ImageProvider.get("logo.svg").getImage().getScaledInstance(256, 258, Image.SCALE_SMOOTH))); 112 int ret = new ExtendedDialog(Main.parent, tr("About JOSM..."), new String[] {tr("OK"), tr("Report bug")}) 113 .setButtonIcons(new String[] {"ok", "bug"}) 114 .setContent(panel, false) 115 .showDialog().getValue(); 116 if (2 == ret) { 117 Main.main.menu.reportbug.actionPerformed(null); 118 } 117 119 } 118 120 -
trunk/src/org/openstreetmap/josm/actions/ReportBugAction.java
r10055 r10062 22 22 */ 23 23 public ReportBugAction() { 24 this( ShowStatusReportAction.getReportHeader());24 this(null); 25 25 } 26 26 … … 38 38 @Override 39 39 public void actionPerformed(ActionEvent e) { 40 BugReportSender.reportBug(text );40 BugReportSender.reportBug(text == null ? ShowStatusReportAction.getReportHeader() : text); 41 41 } 42 42 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandler.java
r10055 r10062 7 7 import java.awt.GridBagConstraints; 8 8 import java.awt.GridBagLayout; 9 import java.io.ByteArrayOutputStream;10 9 import java.io.IOException; 11 10 import java.io.PrintWriter; 12 11 import java.io.StringWriter; 13 import java.net.URL;14 import java.nio.ByteBuffer;15 import java.nio.charset.StandardCharsets;16 import java.util.zip.GZIPOutputStream;17 12 18 13 import javax.swing.JButton; … … 33 28 import org.openstreetmap.josm.plugins.PluginDownloadTask; 34 29 import org.openstreetmap.josm.plugins.PluginHandler; 35 import org.openstreetmap.josm.tools.Base64;36 30 import org.openstreetmap.josm.tools.GBC; 37 31 import org.openstreetmap.josm.tools.WikiReader; … … 154 148 155 149 /** 156 * Handles the given throwable object157 * @param t The throwable object158 */159 public void handle(Throwable t) {160 handleException(t);161 }162 163 /**164 150 * Handles the given exception 165 151 * @param e the exception … … 253 239 return handlingInProgress; 254 240 } 255 256 /**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.258 * @param debugText The debug text to provide us259 * @return The URL to create a JOSM bug report with the given debug text260 * @see BugReportSender#reportBug(String) if you want to send long debug texts along.261 * @since 5849262 */263 public static URL getBugReportUrl(String debugText) {264 try (265 ByteArrayOutputStream out = new ByteArrayOutputStream();266 GZIPOutputStream gzip = new GZIPOutputStream(out)267 ) {268 gzip.write(debugText.getBytes(StandardCharsets.UTF_8));269 gzip.finish();270 271 return new URL(Main.getJOSMWebsite()+"/josmticket?" +272 "gdata="+Base64.encode(ByteBuffer.wrap(out.toByteArray()), true));273 } catch (IOException e) {274 Main.error(e);275 return null;276 }277 }278 279 /**280 * Replies the URL label to create a JOSM bug report with the given debug text281 * @param debugText The debug text to provide us282 * @return The URL label to create a JOSM bug report with the given debug text283 * @since 5849284 */285 public static UrlLabel getBugReportUrlLabel(String debugText) {286 URL url = getBugReportUrl(debugText);287 if (url != null) {288 return new UrlLabel(url.toString(), Main.getJOSMWebsite()+"/josmticket?...", 2);289 }290 return null;291 }292 241 } -
trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandlerTest.java
r10055 r10062 2 2 package org.openstreetmap.josm.tools.bugreport; 3 3 4 import static org.junit.Assert.assertEquals;5 import static org.junit.Assert.assertTrue;6 7 import java.io.ByteArrayInputStream;8 import java.io.IOException;9 import java.nio.charset.StandardCharsets;10 import java.util.zip.GZIPInputStream;11 12 import javax.xml.bind.DatatypeConverter;13 14 4 import org.junit.Before; 15 import org.junit.Test;16 5 import org.openstreetmap.josm.JOSMFixture; 17 import org.openstreetmap.josm.Main;18 import org.openstreetmap.josm.actions.ShowStatusReportAction;19 6 20 7 /** … … 30 17 JOSMFixture.createUnitTestFixture().init(); 31 18 } 32 33 /**34 * Test method for {@link org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler#getBugReportUrl(java.lang.String)}.35 * @throws IOException if any I/O error occurs36 */37 @Test38 public void testGetBugReportUrl() throws IOException {39 String report = ShowStatusReportAction.getReportHeader();40 String url = BugReportExceptionHandler.getBugReportUrl(report).toExternalForm();41 String prefix = Main.getJOSMWebsite()+"/josmticket?gdata=";42 assertTrue(url.startsWith(prefix));43 44 String gdata = url.substring(prefix.length());45 // JAXB only provides support for "base64" decoding while we encode url in "base64url", so switch encoding, only for test purpose46 byte[] data = DatatypeConverter.parseBase64Binary(gdata.replace('-', '+').replace('_', '/'));47 byte[] buff = new byte[8192];48 try (GZIPInputStream is = new GZIPInputStream(new ByteArrayInputStream(data))) {49 StringBuilder sb = new StringBuilder();50 for (int n = is.read(buff); n > 0; n = is.read(buff)) {51 sb.append(new String(buff, 0, n, StandardCharsets.UTF_8));52 }53 assertEquals(report, sb.toString());54 }55 }56 19 }
Note:
See TracChangeset
for help on using the changeset viewer.