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