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));
}
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);
}
}
}
}
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);
}
}
}
Aggregations