Commit | Line | Data |
---|---|---|
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 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers; |
eb1bab5b BH |
13 | |
14 | import org.eclipse.core.commands.ExecutionEvent; | |
15 | import org.eclipse.core.commands.ExecutionException; | |
9315aeee | 16 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; |
eb1bab5b BH |
17 | |
18 | /** | |
eb1bab5b BH |
19 | * <p> |
20 | * Command handler implementation to connect to a target host. | |
21 | * </p> | |
11252342 | 22 | * |
dbd4432d | 23 | * @author Bernd Hufmann |
eb1bab5b BH |
24 | */ |
25 | public class ConnectHandler 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 { | |
35 | fTargetNode.connect(); | |
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.DISCONNECTED)); | |
48 | } finally { | |
49 | fLock.unlock(); | |
50 | } | |
51 | return isEnabled; | |
eb1bab5b BH |
52 | } |
53 | } |