View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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  package com.eviware.soapui.support;
13  
14  import java.awt.BorderLayout;
15  import java.awt.Color;
16  
17  import javax.swing.BorderFactory;
18  import javax.swing.ImageIcon;
19  import javax.swing.JLabel;
20  import javax.swing.JPanel;
21  import javax.swing.UIManager;
22  
23  import com.eviware.soapui.support.swing.GradientPanel;
24  
25  public class DescriptionPanel extends GradientPanel
26  {
27  	private JLabel titleLabel;
28  	private JLabel descriptionLabel;
29  
30  	public DescriptionPanel( String title, String description, ImageIcon icon )
31  	{
32  		super( new BorderLayout() );
33  		setBackground( UIManager.getColor( "control" ) );
34  		setForeground( Color.WHITE );
35  		setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder( 0, 0, 1, 0, Color.DARK_GRAY ),
36  				BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) ) );
37  
38  		descriptionLabel = new JLabel();
39  		setDescription( description );
40  
41  		JPanel innerPanel = new JPanel( new BorderLayout() );
42  		innerPanel.add( descriptionLabel, BorderLayout.CENTER );
43  		innerPanel.setOpaque( false );
44  
45  		if( title != null )
46  		{
47  			descriptionLabel.setBorder( BorderFactory.createEmptyBorder( 5, 5, 0, 0 ) );
48  			titleLabel = new JLabel( "<html><div style=\"font-size: 9px\"><b>" + title + "</b></div></html>" );
49  			innerPanel.add( titleLabel, BorderLayout.NORTH );
50  		}
51  		add( innerPanel, BorderLayout.CENTER );
52  
53  		if( icon != null )
54  		{
55  			JLabel iconLabel = new JLabel( icon );
56  			iconLabel.setBorder( BorderFactory.createEmptyBorder( 0, 10, 0, 0 ) );
57  			add( iconLabel, BorderLayout.EAST );
58  		}
59  	}
60  
61  	public void setTitle( String title )
62  	{
63  		titleLabel.setText( "<html><div style=\"font-size: 9px\"><b>" + title + "</b></div></html>" );
64  	}
65  
66  	public void setDescription( String description )
67  	{
68  		descriptionLabel.setText( "<html><div style=\"font-size: 9px\">" + description + "</div></html>" );
69  	}
70  }