use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class TreeSettings method writeTree.
/**
* Writes the tree passed in to the {@link IMemento} argument.
* @param data The {@link IMemento} to store the tree to.
* @param name The name to give to the <code>parent</code> node.
* @param tree The {@link TreeNode} to store.
*/
private static void writeTree(IMemento data, String name, TreeNode tree) {
IMemento child = data.createChild(name);
child.putString(M_DISP, tree.toString());
Object treeData = tree.getData();
if (treeData != null) {
child.putString(M_DATA, treeData.toString());
child.putString(M_DATATYPE, StapTreeDataFactory.getDataObjectID(treeData));
}
if (tree instanceof TreeDefinitionNode) {
child.putString(M_DEFINITON, getStringFromValue(((TreeDefinitionNode) tree).getDefinition()));
}
child.putBoolean(M_CLICKABLE, tree.isClickable());
for (int i = 0, n = tree.getChildCount(); i < n; i++) {
writeTree(child, M_ITEM, tree.getChildAt(i));
}
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class TreeSettingsTest method testDefinitionTrees.
@Test
public void testDefinitionTrees() {
TreeNode temp;
TreeDefinitionNode t1 = new TreeDefinitionNode("t1", "deftree1", "location", true);
TreeDefinitionNode t2 = new TreeDefinitionNode("t2", "deftree2", null, true);
TreeSettings.setTrees(t1, t2);
temp = TreeSettings.getFunctionTree();
assertTrue("Tree should have been saved as a definition node", temp instanceof TreeDefinitionNode);
assertEquals("Funcs definition", t1.getDefinition(), ((TreeDefinitionNode) temp).getDefinition());
assertEquals("Funcs object", t1.getData(), temp.getData());
assertEquals("Funcs display", t1.toString(), temp.toString());
assertEquals("Funcs clickable", t1.isClickable(), temp.isClickable());
temp = TreeSettings.getProbeTree();
assertTrue("Even with a null definition, tree should have been saved as a definition node", temp instanceof TreeDefinitionNode);
assertEquals("Probs definition", t2.getDefinition(), ((TreeDefinitionNode) temp).getDefinition());
assertEquals("Probs object", t2.getData(), temp.getData());
assertEquals("Probs display", t2.toString(), temp.toString());
assertEquals("Probs clickable", t2.isClickable(), temp.isClickable());
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class TestCreateSystemtapScript method prepareTreeSettings.
/**
* Load custom contents into the Function/Probe views.
*/
private static void prepareTreeSettings() {
TapsetLibrary.stop();
try {
probeDef = File.createTempFile("probeDef", ".stp");
funcDef = File.createTempFile("funcDef", ".stp");
probeDef.deleteOnExit();
funcDef.deleteOnExit();
} catch (IOException e) {
}
// Leave one of the files blank to test token search failures.
try (PrintWriter writer = new PrintWriter(probeDef)) {
writer.print("test file\nptest\nlast line\n");
} catch (FileNotFoundException e) {
}
TreeNode testProbNodeParent = new TreeNode(null, false);
// Have static/alias folders to comply with convention (change this later).
testProbNodeParent.add(new TreeNode(probeCategoryEmpty, true));
testProbNodeParent.add(new TreeNode(probeCategoryFull, true));
TreeNode testProbNodeGroup = new TreeNode(probeGroup, true);
String innerProbe = "probegroup.inner";
TreeNode testProbNode = new TreeDefinitionNode(new ProbeNodeData(innerProbe), innerProbe, probeDef.getPath(), true);
testProbNode.add(new TreeNode(new ProbevarNodeData("s:string"), false));
testProbNodeGroup.add(testProbNode);
testProbNodeParent.getChildAt(1).add(testProbNodeGroup);
TreeNode testProbNode2 = new TreeDefinitionNode(new ProbeNodeData(probeSingleWithoutDef), probeSingleWithoutDef, null, true);
testProbNodeParent.getChildAt(1).add(testProbNode2);
TreeNode testFuncNodeParent = new TreeNode(null, false);
TreeNode testFuncNode = new TreeDefinitionNode(new FunctionNodeData("function ftest(x:long)", null), funcNodeName, funcDef.getPath(), true);
testFuncNode.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
testFuncNodeParent.add(testFuncNode);
TreeSettings.setTrees(testFuncNodeParent, testProbNodeParent);
TapsetLibrary.readTreeFile();
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class TreeDefinitionNodeTest method setUp.
@Before
public void setUp() {
data = new StringBuilder("Object");
data2 = "Data";
d = "/usr/share";
d2 = "/usr";
s = "String";
s2 = "bah";
t = new TreeDefinitionNode(data, s, d, true);
child = new TreeDefinitionNode(data2, s2, d2, false);
t.add(child);
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class TreeDefinitionNodeTest method testTreeDefinitionNode.
@Test
public void testTreeDefinitionNode() {
String d1 = "One";
String d2 = "two";
String s1 = "one";
TreeDefinitionNode t = new TreeDefinitionNode(d1, s1, d2, false);
assertEquals("Create child count", 0, t.getChildCount());
assertEquals("Create child string", s1, t.toString());
assertEquals("Create child data", d1, t.getData());
assertEquals("Create child definition", d2, t.getDefinition());
assertFalse("Create child clickable", t.isClickable());
}
Aggregations