View Javadoc

    1   /*
    2    *  soapUI, copyright (C) 2004-2007 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.SoapUI;
    16  import com.eviware.soapui.impl.WorkspaceImpl;
    17  import com.eviware.soapui.impl.wsdl.WsdlProject;
    18  import com.eviware.soapui.support.UISupport;
    19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
    20
    21  /***
    22   * Actions for importing an existing soapui-project file into the current workspace
    23   *
    24   * @author Ole.Matzura
    25   */
    26
    27  public class ImportRemoteWsdlProjectAction extends AbstractSoapUIAction<WorkspaceImpl>
    28  {
    29  	public static final String SOAPUI_ACTION_ID = "ImportRemoteWsdlProjectAction";
    30
    31  	public ImportRemoteWsdlProjectAction()
    32     {
    33        super( "Import Remote Project", "Imports a remote project into this workspace" );
    34     }
    35
    36  	public void perform( WorkspaceImpl workspace, Object param )
    37  	{
    38        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    39     	Thread.currentThread().setContextClassLoader( SoapUI.class.getClassLoader() );
    40
    41  		try
    42  		{
    43  			String url = UISupport.prompt( "Specify remote URL to project file", "Import Remote Project", "" );
    44  			if( url != null )
    45  			{
    46  				WsdlProject project = (WsdlProject) workspace.importRemoteProject(url);
    47  				if( project != null )
    48  					UISupport.select(project);
    49  			}
    50  		}
    51  		catch (Exception ex)
    52  		{
    53  			UISupport.showErrorMessage( ex );
    54  		}
    55  		finally
    56     	{
    57     		Thread.currentThread().setContextClassLoader( contextClassLoader );
    58     	}
    59     }
    60  }