Search in sources :

Example 1 with AbstractConfigGui

use of org.apache.jmeter.config.gui.AbstractConfigGui in project jmeter by apache.

the class JMeterTreeModel method addComponent.

/**
     * Add a {@link TestElement} to a {@link JMeterTreeNode}
     * @param component The {@link TestElement} to be used as data for the newly created node
     * @param node The {@link JMeterTreeNode} into which the newly created node is to be inserted
     * @return new {@link JMeterTreeNode} for the given <code>component</code>
     * @throws IllegalUserActionException
     *             when the user object for the <code>node</code> is not an instance
     *             of {@link AbstractConfigGui}
     */
public JMeterTreeNode addComponent(TestElement component, JMeterTreeNode node) throws IllegalUserActionException {
    if (node.getUserObject() instanceof AbstractConfigGui) {
        throw new IllegalUserActionException("This node cannot hold sub-elements");
    }
    GuiPackage guiPackage = GuiPackage.getInstance();
    if (guiPackage != null) {
        // The node can be added in non GUI mode at startup
        guiPackage.updateCurrentNode();
        JMeterGUIComponent guicomp = guiPackage.getGui(component);
        guicomp.clearGui();
        guicomp.configure(component);
        guicomp.modifyTestElement(component);
        // put the gui object back
        guiPackage.getCurrentGui();
    // to the way it was.
    }
    JMeterTreeNode newNode = new JMeterTreeNode(component, this);
    // disable the loaded node
    try {
        newNode.setEnabled(component.isEnabled());
    } catch (Exception e) {
        // TODO - can this ever happen?
        newNode.setEnabled(true);
    }
    this.insertNodeInto(newNode, node, node.getChildCount());
    return newNode;
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) AbstractConfigGui(org.apache.jmeter.config.gui.AbstractConfigGui)

Aggregations

AbstractConfigGui (org.apache.jmeter.config.gui.AbstractConfigGui)1 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)1 GuiPackage (org.apache.jmeter.gui.GuiPackage)1 JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)1