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.support.dnd.handlers;
14  
15  import com.eviware.soapui.SoapUI;
16  import com.eviware.soapui.impl.wsdl.WsdlOperation;
17  import com.eviware.soapui.impl.wsdl.actions.operation.AddOperationToMockServiceAction;
18  import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
19  import com.eviware.soapui.support.action.SoapUIAction;
20  
21  public class OperationToMockServiceDropHandler extends
22  		AbstractAfterModelItemDropHandler<WsdlOperation, WsdlMockService>
23  {
24  	public OperationToMockServiceDropHandler()
25  	{
26  		super( WsdlOperation.class, WsdlMockService.class );
27  	}
28  
29  	@Override
30  	boolean canCopyAfter( WsdlOperation source, WsdlMockService target )
31  	{
32  		return source.getInterface().getProject() == target.getProject();
33  	}
34  
35  	@Override
36  	boolean canMoveAfter( WsdlOperation source, WsdlMockService target )
37  	{
38  		return canCopyAfter( source, target );
39  	}
40  
41  	@Override
42  	boolean copyAfter( WsdlOperation source, WsdlMockService target )
43  	{
44  		SoapUIAction<WsdlOperation> action = SoapUI.getActionRegistry().getAction(
45  				AddOperationToMockServiceAction.SOAPUI_ACTION_ID );
46  		AddOperationToMockServiceAction a = ( AddOperationToMockServiceAction )action;
47  
48  		return a.addOperationToMockService( source, target );
49  	}
50  
51  	@Override
52  	boolean moveAfter( WsdlOperation source, WsdlMockService target )
53  	{
54  		return copyAfter( source, target );
55  	}
56  
57  	@Override
58  	String getCopyAfterInfo( WsdlOperation source, WsdlMockService target )
59  	{
60  		return "Add MockOperation for [" + source.getName() + "] to MockService [" + target.getName() + "]";
61  	}
62  
63  	@Override
64  	String getMoveAfterInfo( WsdlOperation source, WsdlMockService target )
65  	{
66  		return getCopyAfterInfo( source, target );
67  	}
68  
69  }