View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.support.components;
14  
15  import java.awt.event.MouseAdapter;
16  import java.awt.event.MouseEvent;
17  
18  import javax.swing.JComponent;
19  import javax.swing.JLabel;
20  import javax.swing.text.JTextComponent;
21  
22  import com.eviware.soapui.support.Tools;
23  
24  public final class HyperlinkLabelMouseAdapter extends MouseAdapter
25  {
26  	private final JComponent label;
27  
28  	public HyperlinkLabelMouseAdapter( JTextComponent label )
29  	{
30  		this.label = label;
31  	}
32  
33  	public HyperlinkLabelMouseAdapter( JLabel label )
34  	{
35  		this.label = label;
36  	}
37  
38  	@Override
39  	public void mouseClicked( MouseEvent e )
40  	{
41  		String text = label instanceof JLabel ? ( ( JLabel )label ).getText() : ( ( JTextComponent )label ).getText();
42  		Tools.openURL( text );
43  	}
44  }