View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 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.util.ArrayList;
16  
17  import com.eviware.soapui.model.settings.Settings;
18  import com.eviware.soapui.settings.ToolsSettings;
19  import com.eviware.soapui.support.components.DirectoryFormComponent;
20  import com.eviware.soapui.support.components.SimpleForm;
21  import com.eviware.soapui.support.types.StringToStringMap;
22  
23  public class ToolsPrefs implements Prefs
24  {
25     public static final String AXIS_1_X = "Axis 1.X";
26     public static final String WSCOMPILE = "JAX-RPC WSCompile";
27     public static final String WSIMPORT = "JAX-WS WSImport";
28     public static final String AXIS_2 = "Axis 2";
29     public static final String WSTOOLS = "JBossWS wstools";
30     public static final String JAVAC = "JDK 1.5 javac";
31     public static final String DOTNET = ".NET 2.0 wsdl.exe";
32     public static final String XFIRE = "XFire 1.X";
33     public static final String GSOAP = "GSoap";  
34     public static final String ANT = "ANT 1.6.5";  
35     public static final String XMLBEANS = "XmlBeans 2.X";
36     public static final String JAXB = "JAXB xjc";
37     public static final String TCPMON = "Apache TcpMon";
38     public static final String WSA = "Oracle wsa.jar";
39     public static final String LIBRARIES = "Script libraries";
40  
41     private static final String[][] TOOLS = {
42        { WSTOOLS, ToolsSettings.JBOSSWS_WSTOOLS_LOCATION },
43        { AXIS_1_X, ToolsSettings.AXIS_1_X_LOCATION },
44        { AXIS_2, ToolsSettings.AXIS_2_LOCATION },
45        { WSCOMPILE, ToolsSettings.JWSDP_WSCOMPILE_LOCATION },
46        { WSIMPORT, ToolsSettings.JWSDP_WSIMPORT_LOCATION },
47        { JAVAC, ToolsSettings.JAVAC_LOCATION },
48        { DOTNET, ToolsSettings.DOTNET_WSDL_LOCATION },
49        { XFIRE, ToolsSettings.XFIRE_LOCATION },
50        { GSOAP, ToolsSettings.GSOAP_LOCATION },
51        { ANT, ToolsSettings.ANT_LOCATION },
52        { XMLBEANS, ToolsSettings.XMLBEANS_LOCATION },
53        { JAXB, ToolsSettings.JAXB_LOCATION },
54        { TCPMON, ToolsSettings.TCPMON_LOCATION },
55        { WSA, ToolsSettings.ORACLE_WSA_LOCATION },
56     };
57     
58  	private SimpleForm toolsForm;
59  	private final String title;
60     
61     public ToolsPrefs( String title )
62     {
63  		this.title = title;
64     }
65        
66     public String getTitle()
67  	{
68  		return title;
69  	}
70     
71     /***
72      * Get the tools to be displayed in the Eclipse plugin.
73      * @return
74      */
75     public String[][] getEclipseTools()
76     {
77        // Return all tools except .NET related and tools that are part of Eclipse.
78        ArrayList<String[]> list = new ArrayList<String[]>();
79        for(String[] s : TOOLS)
80        {
81           String tool = s[0];
82           
83           // Filter out .NET related tools.
84           if(tool != ToolsPrefs.DOTNET && tool != ToolsPrefs.GSOAP &&
85           
86              // Filter out tools that are part of Eclipse.
87              tool != ToolsPrefs.JAVAC && tool != ToolsPrefs.ANT)
88           {
89              list.add(s);
90           }
91        }
92        return list.toArray(new String[list.size()][]);
93     }
94     
95  	public SimpleForm getForm()
96  	{
97  		if( toolsForm == null )
98  		{
99  			toolsForm = new SimpleForm();
100 			toolsForm.addSpace( 5 );
101 			toolsForm.append( ToolsPrefs.WSTOOLS, new DirectoryFormComponent( "location of JBossWS wstools" ));
102 			toolsForm.append( ToolsPrefs.WSCOMPILE, new DirectoryFormComponent( "location of JWSDP wscompile" ));
103 			toolsForm.append( ToolsPrefs.WSIMPORT, new DirectoryFormComponent( "location of JAX-WS wsimport" ));
104 			toolsForm.append( ToolsPrefs.AXIS_1_X, new DirectoryFormComponent( "location of Axis 1.X" ));
105 			toolsForm.append( ToolsPrefs.AXIS_2, new DirectoryFormComponent( "location of Axis 2" ));
106 			toolsForm.append( ToolsPrefs.DOTNET, new DirectoryFormComponent( "location of .NET 2.0 wsdl.exe" ));
107 			toolsForm.append( ToolsPrefs.XFIRE, new DirectoryFormComponent( "location of XFire 1.X" ));
108 			toolsForm.append( ToolsPrefs.ANT, new DirectoryFormComponent( "location of Apache ANT 1.6.5" ));
109 			toolsForm.append( ToolsPrefs.GSOAP, new DirectoryFormComponent( "location of GSoap 2.X" ));
110 			toolsForm.append( ToolsPrefs.JAXB, new DirectoryFormComponent( "location of JAXB xjc" ));
111 			toolsForm.append( ToolsPrefs.XMLBEANS, new DirectoryFormComponent( "location of XMLBeans 2.X" ));
112 			toolsForm.append( ToolsPrefs.JAVAC, new DirectoryFormComponent( "location of JDK 1.5 javac" ));
113 			toolsForm.append( ToolsPrefs.TCPMON, new DirectoryFormComponent( "location of TcpMon directory" ));
114 			toolsForm.append( ToolsPrefs.WSA, new DirectoryFormComponent( "location of Orace wsa.jar" ));
115 			toolsForm.addSpace( 5 );
116 		}
117 		
118 		return toolsForm;
119 	}
120 
121 	public void getFormValues(Settings settings)
122 	{
123 		StringToStringMap values = new StringToStringMap();
124 		toolsForm.getValues( values );
125 		storeValues(values, settings);
126 	}
127 	
128 	public void storeValues(StringToStringMap values, Settings settings)
129 	{	
130 		for(int i = 0; i < TOOLS.length; i++)
131 	   {
132 	      settings.setString( TOOLS[i][1], values.get( TOOLS[i][0] ));
133 	   }
134 	}
135 
136 	public void setFormValues(Settings settings)
137 	{
138 		getForm().setValues( getValues(settings) ); 
139 	}
140 
141 	public StringToStringMap getValues(Settings settings)
142 	{
143 		StringToStringMap toolsValues = new StringToStringMap();
144 	   for(int i = 0; i < TOOLS.length; i++)
145 	   {
146 	      toolsValues.put( TOOLS[i][0], settings.getString( TOOLS[i][1], "" ));
147 	   }
148 	   return toolsValues;
149 	}
150 }