~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/treeviewer/StapTreeDoubleClickListener.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2009 Red Hat, Inc.
 
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
 
7
 * 
 
8
 * Contributors:
 
9
 *     Red Hat - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.callgraph.treeviewer;
 
12
 
 
13
import java.util.Iterator;
 
14
 
 
15
import org.eclipse.jface.viewers.DoubleClickEvent;
 
16
import org.eclipse.jface.viewers.IDoubleClickListener;
 
17
import org.eclipse.jface.viewers.IStructuredSelection;
 
18
import org.eclipse.jface.viewers.TreeViewer;
 
19
import org.eclipse.linuxtools.internal.callgraph.StapData;
 
20
import org.eclipse.linuxtools.internal.callgraph.StapGraph;
 
21
 
 
22
public class StapTreeDoubleClickListener implements IDoubleClickListener {
 
23
 
 
24
        private StapGraph graph;
 
25
        private TreeViewer viewer;
 
26
 
 
27
        public StapTreeDoubleClickListener(TreeViewer t , StapGraph g) {
 
28
                this.graph  = g;
 
29
                this.viewer = t;
 
30
        }
 
31
 
 
32
        @Override
 
33
        public void doubleClick(DoubleClickEvent event) {
 
34
                if (!(event.getSelection() instanceof IStructuredSelection))
 
35
                        return;
 
36
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
 
37
                if (selection.size() != 1) return;
 
38
                
 
39
                
 
40
                //Expand the current node in the tree viewer and on the graph
 
41
        for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
 
42
                StapData data = (StapData) iterator.next();
 
43
                viewer.collapseToLevel(data, 1);
 
44
                viewer.expandToLevel(data, 1);
 
45
                graph.setCollapseMode(true);
 
46
                graph.draw(data.id);
 
47
                graph.getNode(data.id).unhighlight();
 
48
        }
 
49
        
 
50
        graph.setFocus();
 
51
        }
 
52
 
 
53
}