Add further support for enabling kernel events
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / handlers / BaseNodeHandler.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.lttng.ui.views.control.handlers;
13
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.jface.viewers.StructuredSelection;
16 import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
17 import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
18 import org.eclipse.ui.IWorkbenchPage;
19
20 /**
21 * <b><u>BaseNodeHandler</u></b>
22 * <p>
23 * Command handler implementation to delete a target host.
24 * </p>
25 */
26 abstract public class BaseNodeHandler extends BaseControlViewHandler {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31 /**
32 * The target node component the command is to be executed on.
33 */
34 protected TargetNodeComponent fTargetNode = null;
35
36 // ------------------------------------------------------------------------
37 // Operations
38 // ------------------------------------------------------------------------
39 /*
40 * (non-Javadoc)
41 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
42 */
43 @Override
44 public boolean isEnabled() {
45
46 // Get workbench page for the Control View
47 IWorkbenchPage page = getWorkbenchPage();
48 if (page == null) {
49 return false;
50 }
51
52 fTargetNode = null;
53
54 // Check if the node component is selected
55 ISelection selection = page.getSelection(ControlView.ID);
56 if (selection instanceof StructuredSelection) {
57 Object element = ((StructuredSelection) selection).getFirstElement();
58 fTargetNode = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
59 }
60 return fTargetNode != null;
61 }
62
63
64 }
This page took 0.030999 seconds and 5 git commands to generate.