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

Last change on this file since 7722 was 6901, checked in by Don-vip, 10 years ago

see #3764 - make UI messages copy-able (patch by simon04)

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