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

Last change on this file since 7337 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
RevLine 
[6380]1//License: GPL. For details, see LICENSE file.
[626]2package org.openstreetmap.josm.actions;
3
[302]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;
[2358]19import org.openstreetmap.josm.data.Version;
[5493]20import org.openstreetmap.josm.gui.util.GuiHelper;
[6901]21import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
[5886]22import org.openstreetmap.josm.gui.widgets.JosmTextArea;
[6340]23import org.openstreetmap.josm.gui.widgets.UrlLabel;
[1326]24import org.openstreetmap.josm.plugins.PluginHandler;
[5849]25import org.openstreetmap.josm.tools.BugReportExceptionHandler;
[302]26import org.openstreetmap.josm.tools.GBC;
27import org.openstreetmap.josm.tools.ImageProvider;
[2017]28import org.openstreetmap.josm.tools.Shortcut;
[5849]29import 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 */
39public 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}
Note: See TracBrowser for help on using the repository browser.