Commit | Line | Data |
---|---|---|
ef906471 XR |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 Kalray | |
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 | * Xavier Raynaud - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.ui.views.filter; | |
14 | ||
15 | import org.eclipse.jface.viewers.ISelection; | |
16 | import org.eclipse.jface.viewers.IStructuredSelection; | |
17 | import org.eclipse.jface.viewers.StructuredSelection; | |
18 | import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode; | |
19 | ||
20 | /** | |
21 | * Handler for cut command in filter view | |
22 | * @author Xavier Raynaud <xavier.raynaud@kalray.eu> | |
c4767854 | 23 | * @since 3.0 |
ef906471 XR |
24 | */ |
25 | public class CutHandler extends CopyHandler { | |
26 | ||
27 | @Override | |
28 | protected ISelection getSelection(FilterView tcv) { | |
29 | ISelection sel = super.getSelection(tcv); | |
30 | if (sel instanceof IStructuredSelection) { | |
31 | IStructuredSelection selection = (IStructuredSelection) sel; | |
32 | Object o = selection.getFirstElement(); | |
33 | if (o instanceof ITmfFilterTreeNode) { | |
34 | ITmfFilterTreeNode node = (ITmfFilterTreeNode) o; | |
35 | node = node.remove(); | |
36 | tcv.refresh(); | |
37 | return new StructuredSelection(node); | |
38 | } | |
39 | } | |
40 | return sel; | |
41 | } | |
42 | ||
43 | } |