Search in sources :

Example 61 with JMeterTreeNode

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

the class UndoHistory method treeNodesChanged.

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

Example 62 with JMeterTreeNode

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

the class Clear method doAction.

@Override
public void doAction(ActionEvent e) {
    GuiPackage guiPackage = GuiPackage.getInstance();
    final String actionCommand = e.getActionCommand();
    if (actionCommand.equals(ActionNames.CLEAR)) {
        JMeterGUIComponent guiComp = guiPackage.getCurrentGui();
        if (guiComp instanceof Clearable) {
            ((Clearable) guiComp).clearData();
        }
    } else {
        guiPackage.getMainFrame().clearData();
        for (JMeterTreeNode node : guiPackage.getTreeModel().getNodesOfType(Clearable.class)) {
            JMeterGUIComponent guiComp = guiPackage.getGui(node.getTestElement());
            if (guiComp instanceof Clearable) {
                Clearable item = (Clearable) guiComp;
                try {
                    item.clearData();
                } catch (Exception ex) {
                    log.error("Can't clear: {} {}", node, guiComp, ex);
                }
            }
        }
    }
}
Also used : Clearable(org.apache.jmeter.samplers.Clearable) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent)

Example 63 with JMeterTreeNode

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

the class Copy method cloneChildren.

private static void cloneChildren(JMeterTreeNode to, JMeterTreeNode from) {
    Enumeration<?> enumFrom = from.children();
    while (enumFrom.hasMoreElements()) {
        JMeterTreeNode child = (JMeterTreeNode) enumFrom.nextElement();
        JMeterTreeNode childClone = (JMeterTreeNode) child.clone();
        childClone.setUserObject(((TestElement) child.getUserObject()).clone());
        to.add(childClone);
        cloneChildren((JMeterTreeNode) to.getLastChild(), child);
    }
}
Also used : JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 64 with JMeterTreeNode

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

the class Copy method cloneTreeNode.

public static JMeterTreeNode cloneTreeNode(JMeterTreeNode node) {
    JMeterTreeNode treeNode = (JMeterTreeNode) node.clone();
    treeNode.setUserObject(((TestElement) node.getUserObject()).clone());
    cloneChildren(treeNode, node);
    return treeNode;
}
Also used : JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 65 with JMeterTreeNode

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

the class Copy method doAction.

@Override
public void doAction(ActionEvent e) {
    JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
    JMeterTreeNode[] nodes = treeListener.getSelectedNodes();
    nodes = keepOnlyAncestors(nodes);
    nodes = cloneTreeNodes(nodes);
    setCopiedNodes(nodes);
}
Also used : JMeterTreeListener(org.apache.jmeter.gui.tree.JMeterTreeListener) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

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