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