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  package com.eviware.soapui.actions;
13  
14  import java.io.File;
15  
16  import com.eviware.soapui.model.settings.Settings;
17  import com.eviware.soapui.settings.LoadUISettings;
18  import com.eviware.soapui.support.components.DirectoryFormComponent;
19  import com.eviware.soapui.support.components.SimpleForm;
20  import com.eviware.soapui.support.types.StringToStringMap;
21  
22  public class LoadUIPrefs implements Prefs
23  {
24  	public static final String LOADUI_PATH = "loadUI.bat(.sh) folder";
25  	public static final String LOADUI_CAJO_PORT = "loadUI integration port";
26  	public static final String SOAPUI_CAJO_PORT = "soapUI integration port";
27  
28  	private final String title;
29  	private SimpleForm editorForm;
30  
31  	public LoadUIPrefs( String title )
32  	{
33  		this.title = title;
34  	}
35  
36  	public SimpleForm getForm()
37  	{
38  		if( editorForm == null )
39  		{
40  			editorForm = new SimpleForm();
41  			editorForm.addSpace( 5 );
42  			DirectoryFormComponent directoryFormComponent=new DirectoryFormComponent( "Folder containing loadUI.bat(.sh) " );
43  			directoryFormComponent.setInitialFolder( System.getProperty( "soapui.home" )+File.separator+".."+File.separator+".." );
44  			editorForm.append( LOADUI_PATH,  directoryFormComponent);
45  			editorForm.appendTextField( LOADUI_CAJO_PORT, "Client port for loadUI integration" );
46  			editorForm.appendTextField( SOAPUI_CAJO_PORT,
47  					"Server port of soapUI integration (change requires restart of soapUI)" );
48  
49  		}
50  		return editorForm;
51  	}
52  
53  	public void getFormValues( Settings settings )
54  	{
55  		StringToStringMap values = new StringToStringMap();
56  		editorForm.getValues( values );
57  		storeValues( values, settings );
58  	}
59  
60  	public String getTitle()
61  	{
62  		return title;
63  	}
64  
65  	public StringToStringMap getValues( Settings settings )
66  	{
67  		StringToStringMap values = new StringToStringMap();
68  		values.put( LOADUI_PATH, settings.getString( LoadUISettings.LOADUI_PATH, "" ) );
69  		values.put( LOADUI_CAJO_PORT, settings.getString( LoadUISettings.LOADUI_CAJO_PORT, "1199" ) );
70  		values.put( SOAPUI_CAJO_PORT, settings.getString( LoadUISettings.SOAPUI_CAJO_PORT, "1198" ) );
71  		return values;
72  	}
73  
74  	public void setFormValues( Settings settings )
75  	{
76  		editorForm.setValues( getValues( settings ) );
77  	}
78  
79  	public void storeValues( StringToStringMap values, Settings settings )
80  	{
81  		settings.setString( LoadUISettings.LOADUI_PATH, values.get( LOADUI_PATH ) );
82  		settings.setString( LoadUISettings.LOADUI_CAJO_PORT, values.get( LOADUI_CAJO_PORT ) );
83  		settings.setString( LoadUISettings.SOAPUI_CAJO_PORT, values.get( SOAPUI_CAJO_PORT ) );
84  
85  	}
86  
87  }