package action;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;

import javax.swing.JLabel;

@SuppressWarnings("serial")
public class LinkToUnicarbAction extends JLabel {
	
	String id;
	String uniPage; 
	public LinkToUnicarbAction(String id){
		this.id = id;
		uniPage = "http://www.unicarbkb.org/structure/" + id;
		this.setText(uniPage);
		this.setForeground(Color.blue);
		this.setFont(new Font("Calibri", Font.ITALIC, 12));

		addMouseListener(new MouseAdapter() {
		
			public void mouseEntered(MouseEvent e) {
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			}
			
			public void mouseClicked(MouseEvent e){
				URI uri = URI.create(uniPage);
				try {
					Desktop.getDesktop().browse(uri);
				}
				catch (IOException ex) {
//					TODO catch
					ex.printStackTrace();
				}
			}
		});

	}
}
