use of org.apache.jmeter.control.ModuleController in project jmeter by apache.
the class ModuleControllerGui method buildTreeNodeModel.
/**
* Recursively build module to run tree. Only 4 types of elements are allowed to be added:
* - All controllers except ModuleController
* - TestPlan
* - TestFragmentController
* - AbstractThreadGroup
*
* @param node - element of test plan tree
* @param level - level of element in a tree
* @param parent
*/
private void buildTreeNodeModel(JMeterTreeNode node, int level, DefaultMutableTreeNode parent) {
if (node != null) {
for (int i = 0; i < node.getChildCount(); i++) {
JMeterTreeNode cur = (JMeterTreeNode) node.getChildAt(i);
TestElement te = cur.getTestElement();
if (te instanceof Controller && !(te instanceof ModuleController) && level > 0) {
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(cur);
parent.add(newNode);
buildTreeNodeModel(cur, level + 1, newNode);
} else if (te instanceof TestFragmentController || te instanceof AbstractThreadGroup) {
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(cur);
parent.add(newNode);
buildTreeNodeModel(cur, level + 1, newNode);
} else if (te instanceof TestPlan) {
((DefaultMutableTreeNode) moduleToRunTreeModel.getRoot()).setUserObject(cur);
buildTreeNodeModel(cur, level, (DefaultMutableTreeNode) moduleToRunTreeModel.getRoot());
}
}
}
}
use of org.apache.jmeter.control.ModuleController in project jmeter by apache.
the class ModuleControllerGui method modifyTestElement.
/** {@inheritDoc}} */
@Override
public void modifyTestElement(TestElement element) {
configureTestElement(element);
JMeterTreeNode tn = null;
DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode) this.moduleToRunTreeNodes.getLastSelectedPathComponent();
if (lastSelected != null && lastSelected.getUserObject() instanceof JMeterTreeNode) {
tn = (JMeterTreeNode) lastSelected.getUserObject();
}
if (tn != null) {
selected = tn;
// prevent from selecting thread group or test plan elements
if (isTestElementAllowed(selected.getTestElement())) {
((ModuleController) element).setSelectedNode(selected);
}
}
}
use of org.apache.jmeter.control.ModuleController in project jmeter by apache.
the class ModuleControllerGui method createTestElement.
/** {@inheritDoc}} */
@Override
public TestElement createTestElement() {
ModuleController mc = new ModuleController();
configureTestElement(mc);
if (selected != null) {
mc.setSelectedNode(selected);
}
return mc;
}
use of org.apache.jmeter.control.ModuleController in project jmeter by apache.
the class ModuleControllerGui method configure.
/** {@inheritDoc}} */
@Override
public void configure(TestElement el) {
super.configure(el);
ModuleController controller = (ModuleController) el;
this.selected = controller.getSelectedNode();
if (selected == null && controller.getNodePath() != null) {
warningLabel.setText(// $NON-NLS-1$
JMeterUtils.getResString("module_controller_warning") + renderPath(controller.getNodePath()));
warningLabel.setVisible(true);
expandButton.setEnabled(false);
} else {
warningLabel.setVisible(false);
expandButton.setEnabled(true);
}
reinitialize();
}
Aggregations