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

Last change on this file since 5050 was 5050, checked in by akks, 12 years ago

UrlLabel class simplification by Zverik, better label layout in VersionInfoPanel (see #7450, #7326)

  • Property svn:eol-style set to native
File size: 4.2 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.Font;
8import java.awt.GridBagLayout;
9import java.awt.event.ActionEvent;
10import java.awt.event.KeyEvent;
11
12import javax.swing.BorderFactory;
13import javax.swing.JLabel;
14import javax.swing.JOptionPane;
15import javax.swing.JPanel;
16import javax.swing.JScrollPane;
17import javax.swing.JTabbedPane;
18import javax.swing.JTextArea;
19
20import org.openstreetmap.josm.Main;
21import org.openstreetmap.josm.data.Version;
22import org.openstreetmap.josm.plugins.PluginHandler;
23import org.openstreetmap.josm.tools.GBC;
24import org.openstreetmap.josm.tools.ImageProvider;
25import org.openstreetmap.josm.tools.Shortcut;
26import org.openstreetmap.josm.tools.UrlLabel;
27
28/**
29 * Nice about screen. I guess every application need one these days.. *sigh*
30 *
31 * The REVISION resource is read and if present, it shows the revision
32 * information of the jar-file.
33 *
34 * @author imi
35 */
36public class AboutAction extends JosmAction {
37
38 public AboutAction() {
39 super(tr("About"), "about", tr("Display the about screen."),
40 Shortcut.registerShortcut("system:about", tr("About"),
41 KeyEvent.VK_F1, Shortcut.SHIFT), true);
42 }
43
44 public void actionPerformed(ActionEvent e) {
45 JTabbedPane about = new JTabbedPane();
46
47 JTextArea readme = new JTextArea();
48 readme.setEditable(false);
49 readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
50
51 JTextArea contribution = new JTextArea();
52 contribution.setEditable(false);
53 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
54
55 JTextArea license = new JTextArea();
56 license.setEditable(false);
57 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
58
59 Version version = Version.getInstance();
60
61 JPanel info = new JPanel(new GridBagLayout());
62 JLabel caption = new JLabel("JOSM - " + tr("Java OpenStreetMap Editor"));
63 caption.setFont(new Font("Helvetica", Font.BOLD, 20));
64 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
65 info.add(GBC.glue(0,10), GBC.eol());
66 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
67 info.add(GBC.glue(0,5), GBC.eol());
68 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
69 info.add(GBC.glue(0,5), GBC.eol());
70 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
71 info.add(GBC.glue(0,10), GBC.eol());
72 info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
73 info.add(new UrlLabel("http://josm.openstreetmap.de",2), GBC.eol().fill(GBC.HORIZONTAL));
74 info.add(GBC.glue(0,5), GBC.eol());
75 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
76 info.add(new UrlLabel("http://josm.openstreetmap.de/newticket",2), GBC.eol().fill(GBC.HORIZONTAL));
77
78 JTextArea revision = new JTextArea();
79 revision.setEditable(false);
80 revision.setText(version.getReleaseAttributes());
81 about.addTab(tr("Info"), info);
82 about.addTab(tr("Readme"), createScrollPane(readme));
83 about.addTab(tr("Revision"), createScrollPane(revision));
84 about.addTab(tr("Contribution"), createScrollPane(contribution));
85 about.addTab(tr("License"), createScrollPane(license));
86 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
87
88 about.setPreferredSize(new Dimension(500,300));
89
90 JOptionPane.showMessageDialog(Main.parent, about, tr("About JOSM..."),
91 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
92 }
93
94 private JScrollPane createScrollPane(JTextArea area) {
95 area.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
96 area.setOpaque(false);
97 JScrollPane sp = new JScrollPane(area);
98 sp.setBorder(null);
99 sp.setOpaque(false);
100 return sp;
101 }
102}
Note: See TracBrowser for help on using the repository browser.