Ticket #2160: AddStautsReport.patch
File AddStautsReport.patch, 7.3 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.actions; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.Dimension; 7 import java.awt.Toolkit; 8 import java.awt.datatransfer.Clipboard; 9 import java.awt.datatransfer.ClipboardOwner; 10 import java.awt.datatransfer.StringSelection; 11 import java.awt.datatransfer.Transferable; 12 import java.awt.event.ActionEvent; 13 import java.awt.event.KeyEvent; 14 import java.io.BufferedReader; 15 import java.io.File; 16 import java.io.FileReader; 17 18 import javax.swing.JScrollPane; 19 import javax.swing.JTextArea; 20 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.gui.ExtendedDialog; 23 import org.openstreetmap.josm.plugins.PluginHandler; 24 import org.openstreetmap.josm.tools.Shortcut; 25 26 /** 27 * @author xeen 28 * 29 * Opens a dialog with useful status information like version numbers for Java, JOSM and plugins 30 * Also includes preferences with stripped username and password 31 */ 32 public final class ShowStatusReportAction extends JosmAction { 33 public ShowStatusReportAction() { 34 super( 35 tr("Show Status Report"), 36 "clock", 37 tr("Show status report with useful information that can be attached to bugs"), 38 Shortcut.registerShortcut("help:showstatusreport", tr("Help: {0}", 39 tr("Show Status Report")), KeyEvent.VK_R, Shortcut.GROUP_NONE), true); 40 41 } 42 43 public void actionPerformed(ActionEvent e) { 44 StringBuilder text = new StringBuilder(); 45 text.append(AboutAction.getTextBlock()); 46 text.append("\n\n"); 47 text.append("Java version: " + System.getProperty("java.version")); 48 text.append("\n\n"); 49 text.append(PluginHandler.getBugReportText()); 50 text.append("\n\n"); 51 try { 52 BufferedReader input = new BufferedReader(new FileReader(Main.pref 53 .getPreferencesDirFile() 54 + File.separator + "preferences")); 55 try { 56 String line = null; 57 58 while ((line = input.readLine()) != null) { 59 // Skip potential private information 60 if (line.trim().toLowerCase().startsWith("osm-server.username")) 61 continue; 62 if (line.trim().toLowerCase().startsWith("osm-server.password")) 63 continue; 64 if (line.trim().toLowerCase().startsWith("marker.show")) 65 continue; 66 67 text.append(line); 68 text.append("\n"); 69 } 70 } finally { 71 input.close(); 72 } 73 } catch (Exception x) { 74 x.printStackTrace(); 75 } 76 77 JTextArea ta = new JTextArea(text.toString()); 78 ta.setWrapStyleWord(true); 79 ta.setLineWrap(true); 80 ta.setEditable(false); 81 JScrollPane sp = new JScrollPane(ta); 82 sp.setPreferredSize(new Dimension(600, 500)); 83 84 int result = new ExtendedDialog(Main.parent, tr(tr("Status Report")), sp, 85 new String[] {tr("Copy to clipboard and close"), tr("Close") }, 86 new String[] {"copy.png", "cancel.png" }).getValue(); 87 88 if(result != 1) return; 89 try { 90 Toolkit.getDefaultToolkit().getSystemClipboard().setContents( 91 new StringSelection(text.toString()), new ClipboardOwner() { 92 public void lostOwnership(Clipboard clipboard, Transferable contents) {} 93 } 94 ); 95 } 96 catch (RuntimeException x) {} 97 } 98 } -
src/org/openstreetmap/josm/gui/MainMenu.java
6 6 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; 9 import java.awt.event.KeyEvent; 9 10 10 11 import javax.swing.JCheckBoxMenuItem; 11 12 import javax.swing.JMenu; 12 13 import javax.swing.JMenuBar; 13 14 import javax.swing.JMenuItem; 14 15 import javax.swing.KeyStroke; 15 import java.awt.event.KeyEvent;16 16 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.actions.AboutAction; 19 19 import org.openstreetmap.josm.actions.AddNodeAction; 20 20 import org.openstreetmap.josm.actions.AlignInCircleAction; 21 21 import org.openstreetmap.josm.actions.AlignInLineAction; 22 import org.openstreetmap.josm.actions.OpenLocationAction;23 import org.openstreetmap.josm.actions.OrthogonalizeAction;24 22 import org.openstreetmap.josm.actions.AutoScaleAction; 25 23 import org.openstreetmap.josm.actions.CombineWayAction; 26 24 import org.openstreetmap.josm.actions.CopyAction; … … 38 36 import org.openstreetmap.josm.actions.MergeNodesAction; 39 37 import org.openstreetmap.josm.actions.NewAction; 40 38 import org.openstreetmap.josm.actions.OpenFileAction; 39 import org.openstreetmap.josm.actions.OpenLocationAction; 40 import org.openstreetmap.josm.actions.OrthogonalizeAction; 41 41 import org.openstreetmap.josm.actions.PasteAction; 42 42 import org.openstreetmap.josm.actions.PasteTagsAction; 43 43 import org.openstreetmap.josm.actions.PreferencesAction; … … 46 46 import org.openstreetmap.josm.actions.SaveAction; 47 47 import org.openstreetmap.josm.actions.SaveAsAction; 48 48 import org.openstreetmap.josm.actions.SelectAllAction; 49 import org.openstreetmap.josm.actions.ShowStatusReportAction; 49 50 import org.openstreetmap.josm.actions.SplitWayAction; 51 import org.openstreetmap.josm.actions.ToggleGPXLinesAction; 50 52 import org.openstreetmap.josm.actions.UnGlueAction; 51 53 import org.openstreetmap.josm.actions.UndoAction; 52 54 import org.openstreetmap.josm.actions.UnselectAllAction; … … 61 63 import org.openstreetmap.josm.actions.audio.AudioPrevAction; 62 64 import org.openstreetmap.josm.actions.audio.AudioSlowerAction; 63 65 import org.openstreetmap.josm.actions.search.SearchAction; 64 import org.openstreetmap.josm.actions.ToggleGPXLinesAction;65 import org.openstreetmap.josm.data.DataSetChecker;66 66 import org.openstreetmap.josm.tools.Shortcut; 67 67 68 68 /** … … 130 130 /* Help menu */ 131 131 public final HelpAction help = new HelpAction(); 132 132 public final JosmAction about = new AboutAction(); 133 public final JosmAction statusreport = new ShowStatusReportAction(); 133 134 134 135 public final JMenu fileMenu = new JMenu(tr("File")); 135 136 public final JMenu editMenu = new JMenu(tr("Edit")); … … 267 268 } 268 269 }); 269 270 helpMenu.add(check);*/ 270 current = helpMenu.add(help); // why is help not a JosmAction? 271 272 helpMenu.add(statusreport); 273 274 current = helpMenu.add(help); // FIXME why is help not a JosmAction? 271 275 current.setAccelerator(Shortcut.registerShortcut("system:help", tr("Help"), KeyEvent.VK_F1, 272 276 Shortcut.GROUP_DIRECT).getKeyStroke()); 273 277 add(helpMenu, about);