gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / handlers / DeleteHandler.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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.linuxtools.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.linuxtools.internal.lttng2.control.core.model.TargetNodeState;
17 import org.eclipse.linuxtools.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 fTargetNode.deregister();
39 root.removeChild(fTargetNode);
40 } finally {
41 fLock.unlock();
42 }
43 return null;
44 }
45
46 @Override
47 public boolean isEnabled() {
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;
56 }
57 }
This page took 0.047758 seconds and 5 git commands to generate.