Method from org.apache.jmeter.gui.tree.JMeterTreeModel Detail: |
public JMeterTreeNode addComponent(TestElement component,
JMeterTreeNode node) throws IllegalUserActionException {
if (node.getUserObject() instanceof AbstractConfigGui) {
throw new IllegalUserActionException("This node cannot hold sub-elements");
}
component.setProperty(TestElement.GUI_CLASS, NameUpdater.getCurrentName(component
.getPropertyAsString(TestElement.GUI_CLASS)));
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.configure(component);
guicomp.modifyTestElement(component);
guiPackage.getCurrentGui(); // put the gui object back
// to the way it was.
}
JMeterTreeNode newNode = new JMeterTreeNode(component, this);
// This check the state of the TestElement and if returns false it
// disable the loaded node
try {
if (component.getProperty(TestElement.ENABLED) instanceof NullProperty
|| component.getPropertyAsBoolean(TestElement.ENABLED)) {
newNode.setEnabled(true);
} else {
newNode.setEnabled(false);
}
} catch (Exception e) {
newNode.setEnabled(true);
}
this.insertNodeInto(newNode, node, node.getChildCount());
return newNode;
}
|
public HashTree addSubTree(HashTree subTree,
JMeterTreeNode current) throws IllegalUserActionException {
Iterator iter = subTree.list().iterator();
while (iter.hasNext()) {
TestElement item = (TestElement) iter.next();
if (item instanceof TestPlan) {
TestPlan tp = (TestPlan) item;
current = (JMeterTreeNode) ((JMeterTreeNode) getRoot()).getChildAt(0);
final TestPlan userObject = (TestPlan) current.getUserObject();
userObject.addTestElement(item);
userObject.setName(item.getName());
userObject.setFunctionalMode(tp.isFunctionalMode());
userObject.setSerialized(tp.isSerialized());
addSubTree(subTree.getTree(item), current);
} else if (item instanceof WorkBench) {
current = (JMeterTreeNode) ((JMeterTreeNode) getRoot()).getChildAt(1);
final TestElement testElement = ((TestElement) current.getUserObject());
testElement.addTestElement(item);
testElement.setName(item.getName());
addSubTree(subTree.getTree(item), current);
} else {
addSubTree(subTree.getTree(item), addComponent(item, current));
}
}
return getCurrentSubTree(current);
}
Adds the sub tree at the given node. Returns a boolean indicating whether
the added sub tree was a full test plan. |
public void clearTestPlan() {
TestElement tp = new TestPlanGui().createTestElement();
clearTestPlan(tp);
}
|
public void clearTestPlan(TestElement testPlan) {
// Remove the workbench and testplan nodes
int children = getChildCount(getRoot());
while (children > 0) {
JMeterTreeNode child = (JMeterTreeNode)getChild(getRoot(), 0);
super.removeNodeFromParent(child);
children = getChildCount(getRoot());
}
// Init the tree
initTree(testPlan,new WorkBenchGui().createTestElement()); // Assumes this is only called from GUI mode
}
|
public HashTree getCurrentSubTree(JMeterTreeNode node) {
ListedHashTree hashTree = new ListedHashTree(node);
Enumeration enumNode = node.children();
while (enumNode.hasMoreElements()) {
JMeterTreeNode child = (JMeterTreeNode) enumNode.nextElement();
hashTree.add(node, getCurrentSubTree(child));
}
return hashTree;
}
|
public JMeterTreeNode getNodeOf(TestElement userObject) {
return traverseAndFind(userObject, (JMeterTreeNode) getRoot());
}
Get the node for a given TestElement object. |
public List getNodesOfType(Class type) {
List nodeList = new LinkedList();
traverseAndFind(type, (JMeterTreeNode) this.getRoot(), nodeList);
return nodeList;
}
Returns a list of tree nodes that hold objects of the given class type.
If none are found, an empty list is returned. |
public HashTree getTestPlan() {
return getCurrentSubTree((JMeterTreeNode) ((JMeterTreeNode) this.getRoot()).getChildAt(0));
}
|
public void removeNodeFromParent(JMeterTreeNode node) {
if (!(node.getUserObject() instanceof TestPlan) && !(node.getUserObject() instanceof WorkBench)) {
super.removeNodeFromParent(node);
}
}
|