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