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