001: /*
002: * soapUI, copyright (C) 2004-2007 eviware.com
003: *
004: * soapUI is free software; you can redistribute it and/or modify it under the
005: * terms of version 2.1 of the GNU Lesser General Public License as published by
006: * the Free Software Foundation.
007: *
008: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: * See the GNU Lesser General Public License for more details at gnu.org.
011: */
012:
013: package com.eviware.soapui.actions;
014:
015: import java.util.ArrayList;
016:
017: import com.eviware.soapui.model.settings.Settings;
018: import com.eviware.soapui.settings.ToolsSettings;
019: import com.eviware.soapui.support.components.DirectoryFormComponent;
020: import com.eviware.soapui.support.components.SimpleForm;
021: import com.eviware.soapui.support.types.StringToStringMap;
022:
023: /**
024: * Preferences class for ToolsSettings
025: *
026: * @author ole.matzura
027: */
028:
029: public class ToolsPrefs implements Prefs {
030: public static final String AXIS_1_X = "Axis 1.X";
031: public static final String WSCOMPILE = "JAX-RPC WSCompile";
032: public static final String WSIMPORT = "JAX-WS WSImport";
033: public static final String AXIS_2 = "Axis 2";
034: public static final String WSTOOLS = "JBossWS wstools";
035: public static final String JAVAC = "JDK 1.5 javac";
036: public static final String DOTNET = ".NET 2.0 wsdl.exe";
037: public static final String XFIRE = "XFire 1.X";
038: public static final String GSOAP = "GSoap";
039: public static final String ANT = "ANT 1.6+";
040: public static final String XMLBEANS = "XmlBeans 2.X";
041: public static final String JAXB = "JAXB xjc";
042: public static final String TCPMON = "Apache TcpMon";
043: public static final String WSA = "Oracle wsa.jar";
044: public static final String LIBRARIES = "Script libraries";
045:
046: private static final String[][] TOOLS = {
047: { WSTOOLS, ToolsSettings.JBOSSWS_WSTOOLS_LOCATION },
048: { AXIS_1_X, ToolsSettings.AXIS_1_X_LOCATION },
049: { AXIS_2, ToolsSettings.AXIS_2_LOCATION },
050: { WSCOMPILE, ToolsSettings.JWSDP_WSCOMPILE_LOCATION },
051: { WSIMPORT, ToolsSettings.JWSDP_WSIMPORT_LOCATION },
052: { JAVAC, ToolsSettings.JAVAC_LOCATION },
053: { DOTNET, ToolsSettings.DOTNET_WSDL_LOCATION },
054: { XFIRE, ToolsSettings.XFIRE_LOCATION },
055: { GSOAP, ToolsSettings.GSOAP_LOCATION },
056: { ANT, ToolsSettings.ANT_LOCATION },
057: { XMLBEANS, ToolsSettings.XMLBEANS_LOCATION },
058: { JAXB, ToolsSettings.JAXB_LOCATION },
059: { TCPMON, ToolsSettings.TCPMON_LOCATION },
060: { WSA, ToolsSettings.ORACLE_WSA_LOCATION }, };
061:
062: private SimpleForm toolsForm;
063: private final String title;
064:
065: public ToolsPrefs(String title) {
066: this .title = title;
067: }
068:
069: public String getTitle() {
070: return title;
071: }
072:
073: /**
074: * Get the tools to be displayed in the Eclipse plugin.
075: * @return
076: */
077: public String[][] getEclipseTools() {
078: // Return all tools except .NET related and tools that are part of Eclipse.
079: ArrayList<String[]> list = new ArrayList<String[]>();
080: for (String[] s : TOOLS) {
081: String tool = s[0];
082:
083: // Filter out .NET related tools.
084: if (tool != ToolsPrefs.DOTNET && tool != ToolsPrefs.GSOAP &&
085:
086: // Filter out tools that are part of Eclipse.
087: tool != ToolsPrefs.JAVAC && tool != ToolsPrefs.ANT) {
088: list.add(s);
089: }
090: }
091: return list.toArray(new String[list.size()][]);
092: }
093:
094: public SimpleForm getForm() {
095: if (toolsForm == null) {
096: toolsForm = new SimpleForm();
097: toolsForm.addSpace(5);
098: toolsForm.append(ToolsPrefs.WSTOOLS,
099: new DirectoryFormComponent(
100: "location of JBossWS wstools"));
101: toolsForm.append(ToolsPrefs.WSCOMPILE,
102: new DirectoryFormComponent(
103: "location of JWSDP wscompile"));
104: toolsForm.append(ToolsPrefs.WSIMPORT,
105: new DirectoryFormComponent(
106: "location of JAX-WS wsimport"));
107: toolsForm.append(ToolsPrefs.AXIS_1_X,
108: new DirectoryFormComponent("location of Axis 1.X"));
109: toolsForm.append(ToolsPrefs.AXIS_2,
110: new DirectoryFormComponent("location of Axis 2"));
111: toolsForm.append(ToolsPrefs.DOTNET,
112: new DirectoryFormComponent(
113: "location of .NET 2.0 wsdl.exe"));
114: toolsForm
115: .append(ToolsPrefs.XFIRE,
116: new DirectoryFormComponent(
117: "location of XFire 1.X"));
118: toolsForm.append(ToolsPrefs.ANT,
119: new DirectoryFormComponent(
120: "location of Apache ANT 1.6.5 or later"));
121: toolsForm
122: .append(ToolsPrefs.GSOAP,
123: new DirectoryFormComponent(
124: "location of GSoap 2.X"));
125: toolsForm.append(ToolsPrefs.JAXB,
126: new DirectoryFormComponent("location of JAXB xjc"));
127: toolsForm.append(ToolsPrefs.XMLBEANS,
128: new DirectoryFormComponent(
129: "location of XMLBeans 2.X"));
130: toolsForm.append(ToolsPrefs.JAVAC,
131: new DirectoryFormComponent(
132: "location of JDK 1.5 javac"));
133: toolsForm.append(ToolsPrefs.TCPMON,
134: new DirectoryFormComponent(
135: "location of TcpMon directory"));
136: toolsForm.append(ToolsPrefs.WSA,
137: new DirectoryFormComponent(
138: "location of Orace wsa.jar"));
139: toolsForm.addSpace(5);
140: }
141:
142: return toolsForm;
143: }
144:
145: public void getFormValues(Settings settings) {
146: StringToStringMap values = new StringToStringMap();
147: toolsForm.getValues(values);
148: storeValues(values, settings);
149: }
150:
151: public void storeValues(StringToStringMap values, Settings settings) {
152: for (int i = 0; i < TOOLS.length; i++) {
153: settings.setString(TOOLS[i][1], values.get(TOOLS[i][0]));
154: }
155: }
156:
157: public void setFormValues(Settings settings) {
158: getForm().setValues(getValues(settings));
159: }
160:
161: public StringToStringMap getValues(Settings settings) {
162: StringToStringMap toolsValues = new StringToStringMap();
163: for (int i = 0; i < TOOLS.length; i++) {
164: toolsValues.put(TOOLS[i][0], settings.getString(
165: TOOLS[i][1], ""));
166: }
167: return toolsValues;
168: }
169: }
|