Search in sources :

Example 6 with TreeDefinitionNode

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));
    }
}
Also used : TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) IMemento(org.eclipse.ui.IMemento)

Example 7 with TreeDefinitionNode

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());
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) Test(org.junit.Test)

Example 8 with TreeDefinitionNode

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();
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) FunctionNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData) TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ProbeNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData) FuncparamNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData) ProbevarNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData) PrintWriter(java.io.PrintWriter)

Example 9 with TreeDefinitionNode

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);
}
Also used : TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) Before(org.junit.Before)

Example 10 with TreeDefinitionNode

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());
}
Also used : TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) Test(org.junit.Test)

Aggregations

TreeDefinitionNode (org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode)10 TreeNode (org.eclipse.linuxtools.systemtap.structures.TreeNode)4 FunctionNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData)2 IMemento (org.eclipse.ui.IMemento)2 Test (org.junit.Test)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Matcher (java.util.regex.Matcher)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 OpenFileHandler (org.eclipse.linuxtools.internal.systemtap.ui.ide.OpenFileHandler)1 STPEditor (org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor)1 FuncparamNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData)1 ISearchableNode (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ISearchableNode)1 ProbeNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData)1 ProbevarNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData)1 IEditorPart (org.eclipse.ui.IEditorPart)1 Before (org.junit.Before)1