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.SoapUI;
16  import com.eviware.soapui.impl.WorkspaceImpl;
17  import com.eviware.soapui.support.MessageSupport;
18  import com.eviware.soapui.support.UISupport;
19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
20  
21  /***
22   * Action to clear the current workspace
23   * 
24   * @author ole.matzura
25   */
26  
27  public class ClearWorkspaceAction extends AbstractSoapUIAction<WorkspaceImpl>
28  {
29  	public static final String SOAPUI_ACTION_ID = "ClearWorkspaceAction";
30  	public static final MessageSupport messages = MessageSupport.getMessages( ClearWorkspaceAction.class );
31  
32  	public ClearWorkspaceAction()
33  	{
34  		super( messages.get( "ClearWorkspaceAction.Title" ), messages.get( "ClearWorkspaceAction.Description" ) );
35  	}
36  
37  	public void perform( WorkspaceImpl workspace, Object param )
38  	{
39  		if( SoapUI.getTestMonitor().hasRunningTests() )
40  		{
41  			UISupport.showErrorMessage( messages.get( "ClearWorkspaceAction.WhileTestsAreRunningError" ) );
42  			return;
43  		}
44  
45  		if( !UISupport.confirm( messages.get( "ClearWorkspaceAction.ConfirmQuestion" ), messages
46  				.get( "ClearWorkspaceAction.Title" ) ) )
47  		{
48  			return;
49  		}
50  
51  		if( SoapUI.getDesktop().closeAll() )
52  		{
53  			while( workspace.getProjectCount() > 0 )
54  			{
55  				workspace.removeProject( workspace.getProjectAt( 0 ) );
56  			}
57  		}
58  	}
59  }