source: josm/trunk/src/org/openstreetmap/josm/actions/AboutAction.java@ 5849

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

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

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1//License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Dimension;
7import java.awt.GridBagLayout;
8import java.awt.event.ActionEvent;
9import java.awt.event.KeyEvent;
10
11import javax.swing.BorderFactory;
12import javax.swing.JLabel;
13import javax.swing.JOptionPane;
14import javax.swing.JPanel;
15import javax.swing.JScrollPane;
16import javax.swing.JTabbedPane;
17import javax.swing.JTextArea;
18
19import org.openstreetmap.josm.Main;
20import org.openstreetmap.josm.data.Version;
21import org.openstreetmap.josm.gui.util.GuiHelper;
22import org.openstreetmap.josm.plugins.PluginHandler;
23import org.openstreetmap.josm.tools.BugReportExceptionHandler;
24import org.openstreetmap.josm.tools.GBC;
25import org.openstreetmap.josm.tools.ImageProvider;
26import org.openstreetmap.josm.tools.Shortcut;
27import org.openstreetmap.josm.tools.UrlLabel;
28import org.openstreetmap.josm.tools.Utils;
29
30/**
31 * Nice about screen. I guess every application need one these days.. *sigh*
32 *
33 * The REVISION resource is read and if present, it shows the revision
34 * information of the jar-file.
35 *
36 * @author imi
37 */
38public class AboutAction extends JosmAction {
39
40 public AboutAction() {
41 super(tr("About"), "about", tr("Display the about screen."),
42 Shortcut.registerShortcut("system:about", tr("About"),
43 KeyEvent.VK_F1, Shortcut.SHIFT), true);
44 }
45
46 public void actionPerformed(ActionEvent e) {
47 final JTabbedPane about = new JTabbedPane();
48
49 Version version = Version.getInstance();
50
51 JTextArea readme = new JTextArea();
52 readme.setEditable(false);
53 readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
54 readme.setCaretPosition(0);
55
56 JTextArea revision = new JTextArea();
57 revision.setEditable(false);
58 revision.setText(version.getReleaseAttributes());
59 revision.setCaretPosition(0);
60
61 JTextArea contribution = new JTextArea();
62 contribution.setEditable(false);
63 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
64 contribution.setCaretPosition(0);
65
66 JTextArea license = new JTextArea();
67 license.setEditable(false);
68 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
69 license.setCaretPosition(0);
70
71 JPanel info = new JPanel(new GridBagLayout());
72 JLabel caption = new JLabel("JOSM – " + tr("Java OpenStreetMap Editor"));
73 caption.setFont(GuiHelper.getTitleFont());
74 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
75 info.add(GBC.glue(0,10), GBC.eol());
76 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
77 info.add(GBC.glue(0,5), GBC.eol());
78 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
79 info.add(GBC.glue(0,5), GBC.eol());
80 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
81 info.add(GBC.glue(0,10), GBC.eol());
82 info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
83 info.add(new UrlLabel("http://josm.openstreetmap.de",2), GBC.eol().fill(GBC.HORIZONTAL));
84 info.add(GBC.glue(0,5), GBC.eol());
85 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
86 info.add(BugReportExceptionHandler.getBugReportUrlLabel(Utils.strip(ShowStatusReportAction.getReportHeader())), GBC.eol().fill(GBC.HORIZONTAL));
87
88 about.addTab(tr("Info"), info);
89 about.addTab(tr("Readme"), createScrollPane(readme));
90 about.addTab(tr("Revision"), createScrollPane(revision));
91 about.addTab(tr("Contribution"), createScrollPane(contribution));
92 about.addTab(tr("License"), createScrollPane(license));
93 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
94
95 // Intermediate panel to allow proper optionPane resizing
96 JPanel panel = new JPanel(new GridBagLayout());
97 panel.setPreferredSize(new Dimension(600, 300));
98 panel.add(about, GBC.std().fill());
99
100 GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
101 JOptionPane.showMessageDialog(Main.parent, panel, tr("About JOSM..."),
102 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
103 }
104
105 private JScrollPane createScrollPane(JTextArea area) {
106 area.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
107 area.setOpaque(false);
108 JScrollPane sp = new JScrollPane(area);
109 sp.setBorder(null);
110 sp.setOpaque(false);
111 return sp;
112 }
113}
Note: See TracBrowser for help on using the repository browser.