Commit | Line | Data |
---|---|---|
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 | **********************************************************************/ | |
31a6a4e4 | 12 | package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers; |
498704b3 BH |
13 | |
14 | import org.eclipse.core.commands.AbstractHandler; | |
31a6a4e4 | 15 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView; |
498704b3 BH |
16 | import org.eclipse.ui.IWorkbenchPage; |
17 | import org.eclipse.ui.IWorkbenchPart; | |
18 | import org.eclipse.ui.IWorkbenchWindow; | |
19 | import 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 | */ | |
27 | abstract 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 | } |