ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / handlers / DeleteHandler.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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 **********************************************************************/
12 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
13
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
17 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
18
19 /**
20 * <p>
21 * Command handler implementation to delete a target host.
22 * </p>
23 *
24 * @author Bernd Hufmann
25 */
26 public class DeleteHandler extends BaseNodeHandler {
27
28 // ------------------------------------------------------------------------
29 // Operations
30 // ------------------------------------------------------------------------
31
32 @Override
33 public Object execute(ExecutionEvent event) throws ExecutionException {
34 fLock.lock();
35 try {
36 ITraceControlComponent root = fTargetNode.getParent();
37 fTargetNode.removeAllChildren();
38 root.removeChild(fTargetNode);
39 } finally {
40 fLock.unlock();
41 }
42 return null;
43 }
44
45 @Override
46 public boolean isEnabled() {
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;
55 }
56 }
This page took 0.036306 seconds and 5 git commands to generate.