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