View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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.actions;
14  
15  import com.eviware.soapui.SoapUIExtensionClassLoader;
16  import com.eviware.soapui.SoapUIExtensionClassLoader.SoapUIClassLoaderState;
17  import com.eviware.soapui.impl.WorkspaceImpl;
18  import com.eviware.soapui.impl.wsdl.WsdlProject;
19  import com.eviware.soapui.support.MessageSupport;
20  import com.eviware.soapui.support.UISupport;
21  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
22  
23  /***
24   * Actions for importing an existing remote soapUI project file into the current
25   * workspace
26   * 
27   * @author Ole.Matzura
28   */
29  
30  public class ImportRemoteWsdlProjectAction extends AbstractSoapUIAction<WorkspaceImpl>
31  {
32  	public static final String SOAPUI_ACTION_ID = "ImportRemoteWsdlProjectAction";
33  	public static final MessageSupport messages = MessageSupport.getMessages( ImportRemoteWsdlProjectAction.class );
34  
35  	public ImportRemoteWsdlProjectAction()
36  	{
37  		super( messages.get( "title" ), messages.get( "description" ) );
38  	}
39  
40  	public void perform( WorkspaceImpl workspace, Object param )
41  	{
42  		SoapUIClassLoaderState state = SoapUIExtensionClassLoader.ensure();
43  		try
44  		{
45  			String url = UISupport.prompt( messages.get( "prompt.text" ), messages.get( "prompt.title" ), "" );
46  
47  			if( url != null )
48  			{
49  				WsdlProject project = ( WsdlProject )workspace.importRemoteProject( url );
50  				if( project != null )
51  					UISupport.select( project );
52  			}
53  		}
54  		catch( Exception ex )
55  		{
56  			UISupport.showErrorMessage( ex );
57  		}
58  		finally
59  		{
60  			state.restore();
61  		}
62  	}
63  }