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

(-)src/core/org/apache/jmeter/gui/action/Cut.java (-1 / +23 lines)
Lines 19-24 Link Here
19
package org.apache.jmeter.gui.action;
19
package org.apache.jmeter.gui.action;
20
20
21
import java.awt.event.ActionEvent;
21
import java.awt.event.ActionEvent;
22
import java.util.ArrayList;
22
import java.util.HashSet;
23
import java.util.HashSet;
23
import java.util.Set;
24
import java.util.Set;
24
25
Lines 51-60 public class Cut extends AbstractAction { Link Here
51
        GuiPackage guiPack = GuiPackage.getInstance();
52
        GuiPackage guiPack = GuiPackage.getInstance();
52
        JMeterTreeNode[] currentNodes = guiPack.getTreeListener().getSelectedNodes();
53
        JMeterTreeNode[] currentNodes = guiPack.getTreeListener().getSelectedNodes();
53
54
55
        // if a child and one of its ancestors are selected : only keep the ancestor
56
        currentNodes = filterNodes(currentNodes);
57
        
54
        Copy.setCopiedNodes(currentNodes);
58
        Copy.setCopiedNodes(currentNodes);
55
        for (int i = 0; i < currentNodes.length; i++) {
59
        for (int i = 0; i < currentNodes.length; i++) {
56
            guiPack.getTreeModel().removeNodeFromParent(currentNodes[i]);
60
            guiPack.getTreeModel().removeNodeFromParent(currentNodes[i]);
57
        }
61
        }
58
        guiPack.getMainFrame().repaint();
62
        guiPack.getMainFrame().repaint();
59
    }
63
    }
64
65
    private JMeterTreeNode[] filterNodes(JMeterTreeNode[] currentNodes) {
66
        ArrayList<JMeterTreeNode> nodes = new ArrayList<JMeterTreeNode>();
67
        for (int i = 0; i < currentNodes.length; i++) {
68
            boolean exclude = false;
69
            for (int j = 0; j < currentNodes.length; j++) {
70
                if(i!=j && currentNodes[i].isNodeAncestor(currentNodes[j])) {
71
                    exclude = true;
72
                    break;
73
                }
74
            }
75
            
76
            if(!exclude) {
77
                nodes.add(currentNodes[i]);
78
            }
79
        }
80
        
81
        return nodes.toArray(new JMeterTreeNode[nodes.size()]);
82
    }
60
}
83
}
61
- 

Return to bug 54847