Improve package tangle index for LTTng 2.0 control design
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / DeleteHandler.java
1 /**********************************************************************
2 * Copyright (c) 2012 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.ui.views.control.handlers;
13
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
17 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
18
19 /**
20 * <b><u>DeleteHandler</u></b>
21 * <p>
22 * Command handler implementation to delete a target host.
23 * </p>
24 */
25 public class DeleteHandler extends BaseNodeHandler {
26
27 // ------------------------------------------------------------------------
28 // Operations
29 // ------------------------------------------------------------------------
30 /*
31 * (non-Javadoc)
32 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
33 */
34 @Override
35 public Object execute(ExecutionEvent event) throws ExecutionException {
36 fLock.lock();
37 try {
38 ITraceControlComponent root = fTargetNode.getParent();
39 fTargetNode.removeAllChildren();
40 fTargetNode.deregister();
41 root.removeChild(fTargetNode);
42 } finally {
43 fLock.unlock();
44 }
45 return null;
46 }
47
48 /*
49 * (non-Javadoc)
50 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#isEnabled()
51 */
52 @Override
53 public boolean isEnabled() {
54 boolean isEnabled = false;
55 fLock.lock();
56 try {
57 isEnabled = (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
58 } finally {
59 fLock.unlock();
60 }
61 return isEnabled;
62 }
63 }
This page took 0.033859 seconds and 6 git commands to generate.