[6380] | 1 | //License: GPL. For details, see LICENSE file.
|
---|
[626] | 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
[302] | 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 5 |
|
---|
| 6 | import java.awt.Dimension;
|
---|
| 7 | import java.awt.GridBagLayout;
|
---|
| 8 | import java.awt.event.ActionEvent;
|
---|
| 9 | import java.awt.event.KeyEvent;
|
---|
| 10 |
|
---|
| 11 | import javax.swing.BorderFactory;
|
---|
| 12 | import javax.swing.JLabel;
|
---|
| 13 | import javax.swing.JOptionPane;
|
---|
| 14 | import javax.swing.JPanel;
|
---|
| 15 | import javax.swing.JScrollPane;
|
---|
| 16 | import javax.swing.JTabbedPane;
|
---|
| 17 |
|
---|
| 18 | import org.openstreetmap.josm.Main;
|
---|
[2358] | 19 | import org.openstreetmap.josm.data.Version;
|
---|
[5493] | 20 | import org.openstreetmap.josm.gui.util.GuiHelper;
|
---|
[6901] | 21 | import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
|
---|
[5886] | 22 | import org.openstreetmap.josm.gui.widgets.JosmTextArea;
|
---|
[6340] | 23 | import org.openstreetmap.josm.gui.widgets.UrlLabel;
|
---|
[1326] | 24 | import org.openstreetmap.josm.plugins.PluginHandler;
|
---|
[5849] | 25 | import org.openstreetmap.josm.tools.BugReportExceptionHandler;
|
---|
[302] | 26 | import org.openstreetmap.josm.tools.GBC;
|
---|
| 27 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
[2017] | 28 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
[5849] | 29 | import org.openstreetmap.josm.tools.Utils;
|
---|
[623] | 30 |
|
---|
[626] | 31 | /**
|
---|
| 32 | * Nice about screen. I guess every application need one these days.. *sigh*
|
---|
[1023] | 33 | *
|
---|
| 34 | * The REVISION resource is read and if present, it shows the revision
|
---|
[626] | 35 | * information of the jar-file.
|
---|
[1023] | 36 | *
|
---|
[626] | 37 | * @author imi
|
---|
| 38 | */
|
---|
| 39 | public class AboutAction extends JosmAction {
|
---|
[2370] | 40 |
|
---|
[5886] | 41 | /**
|
---|
| 42 | * Constructs a new {@code AboutAction}.
|
---|
| 43 | */
|
---|
[1169] | 44 | public AboutAction() {
|
---|
[4942] | 45 | super(tr("About"), "about", tr("Display the about screen."),
|
---|
| 46 | Shortcut.registerShortcut("system:about", tr("About"),
|
---|
[4982] | 47 | KeyEvent.VK_F1, Shortcut.SHIFT), true);
|
---|
[1169] | 48 | }
|
---|
[626] | 49 |
|
---|
[6084] | 50 | @Override
|
---|
[1169] | 51 | public void actionPerformed(ActionEvent e) {
|
---|
[5493] | 52 | final JTabbedPane about = new JTabbedPane();
|
---|
[2370] | 53 |
|
---|
[5194] | 54 | Version version = Version.getInstance();
|
---|
| 55 |
|
---|
[5886] | 56 | JosmTextArea readme = new JosmTextArea();
|
---|
[2358] | 57 | readme.setEditable(false);
|
---|
| 58 | readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
|
---|
[5194] | 59 | readme.setCaretPosition(0);
|
---|
[626] | 60 |
|
---|
[5886] | 61 | JosmTextArea revision = new JosmTextArea();
|
---|
[5194] | 62 | revision.setEditable(false);
|
---|
| 63 | revision.setText(version.getReleaseAttributes());
|
---|
| 64 | revision.setCaretPosition(0);
|
---|
| 65 |
|
---|
[5886] | 66 | JosmTextArea contribution = new JosmTextArea();
|
---|
[2358] | 67 | contribution.setEditable(false);
|
---|
| 68 | contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
|
---|
[5194] | 69 | contribution.setCaretPosition(0);
|
---|
[626] | 70 |
|
---|
[5886] | 71 | JosmTextArea license = new JosmTextArea();
|
---|
[2358] | 72 | license.setEditable(false);
|
---|
| 73 | license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
|
---|
[5194] | 74 | license.setCaretPosition(0);
|
---|
[2370] | 75 |
|
---|
[1169] | 76 | JPanel info = new JPanel(new GridBagLayout());
|
---|
[6901] | 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));
|
---|
[1179] | 88 | info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
|
---|
[6897] | 89 | info.add(new UrlLabel(Main.getJOSMWebsite(),2), GBC.eol().fill(GBC.HORIZONTAL));
|
---|
[5050] | 90 | info.add(GBC.glue(0,5), GBC.eol());
|
---|
[1179] | 91 | info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
|
---|
[5849] | 92 | info.add(BugReportExceptionHandler.getBugReportUrlLabel(Utils.strip(ShowStatusReportAction.getReportHeader())), GBC.eol().fill(GBC.HORIZONTAL));
|
---|
[626] | 93 |
|
---|
[1169] | 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));
|
---|
[1802] | 98 | about.addTab(tr("License"), createScrollPane(license));
|
---|
[1326] | 99 | about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
|
---|
[626] | 100 |
|
---|
[5493] | 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());
|
---|
[6069] | 105 |
|
---|
[5493] | 106 | GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
|
---|
| 107 | JOptionPane.showMessageDialog(Main.parent, panel, tr("About JOSM..."),
|
---|
[1879] | 108 | JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
|
---|
[1169] | 109 | }
|
---|
[626] | 110 |
|
---|
[5886] | 111 | private JScrollPane createScrollPane(JosmTextArea area) {
|
---|
[1169] | 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 | }
|
---|
[626] | 119 | }
|
---|