Commit | Line | Data |
---|---|---|
eb1bab5b BH |
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 | **********************************************************************/ | |
31a6a4e4 | 12 | package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers; |
eb1bab5b BH |
13 | |
14 | import org.eclipse.core.commands.ExecutionEvent; | |
15 | import org.eclipse.core.commands.ExecutionException; | |
31a6a4e4 BH |
16 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent; |
17 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState; | |
eb1bab5b BH |
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) | |
31a6a4e4 | 32 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
eb1bab5b BH |
33 | */ |
34 | @Override | |
35 | public Object execute(ExecutionEvent event) throws ExecutionException { | |
36 | ITraceControlComponent root = fTargetNode.getParent(); | |
37 | fTargetNode.removeAllChildren(); | |
38 | root.removeChild(fTargetNode); | |
39 | return null; | |
40 | } | |
41 | ||
42 | /* | |
43 | * (non-Javadoc) | |
31a6a4e4 | 44 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#isEnabled() |
eb1bab5b BH |
45 | */ |
46 | @Override | |
47 | public boolean isEnabled() { | |
48 | return (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED)); | |
49 | } | |
50 | } |