Fix for bug 382684 (connection re-use)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / DisconnectHandler.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
BH
13
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
9315aeee 16import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
eb1bab5b
BH
17
18/**
eb1bab5b
BH
19 * <p>
20 * Command handler implementation to disconnect from a target host.
21 * </p>
dbd4432d
BH
22 *
23 * @author Bernd Hufmann
eb1bab5b
BH
24 */
25public class DisconnectHandler extends BaseNodeHandler {
26
27 // ------------------------------------------------------------------------
28 // Operations
29 // ------------------------------------------------------------------------
30
31 /*
32 * (non-Javadoc)
115b4a01 33 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
eb1bab5b
BH
34 */
35 @Override
36 public Object execute(ExecutionEvent event) throws ExecutionException {
c56972bb
BH
37 fLock.lock();
38 try {
c56972bb 39 fTargetNode.disconnect();
c56972bb
BH
40 } finally {
41 fLock.unlock();
42 }
eb1bab5b
BH
43 return null;
44 }
45
46 /*
47 * (non-Javadoc)
115b4a01 48 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#isEnabled()
eb1bab5b
BH
49 */
50 @Override
51 public boolean isEnabled() {
c56972bb
BH
52 boolean isEnabled = false;
53 fLock.lock();
54 try {
55 isEnabled = super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
56 } finally {
57 fLock.unlock();
58 }
59 return isEnabled;
eb1bab5b
BH
60 }
61}
This page took 0.031441 seconds and 5 git commands to generate.