1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.actions.loadtest;
14
15 import java.awt.event.ActionEvent;
16
17 import javax.swing.AbstractAction;
18 import javax.swing.Action;
19
20 import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
21 import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
22 import com.eviware.soapui.model.support.LoadTestRunListenerAdapter;
23 import com.eviware.soapui.model.testsuite.LoadTestRunContext;
24 import com.eviware.soapui.model.testsuite.LoadTestRunner;
25 import com.eviware.soapui.support.UISupport;
26
27 /***
28 * Removes a WsdlLoadTest from its WsdlTestSuite
29 *
30 * @author Ole.Matzura
31 */
32
33 public class RemoveLoadTestAction extends AbstractAction
34 {
35 private final WsdlLoadTest loadTest;
36 private final InternalLoadTestRunListener internalLoadTestRunListener = new InternalLoadTestRunListener();
37
38 public RemoveLoadTestAction( WsdlLoadTest loadTest )
39 {
40 super( "Remove" );
41 this.loadTest = loadTest;
42 putValue( Action.SHORT_DESCRIPTION, "Removes this Test Schedule from the test-case" );
43 putValue( Action.ACCELERATOR_KEY, UISupport.getKeyStroke( "DELETE" ));
44
45 loadTest.addLoadTestRunListener( internalLoadTestRunListener);
46 }
47
48 public void actionPerformed(ActionEvent e)
49 {
50 if( UISupport.confirm( "Remove LoadTest [" + loadTest.getName() + "] from test-casee", "Remove LoadTest" ))
51 {
52 ((WsdlTestCase)loadTest.getTestCase()).removeLoadTest( loadTest );
53 }
54 }
55
56 private final class InternalLoadTestRunListener extends LoadTestRunListenerAdapter
57 {
58 public void beforeLoadTest(LoadTestRunner loadTestRunner, LoadTestRunContext context)
59 {
60 setEnabled( false );
61 }
62
63 public void afterLoadTest(LoadTestRunner loadTestRunner, LoadTestRunContext context)
64 {
65 setEnabled( true );
66 }
67 }
68 }