Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / BaseControlViewHandler.java
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 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
13
14 import java.util.concurrent.locks.ReentrantLock;
15
16 import org.eclipse.core.commands.AbstractHandler;
17 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
18 import org.eclipse.ui.IWorkbenchPage;
19 import org.eclipse.ui.IWorkbenchPart;
20 import org.eclipse.ui.IWorkbenchWindow;
21 import org.eclipse.ui.PlatformUI;
22
23 /**
24 * <b><u>BaseControlViewHandler</u></b>
25 * <p>
26 * Abstract Command handler implementation for all control view handlers.
27 * </p>
28 */
29 abstract public class BaseControlViewHandler extends AbstractHandler {
30
31 // ------------------------------------------------------------------------
32 // Attributes
33 // ------------------------------------------------------------------------
34 /**
35 * The synchronization lock.
36 */
37 protected ReentrantLock fLock = new ReentrantLock();
38
39 // ------------------------------------------------------------------------
40 // Operations
41 // ------------------------------------------------------------------------
42 /**
43 * @return returns the workbench page for the Control View
44 */
45 protected IWorkbenchPage getWorkbenchPage() {
46 // Check if we are closing down
47 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
48 if (window == null) {
49 return null;
50 }
51
52 // Check if we are in the Project View
53 IWorkbenchPage page = window.getActivePage();
54 if (page == null) {
55 return null;
56 }
57
58 IWorkbenchPart part = page.getActivePart();
59 if (!(part instanceof ControlView)) {
60 return null;
61 }
62 return page;
63 }
64 }
This page took 0.03256 seconds and 6 git commands to generate.