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