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