Add further support for enabling kernel events
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / handlers / BaseControlViewHandler.java
CommitLineData
498704b3
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
13
14import org.eclipse.core.commands.AbstractHandler;
15import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
16import org.eclipse.ui.IWorkbenchPage;
17import org.eclipse.ui.IWorkbenchPart;
18import org.eclipse.ui.IWorkbenchWindow;
19import org.eclipse.ui.PlatformUI;
20
21/**
22 * <b><u>BaseControlViewHandler</u></b>
23 * <p>
24 * Abstract Command handler implementation for all control view handlers.
25 * </p>
26 */
27abstract public class BaseControlViewHandler extends AbstractHandler {
28
29 // ------------------------------------------------------------------------
30 // Operations
31 // ------------------------------------------------------------------------
32 /**
33 * @return returns the workbench page for the Control View
34 */
35 protected IWorkbenchPage getWorkbenchPage() {
36 // Check if we are closing down
37 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
38 if (window == null) {
39 return null;
40 }
41
42 // Check if we are in the Project View
43 IWorkbenchPage page = window.getActivePage();
44 if (page == null) {
45 return null;
46 }
47
48 IWorkbenchPart part = page.getActivePart();
49 if (!(part instanceof ControlView)) {
50 return null;
51 }
52 return page;
53 }
54}
This page took 0.030922 seconds and 5 git commands to generate.