1
/*******************************************************************************
2
* Copyright (c) 2006 IBM Corporation.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
*******************************************************************************/
12
package org.eclipse.linuxtools.systemtap.ui.structures;
14
import java.util.ArrayList;
16
public class TreeNode {
17
public TreeNode(Object d, boolean c) {
18
children = new ArrayList<TreeNode>();
25
display = d.toString();
28
public TreeNode(Object d, String disp, boolean c) {
29
children = new ArrayList<TreeNode>();
35
public void add(TreeNode item) {
39
public void addAt(TreeNode item, int location) {
40
children.add(Math.min(children.size(), location), item);
43
public int getChildCount() {
44
return children.size();
47
public TreeNode getChildAt(int i){
48
if(children.size() > i)
49
return (TreeNode)children.get(i);
54
public Object getData() {
58
public boolean isClickable() {
62
public boolean remove(int i) {
63
if(children.size() > i)
64
return(null != children.remove(i));
69
public boolean removeAll() {
70
for(int i=children.size()-1; i>=0; i--) {
76
public void setData(Object d) {
80
public void setDisplay(String disp) {
85
* Restructures the tree so that probes are grouped by type and
86
* functions are sorted alphabetically.
88
public void sortTree() {
92
for(int i=0; i<this.getChildCount(); i++) {
93
temp = this.getChildAt(i);
100
* Performs quicksort on the level.
102
public void sortLevel() {
105
Object children[] = this.children.toArray();
107
Sort.quicksort(children, 0, children.length-1);
109
for(j=0; j<children.length; j++)
110
this.add((TreeNode)children[j]);
113
public String toString() {
117
public void dispose() {
119
for(int i=children.size()-1; i>=0; i--)
120
((TreeNode)children.get(i)).dispose();
126
private ArrayList<TreeNode> children;
128
private String display;
129
private boolean clickable;