gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / handlers / DisconnectHandler.java
CommitLineData
eb1bab5b 1/**********************************************************************
11252342
AM
2 * Copyright (c) 2012, 2013 Ericsson
3 *
eb1bab5b
BH
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
11252342
AM
8 *
9 * Contributors:
eb1bab5b
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
8e8c0226 12package org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers;
eb1bab5b
BH
13
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
8e8c0226 16import org.eclipse.linuxtools.internal.lttng2.control.core.model.TargetNodeState;
eb1bab5b
BH
17
18/**
eb1bab5b
BH
19 * <p>
20 * Command handler implementation to disconnect from a target host.
21 * </p>
11252342 22 *
dbd4432d 23 * @author Bernd Hufmann
eb1bab5b
BH
24 */
25public class DisconnectHandler extends BaseNodeHandler {
26
27 // ------------------------------------------------------------------------
28 // Operations
29 // ------------------------------------------------------------------------
30
eb1bab5b
BH
31 @Override
32 public Object execute(ExecutionEvent event) throws ExecutionException {
c56972bb
BH
33 fLock.lock();
34 try {
c56972bb 35 fTargetNode.disconnect();
c56972bb
BH
36 } finally {
37 fLock.unlock();
38 }
eb1bab5b
BH
39 return null;
40 }
41
eb1bab5b
BH
42 @Override
43 public boolean isEnabled() {
c56972bb
BH
44 boolean isEnabled = false;
45 fLock.lock();
46 try {
47 isEnabled = super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
48 } finally {
49 fLock.unlock();
50 }
51 return isEnabled;
eb1bab5b
BH
52 }
53}
This page took 0.05227 seconds and 5 git commands to generate.