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  
14  package com.eviware.soapui.support.dnd.handlers;
15  
16  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
17  import com.eviware.soapui.support.UISupport;
18  
19  public class TestCaseToTestCaseDropHandler extends AbstractBeforeAfterModelItemDropHandler<WsdlTestCase, WsdlTestCase>
20  {
21  	public TestCaseToTestCaseDropHandler()
22  	{
23  		super( WsdlTestCase.class, WsdlTestCase.class );
24  	}
25  	
26  	@Override
27  	boolean canCopyAfter( WsdlTestCase source, WsdlTestCase target )
28  	{
29  		return true;
30  	}
31  
32  	@Override
33  	boolean canMoveAfter( WsdlTestCase source, WsdlTestCase target )
34  	{
35  		return source != target;
36  	}
37  
38  	@Override
39  	boolean copyAfter( WsdlTestCase source, WsdlTestCase target )
40  	{
41  		WsdlTestCase testCase = TestCaseToTestSuiteDropHandler.copyTestCase( source, target.getTestSuite(), 
42  					target.getTestSuite().getIndexOfTestCase( target )+1 );
43  		
44  		if( testCase != null )
45  			UISupport.select( testCase );
46  		
47  		return testCase != null;
48  	}
49  
50  	@Override
51  	boolean moveAfter( WsdlTestCase source, WsdlTestCase target )
52  	{
53  		WsdlTestCase testCase = TestCaseToTestSuiteDropHandler.moveTestCase( source, target.getTestSuite(), 
54  					target.getTestSuite().getIndexOfTestCase( target )+1 );
55  		
56  		if( testCase != null )
57  			UISupport.select( testCase );
58  		
59  		return testCase != null;
60  	}
61  	
62  	@Override
63  	String getCopyAfterInfo( WsdlTestCase source, WsdlTestCase target )
64  	{
65  		return "Copy TestCase [" + source.getName() + "] to TestSuite [" + target.getTestSuite().getName() + "]";
66  	}
67  
68  	@Override
69  	String getMoveAfterInfo( WsdlTestCase source, WsdlTestCase target )
70  	{
71  		return source == target ? "Move TestCase [" + source.getName() + "] within TestSuite" : 
72  			"Move TestCase [" + source.getName() + "] to TestSuite in Project [" + target.getName() + "]";
73  	}
74  
75  	@Override
76  	boolean canCopyBefore( WsdlTestCase source, WsdlTestCase target )
77  	{
78  		return true;
79  	}
80  
81  	@Override
82  	boolean canMoveBefore( WsdlTestCase source, WsdlTestCase target )
83  	{
84  		return source != target;
85  	}
86  
87  	@Override
88  	boolean copyBefore( WsdlTestCase source, WsdlTestCase target )
89  	{
90  		WsdlTestCase testCase = TestCaseToTestSuiteDropHandler.copyTestCase( source, target.getTestSuite(), 
91  					target.getTestSuite().getIndexOfTestCase( target ) );
92  		
93  		if( testCase != null )
94  			UISupport.select( testCase );
95  		
96  		return testCase != null;
97  	}
98  
99  	@Override
100 	String getCopyBeforeInfo( WsdlTestCase source, WsdlTestCase target )
101 	{
102 		return getCopyAfterInfo( source, target );
103 	}
104 
105 	@Override
106 	String getMoveBeforeInfo( WsdlTestCase source, WsdlTestCase target )
107 	{
108 		return getMoveAfterInfo( source, target );
109 	}
110 
111 	@Override
112 	boolean moveBefore( WsdlTestCase source, WsdlTestCase target )
113 	{
114 		WsdlTestCase testCase = TestCaseToTestSuiteDropHandler.moveTestCase( source, target.getTestSuite(), 
115 					target.getTestSuite().getIndexOfTestCase( target ) );
116 		
117 		if( testCase != null )
118 			UISupport.select( testCase );
119 		
120 		return testCase != null;
121 	}
122 }