/* * SoapUI, Copyright (C) 2004-2016 SmartBear Software * * Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * http://ec.europa.eu/idabc/eupl * * Unless required by applicable law or agreed to in writing, software distributed under the Licence is * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the Licence for the specific language governing permissions and limitations * under the Licence. */ package com.eviware.soapui.model.tree.nodes.support; import com.eviware.soapui.model.settings.Settings; import com.eviware.soapui.model.support.TestSuiteListenerAdapter; import com.eviware.soapui.model.testsuite.TestCase; import com.eviware.soapui.model.testsuite.TestSuiteListener; import com.eviware.soapui.security.SecurityTest; import com.eviware.soapui.support.UISupport; /** * ModelItem for LoadTests node * * @author ole.matzura */ public class SecurityTestsModelItem extends EmptyModelItem { private TestCase testCase; private TestSuiteListener listener = new InternalTestSuiteListener(); public SecurityTestsModelItem(TestCase testCase) { super(createLabel(testCase), UISupport.createImageIcon("/security_tests_group.png")); this.testCase = testCase; testCase.getTestSuite().addTestSuiteListener(listener); } private static String createLabel(TestCase testCase) { return "Security Tests (" + testCase.getSecurityTestCount() + ")"; } public Settings getSettings() { return testCase.getSettings(); } @Override public void release() { super.release(); testCase.getTestSuite().removeTestSuiteListener(listener); } @Override public String getName() { return createLabel(testCase); } public void updateLabel() { setName(createLabel(testCase)); } public class InternalTestSuiteListener extends TestSuiteListenerAdapter implements TestSuiteListener { @Override public void securityTestAdded(SecurityTest securityTest) { if (securityTest.getTestCase() == testCase) { updateLabel(); } } @Override public void securityTestRemoved(SecurityTest securityTest) { if (securityTest.getTestCase() == testCase) { updateLabel(); } } @Override public void testCaseRemoved(TestCase testCase) { if (testCase == SecurityTestsModelItem.this.testCase) { testCase.getTestSuite().removeTestSuiteListener(listener); } } } }