01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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.impl.wsdl.actions.project;
14:
15: import java.io.File;
16:
17: import com.eviware.soapui.impl.wsdl.WsdlProject;
18: import com.eviware.soapui.model.iface.Interface;
19: import com.eviware.soapui.support.UISupport;
20: import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21:
22: /**
23: * Adds a WsdlInterface to a WsdlProject from a wsdl file
24: *
25: * @author Ole.Matzura
26: */
27:
28: public class AddInterfaceActionFromFile extends
29: AbstractSoapUIAction<WsdlProject> {
30: public static final String SOAPUI_ACTION_ID = "AddInterfaceActionFromFile";
31:
32: public AddInterfaceActionFromFile() {
33: super ("Add WSDL from File",
34: "Adds all interfaces in a specified local WSDL file to the current project");
35: }
36:
37: public void perform(WsdlProject project, Object param) {
38: File file = UISupport.getFileDialogs().open(this ,
39: "Select WSDL file", ".wsdl", "WSDL Files (*.wsdl)",
40: null);
41: if (file == null)
42: return;
43:
44: String url = file.getAbsolutePath();
45: if (url == null)
46: return;
47:
48: try {
49: Boolean createRequests = UISupport.confirmOrCancel(
50: "Create default requests for all operations",
51: "Import WSDL");
52: if (createRequests == null)
53: return;
54:
55: Interface[] ifaces = project.importWsdl("file:" + url,
56: createRequests);
57: if (ifaces.length > 0)
58: UISupport.select(ifaces[0]);
59: } catch (Exception ex) {
60: UISupport.showErrorMessage(ex.getMessage() + ":"
61: + ex.getCause());
62: }
63: }
64: }
|