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

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

sonar - squid:S2325 - "private" methods that don't access instance data should be "static"

  • Property svn:eol-style set to native
File size: 4.9 KB
RevLine 
[8378]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;
[8442]8import java.awt.Image;
[302]9import java.awt.event.ActionEvent;
10import java.awt.event.KeyEvent;
11
12import javax.swing.BorderFactory;
[8442]13import javax.swing.ImageIcon;
[302]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;
[2358]21import org.openstreetmap.josm.data.Version;
[5493]22import org.openstreetmap.josm.gui.util.GuiHelper;
[6901]23import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
[5886]24import org.openstreetmap.josm.gui.widgets.JosmTextArea;
[6340]25import org.openstreetmap.josm.gui.widgets.UrlLabel;
[1326]26import org.openstreetmap.josm.plugins.PluginHandler;
[5849]27import org.openstreetmap.josm.tools.BugReportExceptionHandler;
[302]28import org.openstreetmap.josm.tools.GBC;
29import org.openstreetmap.josm.tools.ImageProvider;
[2017]30import org.openstreetmap.josm.tools.Shortcut;
[5849]31import org.openstreetmap.josm.tools.Utils;
[623]32
[626]33/**
[8442]34 * Nice about screen.
[1023]35 *
[8442]36 * The REVISION resource is read and if present, it shows the revision information of the jar-file.
[1023]37 *
[626]38 * @author imi
39 */
40public class AboutAction extends JosmAction {
[2370]41
[5886]42 /**
43 * Constructs a new {@code AboutAction}.
44 */
[1169]45 public AboutAction() {
[7771]46 super(tr("About"), "logo", tr("Display the about screen."),
[4942]47 Shortcut.registerShortcut("system:about", tr("About"),
[4982]48 KeyEvent.VK_F1, Shortcut.SHIFT), true);
[1169]49 }
[626]50
[6084]51 @Override
[1169]52 public void actionPerformed(ActionEvent e) {
[5493]53 final JTabbedPane about = new JTabbedPane();
[2370]54
[5194]55 Version version = Version.getInstance();
56
[5886]57 JosmTextArea readme = new JosmTextArea();
[2358]58 readme.setEditable(false);
59 readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
[5194]60 readme.setCaretPosition(0);
[626]61
[5886]62 JosmTextArea revision = new JosmTextArea();
[5194]63 revision.setEditable(false);
64 revision.setText(version.getReleaseAttributes());
65 revision.setCaretPosition(0);
66
[5886]67 JosmTextArea contribution = new JosmTextArea();
[2358]68 contribution.setEditable(false);
69 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
[5194]70 contribution.setCaretPosition(0);
[626]71
[5886]72 JosmTextArea license = new JosmTextArea();
[2358]73 license.setEditable(false);
74 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
[5194]75 license.setCaretPosition(0);
[2370]76
[1169]77 JPanel info = new JPanel(new GridBagLayout());
[6901]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));
[8510]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));
[8442]93 info.add(BugReportExceptionHandler.getBugReportUrlLabel(Utils.strip(ShowStatusReportAction.getReportHeader())),
94 GBC.eol().fill(GBC.HORIZONTAL));
[626]95
[1169]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));
[1802]100 about.addTab(tr("License"), createScrollPane(license));
[1326]101 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
[626]102
[5493]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());
[6069]107
[5493]108 GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
[8442]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)));
[1169]111 }
[626]112
[8870]113 private static JScrollPane createScrollPane(JosmTextArea area) {
[8510]114 area.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
[1169]115 area.setOpaque(false);
116 JScrollPane sp = new JScrollPane(area);
117 sp.setBorder(null);
118 sp.setOpaque(false);
119 return sp;
120 }
[626]121}
Note: See TracBrowser for help on using the repository browser.