Fix NLS-related Javadoc warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / 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 **********************************************************************/
115b4a01 12package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
eb1bab5b 13
eb1bab5b
BH
14import org.eclipse.jface.viewers.ISelection;
15import org.eclipse.jface.viewers.StructuredSelection;
115b4a01
BH
16import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
17import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
eb1bab5b 18import org.eclipse.ui.IWorkbenchPage;
eb1bab5b
BH
19
20/**
eb1bab5b
BH
21 * <p>
22 * Command handler implementation to delete a target host.
23 * </p>
dbd4432d
BH
24 *
25 * @author Bernd Hufmann
eb1bab5b 26 */
498704b3 27abstract public class BaseNodeHandler extends BaseControlViewHandler {
eb1bab5b
BH
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32 /**
33 * The target node component the command is to be executed on.
34 */
35 protected TargetNodeComponent fTargetNode = null;
36
eb1bab5b
BH
37 // ------------------------------------------------------------------------
38 // Operations
39 // ------------------------------------------------------------------------
40 /*
41 * (non-Javadoc)
4775bcbf 42 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
eb1bab5b
BH
43 */
44 @Override
45 public boolean isEnabled() {
eb1bab5b 46
498704b3
BH
47 // Get workbench page for the Control View
48 IWorkbenchPage page = getWorkbenchPage();
eb1bab5b
BH
49 if (page == null) {
50 return false;
51 }
52
c56972bb 53 TargetNodeComponent node = null;
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();
c56972bb 58 node = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
eb1bab5b 59 }
c56972bb
BH
60 boolean isEnabled = node != null;
61 fLock.lock();
62 try {
63 if (isEnabled) {
64 fTargetNode = node;
65 }
66 } finally {
67 fLock.unlock();
68 }
69 return isEnabled;
eb1bab5b 70 }
498704b3
BH
71
72
eb1bab5b 73}
This page took 0.035896 seconds and 5 git commands to generate.