1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.tree.nodes.support;
14
15 import com.eviware.soapui.model.settings.Settings;
16 import com.eviware.soapui.model.support.TestSuiteListenerAdapter;
17 import com.eviware.soapui.model.testsuite.LoadTest;
18 import com.eviware.soapui.model.testsuite.TestCase;
19 import com.eviware.soapui.model.testsuite.TestSuiteListener;
20 import com.eviware.soapui.support.UISupport;
21
22 /***
23 * ModelItem for LoadTests node
24 *
25 * @author ole.matzura
26 */
27
28 public class WsdlLoadTestsModelItem extends EmptyModelItem
29 {
30 private TestCase testCase;
31 private TestSuiteListener listener = new InternalTestSuiteListener();
32
33 public WsdlLoadTestsModelItem( TestCase testCase )
34 {
35 super( createLabel( testCase ), UISupport.createImageIcon( "/loadtests.gif" ) );
36 this.testCase = testCase;
37
38 testCase.getTestSuite().addTestSuiteListener( listener );
39 }
40
41 private static String createLabel( TestCase testCase )
42 {
43 return "Load Tests (" + testCase.getLoadTestCount() + ")";
44 }
45
46 public Settings getSettings()
47 {
48 return testCase.getSettings();
49 }
50
51 @Override
52 public void release()
53 {
54 super.release();
55 testCase.getTestSuite().removeTestSuiteListener( listener );
56 }
57
58 @Override
59 public String getName()
60 {
61 return createLabel( testCase );
62 }
63
64 public void updateLabel()
65 {
66 setName( createLabel( testCase ) );
67 }
68
69 public class InternalTestSuiteListener extends TestSuiteListenerAdapter implements TestSuiteListener
70 {
71 @Override
72 public void loadTestAdded( LoadTest loadTest )
73 {
74 if( loadTest.getTestCase() == testCase )
75 updateLabel();
76 }
77
78 @Override
79 public void loadTestRemoved( LoadTest loadTest )
80 {
81 if( loadTest.getTestCase() == testCase )
82 updateLabel();
83 }
84
85 @Override
86 public void testCaseRemoved( TestCase testCase )
87 {
88 if( testCase == WsdlLoadTestsModelItem.this.testCase )
89 {
90 testCase.getTestSuite().removeTestSuiteListener( listener );
91 }
92 }
93 }
94 }