1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.actions;
14
15 import java.io.File;
16
17 import com.eviware.soapui.SoapUI;
18 import com.eviware.soapui.impl.WorkspaceImpl;
19 import com.eviware.soapui.impl.wsdl.WsdlProject;
20 import com.eviware.soapui.support.UISupport;
21 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
22
23 /***
24 * Actions for importing an existing soapui-project file into the current workspace
25 *
26 * @author Ole.Matzura
27 */
28
29 public class ImportWsdlProjectAction extends AbstractSoapUIAction<WorkspaceImpl>
30 {
31 public static final String SOAPUI_ACTION_ID = "ImportWsdlProjectAction";
32
33 public ImportWsdlProjectAction()
34 {
35 super( "Import Project", "Adds an existing project into this workspace" );
36 }
37
38 public void perform( WorkspaceImpl workspace, Object param )
39 {
40 File file = null;
41
42 if( param == null )
43 {
44 file = UISupport.getFileDialogs().openXML(this, "Select soapui project file");
45 }
46 else
47 {
48 file = new File( param.toString() );
49 }
50
51 if( file == null ) return;
52
53 String fileName = file.getAbsolutePath();
54 if( fileName == null ) return;
55
56 ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
57 Thread.currentThread().setContextClassLoader( SoapUI.class.getClassLoader() );
58
59 try
60 {
61 WsdlProject project = (WsdlProject) workspace.importProject(fileName);
62 if( project != null )
63 UISupport.select(project);
64 }
65 catch (Exception ex)
66 {
67 UISupport.showErrorMessage( ex );
68 }
69 finally
70 {
71 Thread.currentThread().setContextClassLoader( contextClassLoader );
72 }
73 }
74 }