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 | **********************************************************************/ | |
8e8c0226 | 12 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers; |
eb1bab5b BH |
13 | |
14 | import org.eclipse.core.commands.ExecutionEvent; | |
15 | import org.eclipse.core.commands.ExecutionException; | |
8e8c0226 AM |
16 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TargetNodeState; |
17 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
eb1bab5b BH |
18 | |
19 | /** | |
eb1bab5b BH |
20 | * <p> |
21 | * Command handler implementation to delete a target host. | |
22 | * </p> | |
11252342 | 23 | * |
dbd4432d | 24 | * @author Bernd Hufmann |
eb1bab5b BH |
25 | */ |
26 | public class DeleteHandler extends BaseNodeHandler { | |
27 | ||
28 | // ------------------------------------------------------------------------ | |
29 | // Operations | |
30 | // ------------------------------------------------------------------------ | |
11252342 | 31 | |
eb1bab5b BH |
32 | @Override |
33 | public Object execute(ExecutionEvent event) throws ExecutionException { | |
c56972bb BH |
34 | fLock.lock(); |
35 | try { | |
36 | ITraceControlComponent root = fTargetNode.getParent(); | |
37 | fTargetNode.removeAllChildren(); | |
8577ed1e | 38 | fTargetNode.deregister(); |
c56972bb BH |
39 | root.removeChild(fTargetNode); |
40 | } finally { | |
41 | fLock.unlock(); | |
42 | } | |
eb1bab5b BH |
43 | return null; |
44 | } | |
45 | ||
eb1bab5b BH |
46 | @Override |
47 | public boolean isEnabled() { | |
c56972bb BH |
48 | boolean isEnabled = false; |
49 | fLock.lock(); | |
50 | try { | |
51 | isEnabled = (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED)); | |
52 | } finally { | |
53 | fLock.unlock(); | |
54 | } | |
55 | return isEnabled; | |
eb1bab5b BH |
56 | } |
57 | } |