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