001 //License: GPL. Copyright 2007 by Immanuel Scholz and others
002 package org.openstreetmap.josm.actions;
003
004 import static org.openstreetmap.josm.tools.I18n.tr;
005
006 import java.awt.Dimension;
007 import java.awt.Font;
008 import java.awt.GridBagLayout;
009 import java.awt.event.ActionEvent;
010 import java.awt.event.KeyEvent;
011
012 import javax.swing.BorderFactory;
013 import javax.swing.JLabel;
014 import javax.swing.JOptionPane;
015 import javax.swing.JPanel;
016 import javax.swing.JScrollPane;
017 import javax.swing.JTabbedPane;
018 import javax.swing.JTextArea;
019
020 import org.openstreetmap.josm.Main;
021 import org.openstreetmap.josm.data.Version;
022 import org.openstreetmap.josm.gui.util.GuiHelper;
023 import org.openstreetmap.josm.plugins.PluginHandler;
024 import org.openstreetmap.josm.tools.GBC;
025 import org.openstreetmap.josm.tools.ImageProvider;
026 import org.openstreetmap.josm.tools.Shortcut;
027 import org.openstreetmap.josm.tools.UrlLabel;
028
029 /**
030 * Nice about screen. I guess every application need one these days.. *sigh*
031 *
032 * The REVISION resource is read and if present, it shows the revision
033 * information of the jar-file.
034 *
035 * @author imi
036 */
037 public class AboutAction extends JosmAction {
038
039 public AboutAction() {
040 super(tr("About"), "about", tr("Display the about screen."),
041 Shortcut.registerShortcut("system:about", tr("About"),
042 KeyEvent.VK_F1, Shortcut.SHIFT), true);
043 }
044
045 public void actionPerformed(ActionEvent e) {
046 final JTabbedPane about = new JTabbedPane();
047
048 Version version = Version.getInstance();
049
050 JTextArea readme = new JTextArea();
051 readme.setEditable(false);
052 readme.setText(Version.loadResourceFile(Main.class.getResource("/README")));
053 readme.setCaretPosition(0);
054
055 JTextArea revision = new JTextArea();
056 revision.setEditable(false);
057 revision.setText(version.getReleaseAttributes());
058 revision.setCaretPosition(0);
059
060 JTextArea contribution = new JTextArea();
061 contribution.setEditable(false);
062 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION")));
063 contribution.setCaretPosition(0);
064
065 JTextArea license = new JTextArea();
066 license.setEditable(false);
067 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE")));
068 license.setCaretPosition(0);
069
070 JPanel info = new JPanel(new GridBagLayout());
071 JLabel caption = new JLabel("JOSM ??? " + tr("Java OpenStreetMap Editor"));
072 caption.setFont(new Font("Helvetica", Font.BOLD, 20));
073 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
074 info.add(GBC.glue(0,10), GBC.eol());
075 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
076 info.add(GBC.glue(0,5), GBC.eol());
077 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
078 info.add(GBC.glue(0,5), GBC.eol());
079 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
080 info.add(GBC.glue(0,10), GBC.eol());
081 info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
082 info.add(new UrlLabel("http://josm.openstreetmap.de",2), GBC.eol().fill(GBC.HORIZONTAL));
083 info.add(GBC.glue(0,5), GBC.eol());
084 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0));
085 info.add(new UrlLabel("http://josm.openstreetmap.de/newticket",2), GBC.eol().fill(GBC.HORIZONTAL));
086
087 about.addTab(tr("Info"), info);
088 about.addTab(tr("Readme"), createScrollPane(readme));
089 about.addTab(tr("Revision"), createScrollPane(revision));
090 about.addTab(tr("Contribution"), createScrollPane(contribution));
091 about.addTab(tr("License"), createScrollPane(license));
092 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
093
094 // Intermediate panel to allow proper optionPane resizing
095 JPanel panel = new JPanel(new GridBagLayout());
096 panel.setPreferredSize(new Dimension(600, 300));
097 panel.add(about, GBC.std().fill());
098
099 GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
100 JOptionPane.showMessageDialog(Main.parent, panel, tr("About JOSM..."),
101 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
102 }
103
104 private JScrollPane createScrollPane(JTextArea area) {
105 area.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
106 area.setOpaque(false);
107 JScrollPane sp = new JScrollPane(area);
108 sp.setBorder(null);
109 sp.setOpaque(false);
110 return sp;
111 }
112 }