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  
13  package com.eviware.soapui.support.components;
14  
15  import java.awt.Component;
16  import java.awt.Dimension;
17  
18  import javax.swing.Box;
19  import javax.swing.JButton;
20  import javax.swing.JComponent;
21  import javax.swing.JLabel;
22  import javax.swing.JToolBar;
23  
24  import com.eviware.soapui.support.UISupport;
25  
26  public class JXToolBar extends JToolBar
27  {
28  	public <T extends JComponent> T addFixed( T component )
29  	{
30  		if( !( component instanceof JButton ) )
31  			UISupport.setPreferredHeight( component, 18 );
32  
33  		Dimension preferredSize = component.getPreferredSize();
34  		component.setMinimumSize( preferredSize );
35  		component.setMaximumSize( preferredSize );
36  
37  		add( component );
38  
39  		return component;
40  	}
41  
42  	public Component add( Component component )
43  	{
44  		if( !( component instanceof JButton ) )
45  			UISupport.setPreferredHeight( component, 18 );
46  
47  		return super.add( component );
48  	}
49  
50  	public void addGlue()
51  	{
52  		add( Box.createHorizontalGlue() );
53  	}
54  
55  	public void addRelatedGap()
56  	{
57  		addSpace( 3 );
58  	}
59  
60  	public void addUnrelatedGap()
61  	{
62  		addSeparator();
63  	}
64  
65  	public void addLabeledFixed( String string, JComponent component )
66  	{
67  		addFixed( new JLabel( string ) );
68  		addSeparator( new Dimension( 3, 3 ) );
69  		addFixed( component );
70  	}
71  
72  	public void addSpace( int i )
73  	{
74  		addSeparator( new Dimension( i, 1 ) );
75  	}
76  }