Search in sources :

Example 66 with JMeterTreeNode

use of org.apache.jmeter.gui.tree.JMeterTreeNode in project jmeter by apache.

the class ModuleController method setNodePath.

private void setNodePath() {
    List<String> nodePath = new ArrayList<>();
    if (selectedNode != null) {
        TreeNode[] path = selectedNode.getPath();
        for (TreeNode node : path) {
            nodePath.add(((JMeterTreeNode) node).getName());
        }
    }
    setProperty(new CollectionProperty(NODE_PATH, nodePath));
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TreeNode(javax.swing.tree.TreeNode) ArrayList(java.util.ArrayList)

Example 67 with JMeterTreeNode

use of org.apache.jmeter.gui.tree.JMeterTreeNode in project jmeter by apache.

the class JMeter method convertSubTree.

/**
     * Remove disabled elements
     * Replace the ReplaceableController with the target subtree
     *
     * @param tree The {@link HashTree} to convert
     */
public static void convertSubTree(HashTree tree) {
    LinkedList<Object> copyList = new LinkedList<>(tree.list());
    for (Object o : copyList) {
        if (o instanceof TestElement) {
            TestElement item = (TestElement) o;
            if (item.isEnabled()) {
                if (item instanceof ReplaceableController) {
                    ReplaceableController rc = ensureReplaceableControllerIsLoaded(item);
                    HashTree subTree = tree.getTree(item);
                    if (subTree != null) {
                        HashTree replacementTree = rc.getReplacementSubTree();
                        if (replacementTree != null) {
                            convertSubTree(replacementTree);
                            tree.replaceKey(item, rc);
                            tree.set(rc, replacementTree);
                        }
                    }
                } else {
                    // not Replaceable Controller
                    convertSubTree(tree.getTree(item));
                }
            } else {
                // Not enabled
                tree.remove(item);
            }
        } else {
            // Not a TestElement
            JMeterTreeNode item = (JMeterTreeNode) o;
            if (item.isEnabled()) {
                // @see StandardJMeterEngine.run()
                if (item.getUserObject() instanceof ReplaceableController) {
                    TestElement controllerAsItem = item.getTestElement();
                    ReplaceableController rc = ensureReplaceableControllerIsLoaded(controllerAsItem);
                    HashTree subTree = tree.getTree(item);
                    if (subTree != null) {
                        HashTree replacementTree = rc.getReplacementSubTree();
                        if (replacementTree != null) {
                            convertSubTree(replacementTree);
                            tree.replaceKey(item, rc);
                            tree.set(rc, replacementTree);
                        }
                    }
                } else {
                    // Not a ReplaceableController
                    convertSubTree(tree.getTree(item));
                    TestElement testElement = item.getTestElement();
                    tree.replaceKey(item, testElement);
                }
            } else {
                // Not enabled
                tree.remove(item);
            }
        }
    }
}
Also used : HashTree(org.apache.jorphan.collections.HashTree) ReplaceableController(org.apache.jmeter.control.ReplaceableController) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestElement(org.apache.jmeter.testelement.TestElement) RemoteThreadsListenerTestElement(org.apache.jmeter.threads.RemoteThreadsListenerTestElement) LinkedList(java.util.LinkedList)

Example 68 with JMeterTreeNode

use of org.apache.jmeter.gui.tree.JMeterTreeNode in project jmeter by apache.

the class RecordController method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == clearButton) {
        GuiPackage guiPackage = GuiPackage.getInstance();
        JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
        if (!(currentNode.getUserObject() instanceof org.apache.jmeter.protocol.http.control.RecordingController)) {
            Toolkit.getDefaultToolkit().beep();
            return;
        }
        try {
            guiPackage.updateCurrentNode();
            JMeterTreeModel treeModel = guiPackage.getTreeModel();
            int childCount = currentNode.getChildCount();
            for (int i = 0; i < childCount; i++) {
                JMeterTreeNode node = (JMeterTreeNode) currentNode.getChildAt(0);
                treeModel.removeNodeFromParent(node);
            }
        } catch (Exception err) {
            Toolkit.getDefaultToolkit().beep();
            log.error("Error while removing recorded samples", err);
        }
    }
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) RecordingController(org.apache.jmeter.protocol.http.control.RecordingController)

Aggregations

JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)68 GuiPackage (org.apache.jmeter.gui.GuiPackage)21 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)18 TestElement (org.apache.jmeter.testelement.TestElement)18 TreePath (javax.swing.tree.TreePath)10 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)10 IOException (java.io.IOException)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)7 TestPlan (org.apache.jmeter.testelement.TestPlan)7 HashTree (org.apache.jorphan.collections.HashTree)7 ActionEvent (java.awt.event.ActionEvent)6 JTree (javax.swing.JTree)6 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)6 Controller (org.apache.jmeter.control.Controller)6 JMeterTreeListener (org.apache.jmeter.gui.tree.JMeterTreeListener)6 TreeNode (javax.swing.tree.TreeNode)5 LinkedList (java.util.LinkedList)4 JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)4 WorkBench (org.apache.jmeter.testelement.WorkBench)4 ListedHashTree (org.apache.jorphan.collections.ListedHashTree)4