Skip to main content
summaryrefslogtreecommitdiffstats
blob: 023cf109e7d1e34d0a663cbd5c03bc88542281bf (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
75
76
77
78
79
80
81
/*******************************************************************************
 * 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.graphlisteners;

import org.eclipse.linuxtools.callgraph.CallgraphView;
import org.eclipse.linuxtools.callgraph.StapGraph;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;

/**
 * StapGraph key listener
 */
public class StapGraphKeyListener implements KeyListener {
	private CallgraphView callgraphView;
	
	public StapGraphKeyListener(StapGraph g) {
		callgraphView = g.getCallgraphView();
	}
	
	@Override
	public void keyPressed(KeyEvent e) {

	}

	@Override
	public void keyReleased(KeyEvent e) {
		if (e.stateMask != SWT.SHIFT) {
			return;
		}
		
		//TODO: Use accelerator in menu actions instead of this hard-coded stuff
		if (e.character == 'R') {
			callgraphView.getView_refresh().run();
//		}else if (e.character == '1') {
//			graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_SLOW);
//		}else if (e.character == '2') {
//			graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_FASTER);
//		}else if (e.character == '3') {
//			graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_FASTEST);
//		}else if (e.character == 'k') {
//			Shell sh = graph.getShell();
//			graph.dispose();
//			sh.close();
//		}else if (e.character == 'n') {
//			int id = graph.getNextMarkedNode();
//			graph.draw(id, 0, 0);
//			graph.getTreeViewer().expandToLevel(graph.getData(id), 0);
//		}else if (e.character == 'p') {
//			int id = graph.getPreviousMarkedNode();
//			graph.draw(id, 0, 0);
//			graph.getTreeViewer().expandToLevel(graph.getData(id), 0);
//		}else if (e.character == 'd') {
//			graph.deleteAll(-1);
//		}else if (e.character == 'T') {
//			graph.deleteAll(graph.getRootVisibleNode());
//			graph.draw(StapGraph.CONSTANT_DRAWMODE_TREE, graph.getAnimationMode(), 
//					graph.getRootVisibleNode());
//			graph.currentPositionInLevel.clear();
		}else if (e.character == 'C') {
			callgraphView.getMode_collapsednodes().run();
		} else if (e.character == 'N') {
			callgraphView.getGoto_next().run();
		} else if (e.character == 'P') {
			callgraphView.getGoto_previous().run();
		} else if (e.character == 'L') {
			callgraphView.getGoto_last().run();
		} else if (e.character == 'D') {
			callgraphView.getPlay().run();
		}
	}
	
};

Back to the top