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

Last change on this file since 6053 was 5886, checked in by Don-vip, 11 years ago

see #4429 - Right click menu "undo, cut, copy, paste, delete, select all" for each text component (originally based on patch by NooN)

  • Property svn:eol-style set to native
File size: 4.9 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 public void actionPerformed(ActionEvent e) {
50 final JTabbedPane about = new JTabbedPane();
51
52 Version version = Version.getInstance();
53
54 JosmTextArea readme = new JosmTextArea();
55 readme.setEditable(false);
56 readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
57 readme.setCaretPosition(0);
58
59 JosmTextArea revision = new JosmTextArea();
60 revision.setEditable(false);
61 revision.setText(version.getReleaseAttributes());
62 revision.setCaretPosition(0);
63
64 JosmTextArea contribution = new JosmTextArea();
65 contribution.setEditable(false);
66 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
67 contribution.setCaretPosition(0);
68
69 JosmTextArea license = new JosmTextArea();
70 license.setEditable(false);
71 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
72 license.setCaretPosition(0);
73
74 JPanel info = new JPanel(new GridBagLayout());
75 JLabel caption = new JLabel("JOSM – " + tr("Java OpenStreetMap Editor"));
76 caption.setFont(GuiHelper.getTitleFont());
77 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
78 info.add(GBC.glue(0,10), GBC.eol());
79 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
80 info.add(GBC.glue(0,5), GBC.eol());
81 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
82 info.add(GBC.glue(0,5), GBC.eol());
83 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
84 info.add(GBC.glue(0,10), GBC.eol());
85 info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
86 info.add(new UrlLabel("http://josm.openstreetmap.de",2), GBC.eol().fill(GBC.HORIZONTAL));
87 info.add(GBC.glue(0,5), GBC.eol());
88 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
89 info.add(BugReportExceptionHandler.getBugReportUrlLabel(Utils.strip(ShowStatusReportAction.getReportHeader())), GBC.eol().fill(GBC.HORIZONTAL));
90
91 about.addTab(tr("Info"), info);
92 about.addTab(tr("Readme"), createScrollPane(readme));
93 about.addTab(tr("Revision"), createScrollPane(revision));
94 about.addTab(tr("Contribution"), createScrollPane(contribution));
95 about.addTab(tr("License"), createScrollPane(license));
96 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
97
98 // Intermediate panel to allow proper optionPane resizing
99 JPanel panel = new JPanel(new GridBagLayout());
100 panel.setPreferredSize(new Dimension(600, 300));
101 panel.add(about, GBC.std().fill());
102
103 GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
104 JOptionPane.showMessageDialog(Main.parent, panel, tr("About JOSM..."),
105 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
106 }
107
108 private JScrollPane createScrollPane(JosmTextArea area) {
109 area.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
110 area.setOpaque(false);
111 JScrollPane sp = new JScrollPane(area);
112 sp.setBorder(null);
113 sp.setOpaque(false);
114 return sp;
115 }
116}
Note: See TracBrowser for help on using the repository browser.