1
2
3
4
5 package com.eviware.soapui.support.dnd.handlers;
6
7 import com.eviware.soapui.impl.wsdl.WsdlInterface;
8 import com.eviware.soapui.impl.wsdl.WsdlProject;
9 import com.eviware.soapui.impl.wsdl.actions.iface.RemoveInterfaceAction;
10 import com.eviware.soapui.support.UISupport;
11
12 public class InterfaceToProjectDropHandler extends AbstractAfterModelItemDropHandler<WsdlInterface, WsdlProject>
13 {
14 public InterfaceToProjectDropHandler()
15 {
16 super( WsdlInterface.class, WsdlProject.class );
17 }
18
19 @Override
20 boolean canCopyAfter( WsdlInterface source, WsdlProject target )
21 {
22 return source.getProject() != target && target.isOpen();
23 }
24
25 @Override
26 boolean canMoveAfter( WsdlInterface source, WsdlProject target )
27 {
28 return source.getProject() != target && target.isOpen();
29 }
30
31 @Override
32 boolean copyAfter( WsdlInterface source, WsdlProject target )
33 {
34 WsdlInterface targetInterface = target.getInterfaceByBindingName( source.getBindingName() );
35 if( targetInterface != null )
36 {
37 UISupport.showErrorMessage( "Target project already contains this Interface" );
38 return false;
39 }
40 else if( !UISupport.confirm( "Copy Interface [" + source.getName() + "] to Project [" +
41 target.getName() + "]", "Copy Interface" ))
42 {
43 return false;
44 }
45
46 boolean importEndpoints = UISupport.confirm( "Import endpoint defaults also?", "Copy Interface" );
47 UISupport.select( target.importInterface( source, importEndpoints, true ));
48
49 return true;
50 }
51
52 @Override
53 boolean moveAfter( WsdlInterface source, WsdlProject target )
54 {
55 WsdlInterface targetInterface = target.getInterfaceByBindingName( source.getBindingName() );
56 if( targetInterface != null )
57 {
58 UISupport.showErrorMessage( "Target project already contains this Interface" );
59 return false;
60 }
61
62 if( RemoveInterfaceAction.hasRunningDependingTests( source ) )
63 {
64 UISupport.showErrorMessage( "Cannot remove Interface due to running depending tests" );
65 return false;
66 }
67
68 if( RemoveInterfaceAction.hasDependingTests( source ) )
69 {
70 Boolean retval = UISupport.confirmOrCancel( "Interface has depending Test Steps which will be removed. Copy Instead?" +
71 "\r\n(moving will remove dependant Test Steps from source project)", "Move Interface" );
72
73 if( retval == null )
74 return false;
75
76 if( retval == true )
77 {
78 boolean importEndpoints = UISupport.confirm( "Move endpoint defaults also?", "Move Interface" );
79 UISupport.select( target.importInterface( source, importEndpoints, true ));
80 return true;
81 }
82 }
83 else if( !UISupport.confirm( "Move Interface [" + source.getName() + "] to Project [" +
84 target.getName() + "]", "Move Interface" ))
85 {
86 return false;
87 }
88
89 boolean importEndpoints = UISupport.confirm( "Move endpoint defaults also?", "Move Interface" );
90 UISupport.select( target.importInterface( source, importEndpoints, false ));
91 source.getProject().removeInterface( source );
92 return true;
93 }
94
95 @Override
96 String getCopyAfterInfo( WsdlInterface source, WsdlProject target )
97 {
98 return "Copy Interface [" + source.getName() + "] to Project [" + target.getName() + "]";
99 }
100
101 @Override
102 String getMoveAfterInfo( WsdlInterface source, WsdlProject target )
103 {
104 return "Move Interface [" + source.getName() + "] to Project [" + target.getName() + "]";
105 }
106
107
108 }