use of org.apache.jmeter.gui.tree.JMeterTreeNode 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 (int nodeIndex = copiedNodes.length - 1; nodeIndex >= 0; nodeIndex--) {
JMeterTreeNode copiedNode = copiedNodes[nodeIndex];
int index = parentNode.getIndex(currentNode) + 1;
treeModel.insertNodeInto(copiedNode, parentNode, index);
}
instance.getMainFrame().repaint();
}
use of org.apache.jmeter.gui.tree.JMeterTreeNode in project jmeter by apache.
the class AddToTree method doAction.
/**
* Adds the specified class to the current node of the tree.
*/
@Override
public void doAction(ActionEvent e) {
GuiPackage guiPackage = GuiPackage.getInstance();
try {
guiPackage.updateCurrentNode();
TestElement testElement = guiPackage.createTestElement(((JComponent) e.getSource()).getName());
JMeterTreeNode parentNode = guiPackage.getCurrentNode();
JMeterTreeNode node = guiPackage.getTreeModel().addComponent(testElement, parentNode);
guiPackage.getNamingPolicy().nameOnCreation(node);
guiPackage.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath()));
} catch (Exception err) {
// $NON-NLS-1$
log.error("Exception while adding a component to tree.", err);
String msg = err.getMessage();
if (msg == null) {
msg = err.toString();
}
JMeterUtils.reportErrorToUser(msg);
}
}
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);
}
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;
}
use of org.apache.jmeter.gui.tree.JMeterTreeNode in project jmeter by apache.
the class Copy method cloneChildren.
@SuppressWarnings("JdkObsolete")
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);
}
}
Aggregations