View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.actions;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  import com.eviware.soapui.SoapUI;
19  import com.eviware.soapui.impl.WorkspaceImpl;
20  import com.eviware.soapui.model.project.Project;
21  import com.eviware.soapui.support.SoapUIException;
22  import com.eviware.soapui.support.UISupport;
23  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
24  
25  /***
26   * Action to save all projects
27   * 
28   * @author ole.matzura
29   */
30  
31  public class OpenClosedProjectsAction extends AbstractSoapUIAction<WorkspaceImpl>
32  {
33  	public static final String SOAPUI_ACTION_ID = "OpenClosedProjectsAction";
34  
35  	public OpenClosedProjectsAction()
36  	{
37  		super( "Open All Closed Projects", "Opens all closed projects in the current Workspace" );
38  	}
39  
40  	public void perform( WorkspaceImpl workspace, Object param )
41  	{
42  		List<Project> openProjects = new ArrayList<Project>();
43  		for( Project project : workspace.getProjectList() )
44  			if( !project.isOpen() && !project.isDisabled() )
45  				openProjects.add( project );
46  
47  		if( openProjects.isEmpty() )
48  		{
49  			UISupport.showErrorMessage( "No closed projects in workspace" );
50  			return;
51  		}
52  
53  		for( Project project : openProjects )
54  		{
55  			try
56  			{
57  				workspace.openProject( project );
58  			}
59  			catch( SoapUIException e )
60  			{
61  				SoapUI.logError( e );
62  			}
63  		}
64  	}
65  }