View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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;
14  
15  import java.awt.Color;
16  import java.awt.Insets;
17  
18  import javax.swing.UIManager;
19  import javax.swing.plaf.ColorUIResource;
20  
21  import com.eviware.soapui.settings.UISettings;
22  import com.eviware.soapui.ui.desktop.DesktopRegistry;
23  import com.eviware.soapui.ui.desktop.standalone.StandaloneDesktopFactory;
24  import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
25  import com.jgoodies.looks.plastic.theme.SkyBluer;
26  
27  public class StandaloneSoapUICore extends SwingSoapUICore
28  {
29  
30  	public StandaloneSoapUICore( boolean init )
31  	{
32  		super();
33  		
34  		if( init )
35  			init( DEFAULT_SETTINGS_FILE );
36  	}
37  	
38  	public StandaloneSoapUICore( String settingsFile )
39  	{
40  		super( null, settingsFile );
41  	}
42  	
43  	public void prepareUI()
44  	{
45  		super.prepareUI();
46  
47  		initSoapUILookAndFeel();
48  		DesktopRegistry.getInstance().addDesktop( SoapUI.DEFAULT_DESKTOP, new StandaloneDesktopFactory() );
49  	}
50  	
51  	public void initSoapUILookAndFeel()
52  	{
53  		try
54  		{
55  			if( getSettings().getBoolean( UISettings.NATIVE_LAF ))
56  			{
57  				javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
58  			}
59  			else
60  			{
61  				SoapUITheme theme = new SoapUITheme();
62  
63  				PlasticXPLookAndFeel.setCurrentTheme( theme );
64  				PlasticXPLookAndFeel.setTabStyle( "Metal" );
65  
66  				UIManager.setLookAndFeel( new PlasticXPLookAndFeel() );
67  				UIManager.put( "TabbedPane.tabAreaInsets", new Insets( 3, 2, 0, 0 ) );
68  				UIManager.put( "TabbedPane.unselectedBackground", new Color( 220, 220, 220 ) );
69  				UIManager.put( "TabbedPane.selected", new Color( 240, 240, 240 ) );
70  				
71  				PlasticXPLookAndFeel.setPlasticTheme( theme );
72  			}
73  		}
74  		catch( Throwable e )
75  		{
76  			System.err.println( "Error initializing PlasticXPLookAndFeel; " + e.getMessage() );
77  		}
78  	}
79  	
80  	/***
81  	 * Adapted theme for soapUI Look and Feel
82  	 * 
83  	 * @author ole.matzura
84  	 */
85  	
86  	public static class SoapUITheme extends SkyBluer
87  	{
88  		public static final Color BACKGROUND_COLOR = new Color( 240, 240, 240 );
89  	
90  		public ColorUIResource getControl()
91  		{
92  			return new ColorUIResource( BACKGROUND_COLOR );
93  		}
94  	
95  		public ColorUIResource getMenuBackground()
96  		{
97  			return getControl();
98  		}
99  	
100 		public ColorUIResource getMenuItemBackground()
101 		{
102 			return new ColorUIResource( new Color( 248, 248, 248 ) );
103 		}
104 	}
105 }