/*
* Copyright (C) 2012 FiveHT Media Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.fiveht.tick.ui.menu;
import com.fiveht.tick.Metadata;
import com.fiveht.tick.ui.Icons;
import com.fiveht.tick.ui.View;
import com.fiveht.tick.ui.icon.Category;
import com.fiveht.tick.ui.icon.Size;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
/**
*
* @author Nathan Crause
*/
public class AboutMenuItem extends JMenuItem implements ActionListener {
private View view;
public AboutMenuItem(View view) {
super("About", Icons.get(Size._16x16, Category.STATUS, "dialog-information.png"));
this.view = view;
init();
}
private void init() {
setToolTipText("About this application");
setMnemonic(KeyEvent.VK_A);
addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
JEditorPane pane = new JEditorPane("text/html",
"<html>"
+ "<body>"
+ "<h1>Tick Java Desktop</h1>"
+ "<p>version: " + Metadata.VERSION + "</p>"
+ "<p><strong>The Tickspot® Desktop Application for Java®</strong></p>"
+ "<p>Copyright © 2012 <a href=\"http://www.fiveht.com/\">FiveHT Media Ltd</a>.</p>"
+ "<p>This software is released under the <a href=\"http://www.gnu.org/licenses/gpl-3.0.html\">GNU General Public License version 3</a>.</p>"
+ "</body>"
+ "</html>");
pane.setEditable(false);
pane.setOpaque(false);
pane.setBackground(new Color(0, 0, 0, 0));
pane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
}
catch (Exception ex) {
Logger.getLogger(AboutMenuItem.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(view, ex, "Exception", JOptionPane.ERROR_MESSAGE);
}
}
}
});
JOptionPane.showMessageDialog(view, pane, "About Tick Java Desktop", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(AboutMenuItem.class.getResource("/com/fiveht/tick/icons/clock-medium.png")));
}
}