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

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.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) 2006 IBM Corporation.
 
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
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
 
10
 *******************************************************************************/
 
11
 
 
12
package org.eclipse.linuxtools.internal.systemtap.ui.ide.views;
 
13
 
 
14
import org.eclipse.jface.action.MenuManager;
 
15
import org.eclipse.jface.action.Separator;
 
16
import org.eclipse.jface.viewers.DoubleClickEvent;
 
17
import org.eclipse.jface.viewers.IDoubleClickListener;
 
18
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.hidden.ProbeAliasAction;
 
19
import org.eclipse.linuxtools.systemtap.ui.ide.structures.TapsetLibrary;
 
20
import org.eclipse.linuxtools.systemtap.ui.logging.LogManager;
 
21
import org.eclipse.swt.widgets.Composite;
 
22
import org.eclipse.swt.widgets.Control;
 
23
import org.eclipse.swt.widgets.Menu;
 
24
import org.eclipse.ui.IWorkbenchActionConstants;
 
25
 
 
26
 
 
27
/**
 
28
 * The Probe Alias Browser module of the SystemTap GUI. This class provides a list of all probe aliases
 
29
 * defined in the tapset (both the standard, and user-specified tapsets), and allows the user to insert
 
30
 * template probes into an editor.
 
31
 * @author Henry Hughes
 
32
 * @author Ryan Morse
 
33
 */
 
34
public class ProbeAliasBrowserView extends BrowserView {
 
35
        public ProbeAliasBrowserView() {
 
36
                super();
 
37
                LogManager.logInfo("Initializing", this);
 
38
        }
 
39
        
 
40
        /**
 
41
         * Creates the UI on the given <code>Composite</code>
 
42
         */
 
43
        public void createPartControl(Composite parent) {
 
44
                LogManager.logDebug("Start createPartControl: parent-" + parent, this);
 
45
                super.createPartControl(parent);
 
46
                TapsetLibrary.init();
 
47
                TapsetLibrary.addListener(new ViewUpdater());
 
48
                refresh();
 
49
                makeActions();
 
50
                LogManager.logDebug("End createPartControl:", this);
 
51
        }
 
52
        
 
53
        /**
 
54
         * Refreshes the list of probe aliases in the viewer.
 
55
         */
 
56
        public void refresh() {
 
57
                LogManager.logDebug("Start refresh:", this);
 
58
                super.viewer.setInput(TapsetLibrary.getProbes());
 
59
                LogManager.logDebug("End refresh:", this);
 
60
        }
 
61
        
 
62
        /**
 
63
         * Wires up all of the actions for this browser, such as double and right click handlers.
 
64
         */
 
65
        private void makeActions() {
 
66
                LogManager.logDebug("Start makeActions:", this);
 
67
                doubleClickAction = new ProbeAliasAction(getSite().getWorkbenchWindow(), this);
 
68
                dblClickListener = new IDoubleClickListener() {
 
69
                        public void doubleClick(DoubleClickEvent event) {
 
70
                                LogManager.logDebug("doubleClick fired", this);
 
71
                                doubleClickAction.run();
 
72
                        }
 
73
                };
 
74
                viewer.addDoubleClickListener(dblClickListener);
 
75
                Control control = this.viewer.getControl();
 
76
                MenuManager manager = new MenuManager("probePopup");
 
77
 
 
78
                manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
 
79
                Menu menu = manager.createContextMenu(control);
 
80
                viewer.getControl().setMenu(menu);
 
81
                getSite().registerContextMenu(manager, viewer);
 
82
                LogManager.logDebug("End makeActions:", this);
 
83
        }
 
84
        
 
85
        public void dispose() {
 
86
                LogManager.logInfo("Disposing", this);
 
87
                super.dispose();
 
88
                if(null != doubleClickAction)
 
89
                        doubleClickAction.dispose();
 
90
                doubleClickAction = null;
 
91
                if(null != viewer)
 
92
                        viewer.removeDoubleClickListener(dblClickListener);
 
93
                dblClickListener = null;
 
94
                if(null != menu)
 
95
                        menu.dispose();
 
96
                menu = null;
 
97
        }
 
98
 
 
99
        public static final String ID = "org.eclipse.linuxtools.internal.systemtap.ui.ide.views.ProbeAliasBrowserView";
 
100
        private ProbeAliasAction doubleClickAction;
 
101
        private IDoubleClickListener dblClickListener;
 
102
        private Menu menu;
 
103
}