01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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.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: private TestCase testCase;
30: private TestSuiteListener listener = new InternalTestSuiteListener();
31:
32: public WsdlLoadTestsModelItem(TestCase testCase) {
33: super (createLabel(testCase), UISupport
34: .createImageIcon("/loadtests.gif"));
35: this .testCase = testCase;
36:
37: testCase.getTestSuite().addTestSuiteListener(listener);
38: }
39:
40: private static String createLabel(TestCase testCase) {
41: return "Load Tests (" + testCase.getLoadTestCount() + ")";
42: }
43:
44: public Settings getSettings() {
45: return testCase.getSettings();
46: }
47:
48: @Override
49: public void release() {
50: super .release();
51: testCase.getTestSuite().removeTestSuiteListener(listener);
52: }
53:
54: public void updateLabel() {
55: setName(createLabel(testCase));
56: }
57:
58: public class InternalTestSuiteListener extends
59: TestSuiteListenerAdapter implements TestSuiteListener {
60: @Override
61: public void loadTestAdded(LoadTest loadTest) {
62: updateLabel();
63: }
64:
65: @Override
66: public void loadTestRemoved(LoadTest loadTest) {
67: updateLabel();
68: }
69: }
70: }
|