001: /*
002: * soapUI, copyright (C) 2004-2007 eviware.com
003: *
004: * soapUI is free software; you can redistribute it and/or modify it under the
005: * terms of version 2.1 of the GNU Lesser General Public License as published by
006: * the Free Software Foundation.
007: *
008: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: * See the GNU Lesser General Public License for more details at gnu.org.
011: */
012:
013: package com.eviware.soapui.impl.wsdl.actions.teststep;
014:
015: import java.util.List;
016:
017: import com.eviware.soapui.SoapUI;
018: import com.eviware.soapui.impl.wsdl.actions.support.ShowDesktopPanelAction;
019: import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
020: import com.eviware.soapui.support.action.SoapUIActionGroup;
021: import com.eviware.soapui.support.action.SoapUIActionMapping;
022: import com.eviware.soapui.support.action.support.DefaultActionMapping;
023: import com.eviware.soapui.support.action.support.DefaultSoapUIActionGroup;
024:
025: /**
026: * SoapUIActionGroup for WsdlTestSteps
027: *
028: * @author ole.matzura
029: */
030:
031: public class WsdlTestStepSoapUIActionGroup extends
032: DefaultSoapUIActionGroup<WsdlTestStep> {
033: private boolean initialized;
034:
035: public WsdlTestStepSoapUIActionGroup(String id, String name) {
036: super (id, name);
037: }
038:
039: public List<SoapUIActionMapping<WsdlTestStep>> getActionMappings(
040: WsdlTestStep modelItem) {
041: List<SoapUIActionMapping<WsdlTestStep>> actions = super
042: .getActionMappings(modelItem);
043: SoapUIActionMapping<WsdlTestStep> toggleDisabledActionMapping = null;
044:
045: if (!initialized) {
046: int insertIndex = 0;
047:
048: // add open-editor action
049: if (modelItem.hasEditor()) {
050: DefaultActionMapping<WsdlTestStep> actionMapping = new DefaultActionMapping<WsdlTestStep>(
051: ShowDesktopPanelAction.SOAPUI_ACTION_ID,
052: "ENTER", null, true, modelItem);
053:
054: actionMapping.setName("Open Editor");
055: actionMapping
056: .setDescription("Opens the editor for this TestStep");
057:
058: actions.add(0, actionMapping);
059: insertIndex++;
060: }
061:
062: toggleDisabledActionMapping = new DefaultActionMapping<WsdlTestStep>(
063: ToggleDisableTestStepAction.SOAPUI_ACTION_ID, null,
064: null, false, modelItem);
065:
066: actions.add(insertIndex, toggleDisabledActionMapping);
067: insertIndex++;
068:
069: // add default teststep actions
070: SoapUIActionGroup<WsdlTestStep> actionGroup = SoapUI
071: .getActionRegistry().getActionGroup(
072: "WsdlTestStepActions");
073: if (actionGroup != null) {
074: actions.addAll(insertIndex, actionGroup
075: .getActionMappings(modelItem));
076: }
077:
078: initialized = true;
079: } else {
080: for (int c = 0; c < actions.size(); c++) {
081: if (actions.get(c).getActionId().equals(
082: ToggleDisableTestStepAction.SOAPUI_ACTION_ID)) {
083: toggleDisabledActionMapping = actions.get(c);
084: break;
085: }
086: }
087: }
088:
089: if (toggleDisabledActionMapping != null) {
090: if (modelItem.isDisabled()) {
091: toggleDisabledActionMapping.setName("Enable TestStep");
092: toggleDisabledActionMapping
093: .setDescription("Enable this TestStep during TestCase execution");
094: } else {
095: toggleDisabledActionMapping.setName("Disable TestStep");
096: toggleDisabledActionMapping
097: .setDescription("Disables this TestStep during TestCase execution");
098: }
099: }
100:
101: return actions;
102: }
103:
104: }
|