use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class KernelSourceAction method run.
/**
* The main code body for this action. Causes one of the following to occur:
* <ul>
* <li>If the selected node is clickable, as specified in <code>TreeNode.isClickable</code>
* the browser creates an instance of <code>CEditor</code> on the file specified in the selection
* (<code>KernelBrowserView</code>'s tree only marks clickable on files, not folders) and
* opens it on the current window</li>
* <li>If the selected node is not clickable, the code runs the action specified in
* <code>TreeExpandCollapseAction</code></li>
* @see org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.c.CEditor
* @see TreeNode#isClickable()
* @see TreeExpandCollapseAction
*/
@Override
public void run() {
IWorkbench wb = PlatformUI.getWorkbench();
Object o = getSelectedElement();
if (o instanceof TreeNode) {
TreeNode t = (TreeNode) o;
if (t.isClickable()) {
IFileStore fs = (IFileStore) t.getData();
if (fs != null) {
IEditorInput input = new FileStoreEditorInput(fs);
try {
wb.getActiveWorkbenchWindow().getActivePage().openEditor(input, CDT_EDITOR_ID);
} catch (PartInitException e) {
// $NON-NLS-1$
ExceptionErrorDialog.openError(Localization.getString("KernelSourceAction.CantOpenEditor"), e);
}
}
} else {
runExpandAction();
}
}
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class TreeNodeTest method testAdd.
@Test
public void testAdd() {
t.add(new TreeNode("One", "tne", false));
assertEquals("Add child", 3, t.getChildCount());
t.add(new TreeNode("two", false));
assertEquals("Add child2", 4, t.getChildCount());
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class TreeNodeTest method testGetChildAt.
@Test
public void testGetChildAt() {
TreeNode child1 = new TreeNode("1", false);
t.add(child1);
TreeNode child2 = new TreeNode("2", false);
t.add(child2);
TreeNode c = t.getChildAt(0);
assertEquals("Retreive first child from tree", child, c);
c = t.getChildAt(2);
assertEquals("Retreive middle child from tree", child1, c);
c = t.getChildAt(3);
assertEquals("Retreive last child from tree", child2, c);
assertNull("No child here", t.getChildAt(10));
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class TreeNodeTest method testRemove.
@Test
public void testRemove() {
TreeNode child1 = new TreeNode("1", false);
t.add(child1);
TreeNode child2 = new TreeNode("2", false);
t.add(child2);
TreeNode child3 = new TreeNode("3", false);
t.add(child3);
assertEquals("Full tree before remove", 5, t.getChildCount());
assertTrue(t.remove(1));
assertEquals("Remove middle child from tree", 4, t.getChildCount());
assertTrue(t.remove(0));
assertEquals("Remove first child from tree", 3, t.getChildCount());
assertTrue(t.remove(1));
assertEquals("Remove last child from tree", 2, t.getChildCount());
assertFalse(t.remove(10));
assertEquals("Remove IndexOutOfBounds", 2, t.getChildCount());
}
Aggregations