View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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.impl.wsdl.WsdlProject;
16  import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
17  import com.eviware.soapui.impl.wsdl.actions.testsuite.CloneTestSuiteAction;
18  import com.eviware.soapui.support.UISupport;
19  
20  public class TestSuiteToProjectDropHandler extends AbstractAfterModelItemDropHandler<WsdlTestSuite, WsdlProject>
21  {
22  	public TestSuiteToProjectDropHandler()
23  	{
24  		super( WsdlTestSuite.class, WsdlProject.class );
25  	}
26  	
27  	@Override
28  	boolean canCopyAfter( WsdlTestSuite source, WsdlProject target )
29  	{
30  		return true;
31  	}
32  
33  	@Override
34  	boolean canMoveAfter( WsdlTestSuite source, WsdlProject target )
35  	{
36  		return source.getProject() != target;
37  	}
38  
39  	@Override
40  	boolean copyAfter( WsdlTestSuite source, WsdlProject target )
41  	{
42  		String name = UISupport.prompt( "Specify name for copied TestSuite", "Copy TestSuite", "Copy of " + source.getName() );
43  		if( name == null )
44  			return false;
45  
46  		if( source.getProject() == target )
47  		{
48  			return CloneTestSuiteAction.cloneTestSuiteWithinProject( source, name, target );
49  		}
50  		else
51  		{
52  			return CloneTestSuiteAction.cloneToAnotherProject( source, target.getName(), name, false ) != null;
53  		}
54  	}
55  
56  	@Override
57  	boolean moveAfter( WsdlTestSuite source, WsdlProject target )
58  	{
59  		String name = UISupport.prompt( "Specify name for moved TestSuite", "Move TestSuite", source.getName() );
60  		if( name == null )
61  			return false;
62  
63  		WsdlTestSuite testSuite = CloneTestSuiteAction.cloneToAnotherProject( source, target.getName(), name, true );
64  		if( testSuite != null )
65  		{
66  			source.getProject().removeTestSuite( source );
67  			return true;
68  		}
69  		
70  		return false;
71  	}
72  
73  	@Override
74  	String getCopyAfterInfo( WsdlTestSuite source, WsdlProject target )
75  	{
76  		return source.getProject() == target ? 
77  			"Copy TestSuite [" + source.getName() + "] within Project [" + target.getName() + "]" :
78  			"Copy TestSuite [" + source.getName() + "] to Project [" + target.getName() + "]";
79  	}
80  
81  	@Override
82  	String getMoveAfterInfo( WsdlTestSuite source, WsdlProject target )
83  	{
84  		return "Move TestSuite [" + source.getName() + "] to Project [" + target.getName() + "]";
85  	}
86  	
87  	
88  }