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.MessageSupport;
21 import com.eviware.soapui.support.UISupport;
22 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
23
24 /***
25 * Actions for importing an existing soapUI project file into the current
26 * workspace
27 *
28 * @author Ole.Matzura
29 */
30
31 public class ImportWsdlProjectAction extends AbstractSoapUIAction<WorkspaceImpl>
32 {
33 public static final String SOAPUI_ACTION_ID = "ImportWsdlProjectAction";
34 public static final MessageSupport messages = MessageSupport.getMessages( ImportWsdlProjectAction.class );
35
36 public ImportWsdlProjectAction()
37 {
38 super( messages.get( "title" ), messages.get( "description" ) );
39 }
40
41 public void perform( WorkspaceImpl workspace, Object param )
42 {
43 File file = null;
44
45 if( param == null )
46 {
47 file = UISupport.getFileDialogs().openXML( this, messages.get( "prompt.title" ) );
48 }
49 else
50 {
51 file = new File( param.toString() );
52 }
53
54 if( file == null )
55 return;
56
57 String fileName = file.getAbsolutePath();
58 if( fileName == null )
59 return;
60
61 ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
62 Thread.currentThread().setContextClassLoader( SoapUI.class.getClassLoader() );
63
64 try
65 {
66 WsdlProject project = ( WsdlProject )workspace.importProject( fileName );
67 if( project != null )
68 UISupport.select( project );
69 }
70 catch( Exception ex )
71 {
72 UISupport.showErrorMessage( ex );
73 }
74 finally
75 {
76 Thread.currentThread().setContextClassLoader( contextClassLoader );
77 }
78 }
79 }