diff options
author | Andrew Overholt | 2011-02-28 03:14:58 +0000 |
---|---|---|
committer | Andrew Overholt | 2011-02-28 03:17:09 +0000 |
commit | 429177f48392d531193049d4387bda901f84245e (patch) | |
tree | 3d58766bfbdd1392c1173cba2211d9c1e6d77faa /lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/DeleteTraceHandler.java | |
parent | 3ebedfbfca945e023c292dbde119602f1e1f160c (diff) | |
parent | cff63467571db17c972d4ea9ccbe0d9e2c224f27 (diff) | |
download | org.eclipse.linuxtools-429177f48392d531193049d4387bda901f84245e.tar.gz org.eclipse.linuxtools-429177f48392d531193049d4387bda901f84245e.tar.xz org.eclipse.linuxtools-429177f48392d531193049d4387bda901f84245e.zip |
Merge lttng 0.6.0
Diffstat (limited to 'lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/DeleteTraceHandler.java')
-rw-r--r-- | lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/DeleteTraceHandler.java | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/DeleteTraceHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/DeleteTraceHandler.java new file mode 100644 index 0000000000..beb0d0595b --- /dev/null +++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/DeleteTraceHandler.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Francois Chouinard - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.lttng.ui.views.project.handlers; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView; +import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * <b><u>DeleteTraceHandler</u></b> + * <p> + * TODO: Implement me. Please. + */ +public class DeleteTraceHandler implements IHandler { + + private LTTngTraceNode fTrace = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Check if a trace is selected + IWorkbenchPage page = window.getActivePage(); + if (!(page.getActivePart() instanceof ProjectView)) + return false; + + // Check if a trace is selected + ISelection selection = page.getSelection(ProjectView.ID); + if (selection instanceof StructuredSelection) { + Object element = ((StructuredSelection) selection).getFirstElement(); + fTrace = (element instanceof LTTngTraceNode) ? (LTTngTraceNode) element : null; + } + + return (fTrace != null); + } + + // Handled if we are in the ProjectView + public boolean isHandled() { + return true; + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + public Object execute(ExecutionEvent event) throws ExecutionException { + + IFolder folder = fTrace.getFolder(); + ILTTngProjectTreeNode parent = fTrace.getParent(); + try { + parent.removeChild(fTrace); + parent.refresh(); + folder.delete(true, true, null); + } catch (CoreException e) { + e.printStackTrace(); + } + + return null; + } + + public void dispose() { + // TODO Auto-generated method stub + } + + // ------------------------------------------------------------------------ + // IHandlerListener + // ------------------------------------------------------------------------ + + public void addHandlerListener(IHandlerListener handlerListener) { + // TODO Auto-generated method stub + } + + public void removeHandlerListener(IHandlerListener handlerListener) { + // TODO Auto-generated method stub + } + +} |