Skip to main content
summaryrefslogtreecommitdiffstats
blob: 05cdd24927cebf979b9eb158fa37800a5db5fae2 (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
/*******************************************************************************
 * 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.callgraph.treeviewer;

import java.util.Iterator;

import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.linuxtools.callgraph.CallgraphView;
import org.eclipse.linuxtools.callgraph.StapData;
import org.eclipse.linuxtools.callgraph.StapGraph;

public class StapTreeDoubleClickListener implements IDoubleClickListener {

	private StapGraph graph;
	private TreeViewer viewer;

	public StapTreeDoubleClickListener(TreeViewer t , StapGraph g) {
		this.graph  = g;
		this.viewer = t;
	}

	@Override
	public void doubleClick(DoubleClickEvent event) {
		if (!(event.getSelection() instanceof IStructuredSelection))
			return;
		IStructuredSelection selection = (IStructuredSelection) event.getSelection();
		if (selection.size() != 1) return;
		
		
		//Expand the current node in the tree viewer and on the graph
        for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
        	StapData data = (StapData) iterator.next();
        	viewer.collapseToLevel(data, 1);
        	viewer.expandToLevel(data, 1);
        	graph.setCollapseMode(true);
        	graph.draw(data.id);
        	graph.getNode(data.id).unhighlight();
        }
        
        CallgraphView.maximizeIfUnmaximized();
        graph.setFocus();
	}

}

Back to the top