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.actions;
14  
15  import java.awt.Dimension;
16  
17  import com.eviware.soapui.impl.wsdl.panels.teststeps.support.PropertyHolderTable;
18  import com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils;
19  import com.eviware.soapui.model.settings.Settings;
20  import com.eviware.soapui.settings.GlobalPropertySettings;
21  import com.eviware.soapui.support.components.SimpleForm;
22  import com.eviware.soapui.support.types.StringToStringMap;
23  
24  public class GlobalPropertiesPrefs implements Prefs
25  {
26  	public final static String ENABLE_OVERRIDE = "Enable Override";
27  	private SimpleForm globalPropertiesForm;
28  
29  	public SimpleForm getForm()
30  	{
31  		if( globalPropertiesForm == null )
32  		{
33  			globalPropertiesForm = new SimpleForm();
34  
35  			PropertyHolderTable propertyHolderTable = new PropertyHolderTable( PropertyExpansionUtils
36  					.getGlobalProperties() );
37  			propertyHolderTable.setPreferredSize( new Dimension( 200, 300 ) );
38  			globalPropertiesForm.addComponent( propertyHolderTable );
39  			globalPropertiesForm.addSpace();
40  			globalPropertiesForm.appendCheckBox( ENABLE_OVERRIDE,
41  					"Enables overriding of any property-reference with global properties", false );
42  		}
43  
44  		return globalPropertiesForm;
45  	}
46  
47  	public void getFormValues( Settings settings )
48  	{
49  		StringToStringMap values = new StringToStringMap();
50  		globalPropertiesForm.getValues( values );
51  		storeValues( values, settings );
52  	}
53  
54  	public String getTitle()
55  	{
56  		return "Global Properties";
57  	}
58  
59  	public StringToStringMap getValues( Settings settings )
60  	{
61  		StringToStringMap values = new StringToStringMap();
62  		values.put( ENABLE_OVERRIDE, settings.getBoolean( GlobalPropertySettings.ENABLE_OVERRIDE ) );
63  		return values;
64  	}
65  
66  	public void setFormValues( Settings settings )
67  	{
68  		globalPropertiesForm.setValues( getValues( settings ) );
69  	}
70  
71  	public void storeValues( StringToStringMap values, Settings settings )
72  	{
73  		settings.setBoolean( GlobalPropertySettings.ENABLE_OVERRIDE, values.getBoolean( ENABLE_OVERRIDE ) );
74  	}
75  }