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.actions;
14  
15  import com.eviware.soapui.SoapUI;
16  import com.eviware.soapui.impl.WorkspaceImpl;
17  import com.eviware.soapui.model.project.Project;
18  import com.eviware.soapui.model.workspace.Workspace;
19  import com.eviware.soapui.model.workspace.WorkspaceListener;
20  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21  
22  /***
23   * Action to save all projects
24   * 
25   * @author ole.matzura
26   */
27  
28  public class SaveAllProjectsAction extends AbstractSoapUIAction<WorkspaceImpl> implements WorkspaceListener
29  {
30  	public static final String SOAPUI_ACTION_ID = "SaveAllProjectsAction";
31  
32  	public SaveAllProjectsAction()
33  	{
34  		super( "Save All Projects", "Saves all projects in the current Workspace" );
35  
36  		Workspace workspace = SoapUI.getWorkspace();
37  		if( workspace == null )
38  		{
39  			setEnabled( true );
40  		}
41  		else
42  		{
43  			setEnabled( workspace.getProjectCount() > 0 );
44  			workspace.addWorkspaceListener( this );
45  		}
46  	}
47  
48  	public void perform( WorkspaceImpl workspace, Object param )
49  	{
50  		workspace.save( false );
51  	}
52  
53  	public void projectAdded( Project project )
54  	{
55  		setEnabled( true );
56  	}
57  
58  	public void projectChanged( Project project )
59  	{
60  	}
61  
62  	public void projectRemoved( Project project )
63  	{
64  		setEnabled( project.getWorkspace().getProjectCount() == 0 );
65  	}
66  
67  	public void workspaceSwitched( Workspace workspace )
68  	{
69  		setEnabled( workspace.getProjectCount() > 0 );
70  	}
71  
72  	public void workspaceSwitching( Workspace workspace )
73  	{
74  	}
75  }