Search in sources :

Example 26 with JMeterTreeNode

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

the class GenerateTreeGui method actionPerformed.

@Override
public void actionPerformed(ActionEvent action) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeModel treeModel = guiPackage.getTreeModel();
    JMeterTreeNode myTarget = findFirstNodeOfType(org.apache.jmeter.threads.ThreadGroup.class, treeModel);
    if (myTarget == null) {
        JMeterUtils.reportErrorToUser("Cannot find Thread Group");
        return;
    }
    addElements(MenuFactory.CONTROLLERS, "Controllers", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.CONFIG_ELEMENTS, "Config Elements", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.TIMERS, "Timers", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.PRE_PROCESSORS, "Pre Processors", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.SAMPLERS, "Samplers", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.POST_PROCESSORS, "Post Processors", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.ASSERTIONS, "Assertions", guiPackage, treeModel, myTarget);
    addElements(MenuFactory.LISTENERS, "Listeners", guiPackage, treeModel, myTarget);
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 27 with JMeterTreeNode

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

the class UndoHistory method treeNodesInserted.

/**
     * Record adding nodes as the undo step
     *
     * @param tme {@link TreeModelEvent} with event details
     */
@Override
public void treeNodesInserted(TreeModelEvent tme) {
    String name = ((JMeterTreeNode) tme.getTreePath().getLastPathComponent()).getName();
    log.debug("Nodes inserted {}", name);
    final JMeterTreeModel sender = (JMeterTreeModel) tme.getSource();
    add(sender, "Add " + name);
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 28 with JMeterTreeNode

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

the class AddParent method addParentToTree.

protected void addParentToTree(TestElement newParent) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeNode newNode = new JMeterTreeNode(newParent, guiPackage.getTreeModel());
    JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
    JMeterTreeNode parentNode = (JMeterTreeNode) currentNode.getParent();
    int index = parentNode.getIndex(currentNode);
    guiPackage.getTreeModel().insertNodeInto(newNode, parentNode, index);
    JMeterTreeNode[] nodes = guiPackage.getTreeListener().getSelectedNodes();
    for (JMeterTreeNode node : nodes) {
        moveNode(guiPackage, node, newNode);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 29 with JMeterTreeNode

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

the class AddThinkTimeBetweenEachStep method addThinkTimeToChildren.

/**
     * Add Think Time to children of parentNode
     * @param guiPackage {@link GuiPackage}
     * @param parentNode Parent node of elements on which we add think times
     * @throws IllegalUserActionException 
     */
private void addThinkTimeToChildren(GuiPackage guiPackage, JMeterTreeNode parentNode) throws IllegalUserActionException {
    guiPackage.updateCurrentNode();
    boolean insertThinkTime = false;
    try {
        int index = 0;
        while (true) {
            if (index == parentNode.getChildCount()) {
                index++;
                break;
            }
            JMeterTreeNode childNode = (JMeterTreeNode) parentNode.getChildAt(index);
            Object userObject = childNode.getUserObject();
            if (userObject instanceof Sampler || userObject instanceof Controller) {
                insertThinkTime = true;
            }
            if (insertThinkTime) {
                JMeterTreeNode[] nodes = createThinkTime(guiPackage, parentNode);
                if (nodes.length != 2) {
                    throw new IllegalArgumentException("Invalid Think Time, expected 2 nodes, got:" + nodes.length);
                }
                index++;
                addNodesToTreeHierachically(guiPackage, parentNode, nodes, index);
                insertThinkTime = false;
            }
            index++;
        }
    } catch (Exception ex) {
        throw new IllegalUserActionException("Cannot add think times", ex);
    }
}
Also used : Sampler(org.apache.jmeter.samplers.Sampler) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) Controller(org.apache.jmeter.control.Controller) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

Example 30 with JMeterTreeNode

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

the class AddThinkTimeBetweenEachStep method doAction.

@Override
public void doAction(ActionEvent e) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
    if (!(currentNode.getUserObject() instanceof Controller || currentNode.getUserObject() instanceof ThreadGroup)) {
        Toolkit.getDefaultToolkit().beep();
        return;
    }
    try {
        addThinkTimeToChildren(guiPackage, currentNode);
    } catch (Exception err) {
        Toolkit.getDefaultToolkit().beep();
        log.error("Failed to add think times", err);
        JMeterUtils.reportErrorToUser("Failed to add think times", err);
    }
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) ThreadGroup(org.apache.jmeter.threads.ThreadGroup) Controller(org.apache.jmeter.control.Controller) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

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