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

Last change on this file since 6143 was 6143, checked in by Don-vip, 6 years ago

see #8885 - cleanup in command line arguments and website URL handling

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