Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / internal / lttng / ui / views / control / handlers / BaseNodeHandler.java
CommitLineData
eb1bab5b
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 12package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
eb1bab5b 13
eb1bab5b
BH
14import org.eclipse.jface.viewers.ISelection;
15import org.eclipse.jface.viewers.StructuredSelection;
31a6a4e4
BH
16import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
17import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
eb1bab5b 18import org.eclipse.ui.IWorkbenchPage;
eb1bab5b
BH
19
20/**
21 * <b><u>BaseNodeHandler</u></b>
22 * <p>
23 * Command handler implementation to delete a target host.
24 * </p>
25 */
498704b3 26abstract public class BaseNodeHandler extends BaseControlViewHandler {
eb1bab5b
BH
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
eb1bab5b
BH
36 // ------------------------------------------------------------------------
37 // Operations
38 // ------------------------------------------------------------------------
39 /*
40 * (non-Javadoc)
4775bcbf 41 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
eb1bab5b
BH
42 */
43 @Override
44 public boolean isEnabled() {
eb1bab5b 45
498704b3
BH
46 // Get workbench page for the Control View
47 IWorkbenchPage page = getWorkbenchPage();
eb1bab5b
BH
48 if (page == null) {
49 return false;
50 }
51
498704b3
BH
52 fTargetNode = null;
53
bbb3538a 54 // Check if the node component is selected
eb1bab5b
BH
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 }
498704b3
BH
62
63
eb1bab5b 64}
This page took 0.028193 seconds and 5 git commands to generate.