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.GridBagLayout;
|
---|
8 | import java.awt.Image;
|
---|
9 | import java.awt.event.ActionEvent;
|
---|
10 | import java.awt.event.KeyEvent;
|
---|
11 |
|
---|
12 | import javax.swing.BorderFactory;
|
---|
13 | import javax.swing.ImageIcon;
|
---|
14 | import javax.swing.JLabel;
|
---|
15 | import javax.swing.JOptionPane;
|
---|
16 | import javax.swing.JPanel;
|
---|
17 | import javax.swing.JScrollPane;
|
---|
18 | import javax.swing.JTabbedPane;
|
---|
19 |
|
---|
20 | import org.openstreetmap.josm.Main;
|
---|
21 | import org.openstreetmap.josm.data.Version;
|
---|
22 | import org.openstreetmap.josm.gui.util.GuiHelper;
|
---|
23 | import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
|
---|
24 | import org.openstreetmap.josm.gui.widgets.JosmTextArea;
|
---|
25 | import org.openstreetmap.josm.gui.widgets.UrlLabel;
|
---|
26 | import org.openstreetmap.josm.plugins.PluginHandler;
|
---|
27 | import org.openstreetmap.josm.tools.BugReportExceptionHandler;
|
---|
28 | import org.openstreetmap.josm.tools.GBC;
|
---|
29 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
30 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
31 | import 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 | */
|
---|
40 | public 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 static 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 | }
|
---|