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