1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.handlers
;
15 import org
.eclipse
.core
.commands
.ExecutionEvent
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.IHandler
;
18 import org
.eclipse
.core
.commands
.IHandlerListener
;
19 import org
.eclipse
.core
.resources
.IFolder
;
20 import org
.eclipse
.core
.runtime
.CoreException
;
21 import org
.eclipse
.jface
.viewers
.ISelection
;
22 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.ProjectView
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
.ILTTngProjectTreeNode
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
.LTTngTraceNode
;
26 import org
.eclipse
.ui
.IWorkbenchPage
;
27 import org
.eclipse
.ui
.IWorkbenchWindow
;
28 import org
.eclipse
.ui
.PlatformUI
;
31 * <b><u>DeleteTraceHandler</u></b>
33 * TODO: Implement me. Please.
35 public class DeleteTraceHandler
implements IHandler
{
37 private LTTngTraceNode fTrace
= null;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 public boolean isEnabled() {
46 // Check if we are closing down
47 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
51 // Check if a trace is selected
52 IWorkbenchPage page
= window
.getActivePage();
53 if (!(page
.getActivePart() instanceof ProjectView
))
56 // Check if a trace is selected
57 ISelection selection
= page
.getSelection(ProjectView
.ID
);
58 if (selection
instanceof StructuredSelection
) {
59 Object element
= ((StructuredSelection
) selection
).getFirstElement();
60 fTrace
= (element
instanceof LTTngTraceNode
) ?
(LTTngTraceNode
) element
: null;
63 return (fTrace
!= null);
66 // Handled if we are in the ProjectView
68 public boolean isHandled() {
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
77 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
79 IFolder folder
= fTrace
.getFolder();
80 ILTTngProjectTreeNode parent
= fTrace
.getParent();
82 parent
.removeChild(fTrace
);
84 folder
.delete(true, true, null);
85 } catch (CoreException e
) {
93 public void dispose() {
94 // TODO Auto-generated method stub
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
102 public void addHandlerListener(IHandlerListener handlerListener
) {
103 // TODO Auto-generated method stub
107 public void removeHandlerListener(IHandlerListener handlerListener
) {
108 // TODO Auto-generated method stub