Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2012, 2014 Ericsson |
11252342 | 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 | **********************************************************************/ | |
9bc60be7 | 12 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers; |
eb1bab5b BH |
13 | |
14 | import org.eclipse.core.commands.ExecutionEvent; | |
15 | import org.eclipse.core.commands.ExecutionException; | |
9bc60be7 AM |
16 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState; |
17 | import org.eclipse.tracecompass.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(); | |
38 | root.removeChild(fTargetNode); | |
39 | } finally { | |
40 | fLock.unlock(); | |
41 | } | |
eb1bab5b BH |
42 | return null; |
43 | } | |
44 | ||
eb1bab5b BH |
45 | @Override |
46 | public boolean isEnabled() { | |
c56972bb BH |
47 | boolean isEnabled = false; |
48 | fLock.lock(); | |
49 | try { | |
50 | isEnabled = (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED)); | |
51 | } finally { | |
52 | fLock.unlock(); | |
53 | } | |
54 | return isEnabled; | |
eb1bab5b BH |
55 | } |
56 | } |