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.actions.CloseOpenProjectsAction;
16  import com.eviware.soapui.actions.OpenClosedProjectsAction;
17  import com.eviware.soapui.impl.WorkspaceImpl;
18  import com.eviware.soapui.model.project.Project;
19  import com.eviware.soapui.support.action.SoapUIActionMapping;
20  import com.eviware.soapui.support.action.support.DefaultSoapUIActionGroup;
21  import com.eviware.soapui.support.action.support.SoapUIActionMappingList;
22  
23  /***
24   * SoapUIActionGroup for WsdlProjects, returns different actions depending on if
25   * the project is disabled or not.
26   * 
27   * @author ole.matzura
28   */
29  
30  public class WorkspaceImplSoapUIActionGroup extends DefaultSoapUIActionGroup<WorkspaceImpl>
31  {
32  	public WorkspaceImplSoapUIActionGroup( String id, String name )
33  	{
34  		super( id, name );
35  	}
36  
37  	public SoapUIActionMappingList<WorkspaceImpl> getActionMappings( WorkspaceImpl workspace )
38  	{
39  		SoapUIActionMappingList<WorkspaceImpl> mappings = super.getActionMappings( workspace );
40  
41  		SoapUIActionMapping<WorkspaceImpl> openMapping = mappings.getMapping( OpenClosedProjectsAction.SOAPUI_ACTION_ID );
42  		openMapping.setEnabled( false );
43  		SoapUIActionMapping<WorkspaceImpl> closeMapping = mappings.getMapping( CloseOpenProjectsAction.SOAPUI_ACTION_ID );
44  		closeMapping.setEnabled( false );
45  
46  		for( Project project : workspace.getProjectList() )
47  		{
48  			if( project.isOpen() )
49  			{
50  				closeMapping.setEnabled( true );
51  				if( openMapping.isEnabled() )
52  					break;
53  			}
54  			else if( !project.isDisabled() )
55  			{
56  				openMapping.setEnabled( true );
57  				if( closeMapping.isEnabled() )
58  					break;
59  			}
60  		}
61  
62  		return mappings;
63  	}
64  }