Add support for importing traces to tracing project
[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/**
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
c56972bb 52 TargetNodeComponent node = null;
bbb3538a 53 // Check if the node component is selected
eb1bab5b
BH
54 ISelection selection = page.getSelection(ControlView.ID);
55 if (selection instanceof StructuredSelection) {
56 Object element = ((StructuredSelection) selection).getFirstElement();
c56972bb 57 node = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
eb1bab5b 58 }
c56972bb
BH
59 boolean isEnabled = node != null;
60 fLock.lock();
61 try {
62 if (isEnabled) {
63 fTargetNode = node;
64 }
65 } finally {
66 fLock.unlock();
67 }
68 return isEnabled;
eb1bab5b 69 }
498704b3
BH
70
71
eb1bab5b 72}
This page took 0.027901 seconds and 5 git commands to generate.