1
2
3
4
5
6
7
8
9
10
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 AbstractSoapUIAction<WsdlProject>
29 {
30 public static final String SOAPUI_ACTION_ID = "AddInterfaceActionFromFile";
31
32 public AddInterfaceActionFromFile()
33 {
34 super( "Add WSDL from File", "Adds all interfaces in a specified local WSDL file to the current project" );
35 }
36
37 public void perform( WsdlProject project, Object param )
38 {
39 File file = UISupport.getFileDialogs().open(this, "Select WSDL file",
40 ".wsdl", "WSDL Files (*.wsdl)", null);
41 if( file == null ) return;
42
43 String url = file.getAbsolutePath();
44 if( url == null ) return;
45
46 try
47 {
48 Boolean createRequests = UISupport.confirmOrCancel( "Create default requests for all operations", "Import WSDL" );
49 if( createRequests == null )
50 return;
51
52 Interface[] ifaces = project.importWsdl("file:" + url, createRequests );
53 if ( ifaces.length > 0)
54 UISupport.select(ifaces[0]);
55 }
56 catch (Exception ex)
57 {
58 UISupport.showErrorMessage( ex.getMessage() + ":" + ex.getCause() );
59 }
60 }
61 }