blob: 3f09e74305c4645608c57dd3b5be3530e7647f11 (
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
82
83
84
85
86
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation.
* 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:
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
*******************************************************************************/
package org.eclipse.linuxtools.internal.systemtap.ui.ide.views;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.hidden.ProbeAliasAction;
import org.eclipse.linuxtools.systemtap.ui.ide.structures.TapsetLibrary;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchActionConstants;
/**
* The Probe Alias Browser module of the SystemTap GUI. This class provides a list of all probe aliases
* defined in the tapset (both the standard, and user-specified tapsets), and allows the user to insert
* template probes into an editor.
* @author Henry Hughes
* @author Ryan Morse
*/
public class ProbeAliasBrowserView extends BrowserView {
public static final String ID = "org.eclipse.linuxtools.internal.systemtap.ui.ide.views.ProbeAliasBrowserView"; //$NON-NLS-1$
private ProbeAliasAction doubleClickAction;
private Menu menu;
/**
* Creates the UI on the given <code>Composite</code>
*/
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
TapsetLibrary.init();
TapsetLibrary.addListener(new ViewUpdater());
refresh();
makeActions();
}
/**
* Refreshes the list of probe aliases in the viewer.
*/
@Override
public void refresh() {
super.viewer.setInput(TapsetLibrary.getProbes());
}
/**
* Wires up all of the actions for this browser, such as double and right click handlers.
*/
private void makeActions() {
doubleClickAction = new ProbeAliasAction(getSite().getWorkbenchWindow(), this);
viewer.addDoubleClickListener(doubleClickAction);
Control control = this.viewer.getControl();
MenuManager manager = new MenuManager("probePopup"); //$NON-NLS-1$
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
Menu menu = manager.createContextMenu(control);
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(manager, viewer);
}
@Override
public void dispose() {
super.dispose();
if(null != viewer) {
viewer.removeDoubleClickListener(doubleClickAction);
}
if(null != doubleClickAction) {
doubleClickAction.dispose();
}
doubleClickAction = null;
if(null != menu) {
menu.dispose();
}
menu = null;
}
}
|