1 /**********************************************************************
2 * Copyright (c) 2012 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
.linuxtools
.internal
.lttng
.ui
.views
.control
.handlers
;
14 import org
.eclipse
.jface
.viewers
.ISelection
;
15 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
16 import org
.eclipse
.linuxtools
.internal
.lttng
.ui
.views
.control
.ControlView
;
17 import org
.eclipse
.linuxtools
.internal
.lttng
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
18 import org
.eclipse
.ui
.IWorkbenchPage
;
21 * <b><u>BaseNodeHandler</u></b>
23 * Command handler implementation to delete a target host.
26 abstract public class BaseNodeHandler
extends BaseControlViewHandler
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 * The target node component the command is to be executed on.
34 protected TargetNodeComponent fTargetNode
= null;
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
41 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
44 public boolean isEnabled() {
46 // Get workbench page for the Control View
47 IWorkbenchPage page
= getWorkbenchPage();
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;
60 return fTargetNode
!= null;