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