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.WsdlInterfaceFactory;
18 import com.eviware.soapui.impl.wsdl.WsdlProject;
19 import com.eviware.soapui.model.iface.Interface;
20 import com.eviware.soapui.model.propertyexpansion.resolvers.providers.ProjectDirProvider;
21 import com.eviware.soapui.support.UISupport;
22 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
23
24 /***
25 * Adds a WsdlInterface to a WsdlProject from a wsdl file
26 *
27 * @author Ole.Matzura
28 */
29
30 public class AddInterfaceActionFromFile extends AbstractSoapUIAction<WsdlProject>
31 {
32 public static final String SOAPUI_ACTION_ID = "AddInterfaceActionFromFile";
33
34 public AddInterfaceActionFromFile()
35 {
36 super( "Add WSDL from File", "Adds all interfaces in a specified local WSDL file to the current project" );
37 }
38
39 public void perform( WsdlProject project, Object param )
40 {
41 File file = UISupport.getFileDialogs().open(this, "Select WSDL file",
42 ".wsdl", "WSDL Files (*.wsdl)", ProjectDirProvider.getProjectFolder( project ));
43 if( file == null ) return;
44
45 String path = file.getAbsolutePath();
46 if( path == null ) return;
47
48 try
49 {
50 Boolean createRequests = UISupport.confirmOrCancel( "Create default requests for all operations", "Import WSDL" );
51 if( createRequests == null )
52 return;
53
54 Interface[] ifaces = WsdlInterfaceFactory.importWsdl( project, file.toURI().toURL().toString(), createRequests );
55 if ( ifaces.length > 0)
56 UISupport.select(ifaces[0]);
57 }
58 catch (Exception ex)
59 {
60 UISupport.showErrorMessage( ex.getMessage() + ":" + ex.getCause() );
61 }
62 }
63 }