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

Last change on this file since 5299 was 5194, checked in by simon04, 12 years ago

about dialog: set cursor/caret position to 0 in order to scroll to top

  • Property svn:eol-style set to native
File size: 4.3 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 Version version = Version.getInstance();
48
49 JTextArea readme = new JTextArea();
50 readme.setEditable(false);
51 readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
52 readme.setCaretPosition(0);
53
54 JTextArea revision = new JTextArea();
55 revision.setEditable(false);
56 revision.setText(version.getReleaseAttributes());
57 revision.setCaretPosition(0);
58
59 JTextArea contribution = new JTextArea();
60 contribution.setEditable(false);
61 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
62 contribution.setCaretPosition(0);
63
64 JTextArea license = new JTextArea();
65 license.setEditable(false);
66 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
67 license.setCaretPosition(0);
68
69 JPanel info = new JPanel(new GridBagLayout());
70 JLabel caption = new JLabel("JOSM – " + tr("Java OpenStreetMap Editor"));
71 caption.setFont(new Font("Helvetica", Font.BOLD, 20));
72 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
73 info.add(GBC.glue(0,10), GBC.eol());
74 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
75 info.add(GBC.glue(0,5), GBC.eol());
76 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
77 info.add(GBC.glue(0,5), GBC.eol());
78 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), 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("Homepage")), GBC.std().insets(10,0,10,0));
81 info.add(new UrlLabel("http://josm.openstreetmap.de",2), GBC.eol().fill(GBC.HORIZONTAL));
82 info.add(GBC.glue(0,5), GBC.eol());
83 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
84 info.add(new UrlLabel("http://josm.openstreetmap.de/newticket",2), GBC.eol().fill(GBC.HORIZONTAL));
85
86 about.addTab(tr("Info"), info);
87 about.addTab(tr("Readme"), createScrollPane(readme));
88 about.addTab(tr("Revision"), createScrollPane(revision));
89 about.addTab(tr("Contribution"), createScrollPane(contribution));
90 about.addTab(tr("License"), createScrollPane(license));
91 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
92
93 about.setPreferredSize(new Dimension(500,300));
94
95 JOptionPane.showMessageDialog(Main.parent, about, tr("About JOSM..."),
96 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
97 }
98
99 private JScrollPane createScrollPane(JTextArea area) {
100 area.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
101 area.setOpaque(false);
102 JScrollPane sp = new JScrollPane(area);
103 sp.setBorder(null);
104 sp.setOpaque(false);
105 return sp;
106 }
107}
Note: See TracBrowser for help on using the repository browser.