use of org.eclipse.linuxtools.internal.callgraph.StapNode in project linuxtools by eclipse.
the class StapGraphMouseListener method mouseUp.
@Override
public void mouseUp(MouseEvent e) {
listener.setStop(true);
graph.removeMouseMoveListener(listener);
graph.removeListener(SWT.MouseExit, exitListener);
List<StapNode> list = graph.getSelection();
if (list.size() == 1) {
int id;
if (list.get(0) != null) {
id = list.get(0).id;
} else {
graph.setSelection(null);
return;
}
graph.setSelection(null);
// ------------Highlighting
if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_TREE || graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_LEVEL) {
for (StapNode n : (List<StapNode>) graph.getNodes()) {
unhighlightall(n);
}
List<Integer> callees = null;
if (graph.isCollapseMode()) {
callees = graph.getNodeData(id).collapsedChildren;
} else {
callees = graph.getNodeData(id).children;
}
for (int subID : callees) {
if (graph.getNode(subID) != null) {
graph.getNode(subID).highlight();
}
}
if (graph.getParentNode(id) != null) {
graph.getParentNode(id).highlight();
}
graph.getNode(id).highlight();
return;
}
} else if (list.size() == 0 && !(graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_AGGREGATE)) {
for (StapNode n : (List<StapNode>) graph.getNodes()) {
unhighlightall(n);
}
}
}
use of org.eclipse.linuxtools.internal.callgraph.StapNode in project linuxtools by eclipse.
the class StapGraphMouseListener method mouseDoubleClick.
@Override
public void mouseDoubleClick(MouseEvent e) {
if (e.stateMask == SWT.CONTROL) {
controlDoubleClick();
return;
}
if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_RADIAL) {
StapNode node = getNodeFromSelection();
if (node == null) {
return;
}
graph.getTreeViewer().collapseToLevel(node.getData(), 0);
graph.getTreeViewer().expandToLevel(node.getData(), 0);
graph.getTreeViewer().setSelection(new StructuredSelection(node.getData()));
int id = node.getData().id;
graph.scale = 1;
// Redraw in the current mode with the new id as the center
// The x,y parameters to draw() are irrelevant for radial mode
graph.draw(id);
// Unhighlight the center node and give it a normal colour
node = graph.getNode(id);
node.unhighlight();
if (graph.getNodeData(id).isMarked()) {
node.setBackgroundColor(StapGraph.CONSTANT_MARKED);
} else {
node.setBackgroundColor(graph.DEFAULT_NODE_COLOR);
}
return;
} else {
StapNode node = getNodeFromSelection();
if (node == null) {
return;
}
unhighlightall(node);
graph.setSelection(null);
// Draw in current modes with 'id' at the top
int id = node.getData().id;
graph.draw(id);
}
graph.setSelection(null);
}
use of org.eclipse.linuxtools.internal.callgraph.StapNode in project linuxtools by eclipse.
the class StapGraphMouseListener method getNodeFromSelection.
private StapNode getNodeFromSelection() {
List<GraphNode> stapNodeList = graph.getSelection();
if (stapNodeList.isEmpty() || stapNodeList.size() != 1) {
graph.setSelection(null);
return null;
}
StapNode node = null;
if (stapNodeList.get(0) instanceof StapNode) {
node = (StapNode) stapNodeList.remove(0);
} else {
graph.setSelection(null);
return null;
}
return node;
}
use of org.eclipse.linuxtools.internal.callgraph.StapNode in project linuxtools by eclipse.
the class StapGraphMouseListener method controlDoubleClick.
private void controlDoubleClick() {
if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_AGGREGATE) {
GraphNode node = getAggregateNodeFromSelection();
if (node == null) {
return;
}
// $NON-NLS-1$
String functionName = (String) node.getData("AGGREGATE_NAME");
FileFinderOpener.findAndOpen(graph.getProject(), functionName);
node.unhighlight();
} else {
StapNode node = getNodeFromSelection();
if (node == null) {
return;
}
int caller = node.getData().id;
if (caller < graph.getFirstUsefulNode()) {
// The only node that satisfies this condition should be main
caller = graph.getFirstUsefulNode();
}
FileFinderOpener.findAndOpen(graph.getProject(), graph.getNodeData(caller).name);
node.unhighlight();
}
graph.setSelection(null);
}
Aggregations