1 /*******************************************************************************
2 * Copyright (c) 2013 Kalray
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 * Xavier Raynaud - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.viewers
.ISelection
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
21 import org
.eclipse
.ui
.IWorkbenchPage
;
22 import org
.eclipse
.ui
.IWorkbenchPart
;
23 import org
.eclipse
.ui
.IWorkbenchWindow
;
24 import org
.eclipse
.ui
.PlatformUI
;
27 * Handler for delete command in filter view
28 * @author Xavier Raynaud <xavier.raynaud@kalray.eu>
31 public class DeleteHandler
extends AbstractHandler
{
34 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
35 // Check if we are closing down
36 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
40 IWorkbenchPage page
= window
.getActivePage();
41 FilterView part
= (FilterView
) page
.getActivePart();
42 ISelection sel
= part
.getViewSite().getSelectionProvider().getSelection();
43 if (sel
instanceof IStructuredSelection
) {
44 IStructuredSelection selection
= (IStructuredSelection
) sel
;
45 Object o
= selection
.getFirstElement();
46 if (o
instanceof ITmfFilterTreeNode
) {
47 ITmfFilterTreeNode node
= (ITmfFilterTreeNode
) o
;
56 public boolean isEnabled() {
57 // Check if we are closing down
58 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
64 IWorkbenchPage page
= window
.getActivePage();
65 IWorkbenchPart part
= page
.getActivePart();
66 if (part
instanceof FilterView
) {
67 FilterView tcv
= (FilterView
) part
;
68 ISelection selection
= tcv
.getSite().getSelectionProvider().getSelection();
69 if (!selection
.isEmpty()) {