View | Details | Raw Unified | Return to bug 57061
Collapse All | Expand All

(-)src/core/org/apache/jmeter/gui/action/Save.java (-3 / +8 lines)
Lines 31-36 Link Here
31
31
32
import org.apache.commons.io.FilenameUtils;
32
import org.apache.commons.io.FilenameUtils;
33
import org.apache.jmeter.control.gui.TestFragmentControllerGui;
33
import org.apache.jmeter.control.gui.TestFragmentControllerGui;
34
import org.apache.jmeter.engine.TreeCloner;
34
import org.apache.jmeter.exceptions.IllegalUserActionException;
35
import org.apache.jmeter.exceptions.IllegalUserActionException;
35
import org.apache.jmeter.gui.GuiPackage;
36
import org.apache.jmeter.gui.GuiPackage;
36
import org.apache.jmeter.gui.tree.JMeterTreeNode;
37
import org.apache.jmeter.gui.tree.JMeterTreeNode;
Lines 101-116 Link Here
101
        } 
102
        } 
102
        else if (e.getActionCommand().equals(ActionNames.SAVE_AS_TEST_FRAGMENT)) {
103
        else if (e.getActionCommand().equals(ActionNames.SAVE_AS_TEST_FRAGMENT)) {
103
            JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
104
            JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
104
            if(checkAcceptableForTestFragment(nodes)) {
105
            if(checkAcceptableForTestFragment(nodes)) {                
105
                subTree = GuiPackage.getInstance().getCurrentSubTree();
106
                subTree = GuiPackage.getInstance().getCurrentSubTree();
106
                
107
                // Create Test Fragment node
107
                TestElement element = GuiPackage.getInstance().createTestElement(TestFragmentControllerGui.class.getName());
108
                TestElement element = GuiPackage.getInstance().createTestElement(TestFragmentControllerGui.class.getName());
108
                HashTree hashTree = new ListedHashTree();
109
                HashTree hashTree = new ListedHashTree();
109
                HashTree tfTree = hashTree.add(new JMeterTreeNode(element, null));
110
                HashTree tfTree = hashTree.add(new JMeterTreeNode(element, null));
110
                for (int i = 0; i < nodes.length; i++) {
111
                for (int i = 0; i < nodes.length; i++) {
111
                    tfTree.add(nodes[i]);
112
                    // Clone deeply current node
113
                    TreeCloner cloner = new TreeCloner(false);
114
                    GuiPackage.getInstance().getTreeModel().getCurrentSubTree(nodes[i]).traverse(cloner);
115
                    // Add clone to tfTree
116
                    tfTree.add(cloner.getClonedTree());
112
                }
117
                }
113
                subTree = hashTree;      
118
                subTree = hashTree;      
114
            } else {
119
            } else {
115
                JMeterUtils.reportErrorToUser(
120
                JMeterUtils.reportErrorToUser(
116
                        JMeterUtils.getResString("save_as_test_fragment_error"), // $NON-NLS-1$
121
                        JMeterUtils.getResString("save_as_test_fragment_error"), // $NON-NLS-1$

Return to bug 57061