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

Last change on this file since 8582 was 8510, checked in by Don-vip, 9 years ago

checkstyle: enable relevant whitespace checks and fix them

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