1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.handlers
;
14 import org
.eclipse
.jface
.viewers
.ISelection
;
15 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
16 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
17 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
18 import org
.eclipse
.ui
.IWorkbenchPage
;
22 * Command handler implementation to delete a target host.
25 * @author Bernd Hufmann
27 public abstract class BaseNodeHandler
extends BaseControlViewHandler
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 * The target node component the command is to be executed on.
35 protected TargetNodeComponent fTargetNode
= null;
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
42 public boolean isEnabled() {
44 // Get workbench page for the Control View
45 IWorkbenchPage page
= getWorkbenchPage();
50 TargetNodeComponent node
= null;
51 // Check if the node component is selected
52 ISelection selection
= page
.getSelection(ControlView
.ID
);
53 if (selection
instanceof StructuredSelection
) {
54 Object element
= ((StructuredSelection
) selection
).getFirstElement();
55 node
= (element
instanceof TargetNodeComponent
) ?
(TargetNodeComponent
) element
: null;
57 boolean isEnabled
= node
!= null;