Search in sources :

Example 6 with JMeterTreeListener

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

the class Duplicate method doAction.

@Override
public void doAction(ActionEvent e) {
    GuiPackage instance = GuiPackage.getInstance();
    JMeterTreeListener treeListener = instance.getTreeListener();
    JMeterTreeNode[] copiedNodes = Copy.cloneTreeNodes(treeListener.getSelectedNodes());
    JMeterTreeNode currentNode = treeListener.getCurrentNode();
    JMeterTreeNode parentNode = (JMeterTreeNode) currentNode.getParent();
    JMeterTreeModel treeModel = instance.getTreeModel();
    for (JMeterTreeNode copiedNode : copiedNodes) {
        int index = parentNode.getIndex(currentNode) + 1;
        treeModel.insertNodeInto(copiedNode, parentNode, index);
    }
    instance.getMainFrame().repaint();
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeListener(org.apache.jmeter.gui.tree.JMeterTreeListener) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 7 with JMeterTreeListener

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

the class Paste method doAction.

/**
     * @see Command#doAction(ActionEvent)
     */
@Override
public void doAction(ActionEvent e) {
    JMeterTreeNode[] draggedNodes = Copy.getCopiedNodes();
    if (draggedNodes == null) {
        Toolkit.getDefaultToolkit().beep();
        return;
    }
    JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
    JMeterTreeNode currentNode = treeListener.getCurrentNode();
    if (MenuFactory.canAddTo(currentNode, draggedNodes)) {
        for (JMeterTreeNode draggedNode : draggedNodes) {
            if (draggedNode != null) {
                addNode(currentNode, draggedNode);
            }
        }
    } else {
        Toolkit.getDefaultToolkit().beep();
    }
    GuiPackage.getInstance().getMainFrame().repaint();
}
Also used : JMeterTreeListener(org.apache.jmeter.gui.tree.JMeterTreeListener) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Aggregations

JMeterTreeListener (org.apache.jmeter.gui.tree.JMeterTreeListener)7 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)6 JTree (javax.swing.JTree)2 TreePath (javax.swing.tree.TreePath)2 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)2 ConversionException (com.thoughtworks.xstream.converters.ConversionException)1 ActionEvent (java.awt.event.ActionEvent)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 SocketException (java.net.SocketException)1 TreeNode (javax.swing.tree.TreeNode)1 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)1 GuiPackage (org.apache.jmeter.gui.GuiPackage)1 MainFrame (org.apache.jmeter.gui.MainFrame)1 ActionRouter (org.apache.jmeter.gui.action.ActionRouter)1 ConfigurationException (org.apache.jmeter.report.config.ConfigurationException)1 GenerationException (org.apache.jmeter.report.dashboard.GenerationException)1 AbstractThreadGroup (org.apache.jmeter.threads.AbstractThreadGroup)1