blob: 99fb4aa63f14bd4fea4f41d5398e274b16f6c591 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*******************************************************************************
* Copyright (c) 2009 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.linuxtools.systemtap.local.callgraph.StapData;
import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph;
public class StapTreeContentProvider implements ITreeContentProvider{
private StapGraph graph;
@Override
public Object[] getChildren(Object parentElement) {
List<StapData> EMPTY = new ArrayList<StapData>();
if (parentElement instanceof StapData) {
StapData parent = ((StapData) parentElement);
List<Integer> childrenIDs = parent.collapsedCallees;
for (int val : childrenIDs) {
if (graph.getData(val) != null) {
EMPTY.add(graph.getData(val));
}
}
}
return EMPTY.toArray();
}
@Override
public Object getParent(Object element) {
if (element instanceof StapData) {
return graph.getData(((StapData) element).collapsedCaller);
}
return null;
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof StapData)
return element == null ? false :
((StapData) element).callees.size() > 0;
return false;
}
@Override
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public void setGraph(StapGraph graph) {
this.graph = graph;
}
}
|