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.plugins.PluginHandler; 023 import org.openstreetmap.josm.tools.GBC; 024 import org.openstreetmap.josm.tools.ImageProvider; 025 import org.openstreetmap.josm.tools.Shortcut; 026 import org.openstreetmap.josm.tools.UrlLabel; 027 028 /** 029 * Nice about screen. I guess every application need one these days.. *sigh* 030 * 031 * The REVISION resource is read and if present, it shows the revision 032 * information of the jar-file. 033 * 034 * @author imi 035 */ 036 public class AboutAction extends JosmAction { 037 038 public AboutAction() { 039 super(tr("About"), "about", tr("Display the about screen."), 040 Shortcut.registerShortcut("system:about", tr("About"), 041 KeyEvent.VK_F1, Shortcut.SHIFT), true); 042 } 043 044 public void actionPerformed(ActionEvent e) { 045 JTabbedPane about = new JTabbedPane(); 046 047 Version version = Version.getInstance(); 048 049 JTextArea readme = new JTextArea(); 050 readme.setEditable(false); 051 readme.setText(Version.loadResourceFile(Main.class.getResource("/README"))); 052 readme.setCaretPosition(0); 053 054 JTextArea revision = new JTextArea(); 055 revision.setEditable(false); 056 revision.setText(version.getReleaseAttributes()); 057 revision.setCaretPosition(0); 058 059 JTextArea contribution = new JTextArea(); 060 contribution.setEditable(false); 061 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION"))); 062 contribution.setCaretPosition(0); 063 064 JTextArea license = new JTextArea(); 065 license.setEditable(false); 066 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE"))); 067 license.setCaretPosition(0); 068 069 JPanel info = new JPanel(new GridBagLayout()); 070 JLabel caption = new JLabel("JOSM ??? " + tr("Java OpenStreetMap Editor")); 071 caption.setFont(new Font("Helvetica", Font.BOLD, 20)); 072 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 073 info.add(GBC.glue(0,10), GBC.eol()); 074 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 075 info.add(GBC.glue(0,5), GBC.eol()); 076 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 077 info.add(GBC.glue(0,5), GBC.eol()); 078 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 079 info.add(GBC.glue(0,10), GBC.eol()); 080 info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0)); 081 info.add(new UrlLabel("http://josm.openstreetmap.de",2), GBC.eol().fill(GBC.HORIZONTAL)); 082 info.add(GBC.glue(0,5), GBC.eol()); 083 info.add(new JLabel(tr("Bug Reports")), GBC.std().insets(10,0,10,0)); 084 info.add(new UrlLabel("http://josm.openstreetmap.de/newticket",2), GBC.eol().fill(GBC.HORIZONTAL)); 085 086 about.addTab(tr("Info"), info); 087 about.addTab(tr("Readme"), createScrollPane(readme)); 088 about.addTab(tr("Revision"), createScrollPane(revision)); 089 about.addTab(tr("Contribution"), createScrollPane(contribution)); 090 about.addTab(tr("License"), createScrollPane(license)); 091 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel())); 092 093 about.setPreferredSize(new Dimension(500,300)); 094 095 JOptionPane.showMessageDialog(Main.parent, about, tr("About JOSM..."), 096 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo")); 097 } 098 099 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 }