Search in sources :

Example 1 with ModuleController

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());
            }
        }
    }
}
Also used : TestFragmentController(org.apache.jmeter.control.TestFragmentController) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TestPlan(org.apache.jmeter.testelement.TestPlan) AbstractThreadGroup(org.apache.jmeter.threads.AbstractThreadGroup) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestElement(org.apache.jmeter.testelement.TestElement) ModuleController(org.apache.jmeter.control.ModuleController) Controller(org.apache.jmeter.control.Controller) TestFragmentController(org.apache.jmeter.control.TestFragmentController) ModuleController(org.apache.jmeter.control.ModuleController)

Example 2 with ModuleController

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);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) ModuleController(org.apache.jmeter.control.ModuleController)

Example 3 with ModuleController

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;
}
Also used : ModuleController(org.apache.jmeter.control.ModuleController)

Example 4 with ModuleController

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();
}
Also used : ModuleController(org.apache.jmeter.control.ModuleController)

Aggregations

ModuleController (org.apache.jmeter.control.ModuleController)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)2 Controller (org.apache.jmeter.control.Controller)1 TestFragmentController (org.apache.jmeter.control.TestFragmentController)1 TestElement (org.apache.jmeter.testelement.TestElement)1 TestPlan (org.apache.jmeter.testelement.TestPlan)1 AbstractThreadGroup (org.apache.jmeter.threads.AbstractThreadGroup)1