1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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
.tracecompass
.tmf
.ui
.views
.filter
;
15 import org
.eclipse
.jface
.util
.LocalSelectionTransfer
;
16 import org
.eclipse
.jface
.viewers
.ISelection
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
21 * Utilities for cut/copy/paste/dnd in filter view
22 * @author Xavier Raynaud <xavier.raynaud@kalray.eu>
24 class FilterEditUtils
{
27 * Gets the ITmfFilterTreeNode in LocalSelectionTransfer, if any
28 * @return a ITmfFilterTreeNode or <code>null</code>
30 public static ITmfFilterTreeNode
getTransferredTreeNode() {
31 ITmfFilterTreeNode treeNodeToDrop
= null;
32 ISelection sel
= LocalSelectionTransfer
.getTransfer().getSelection();
33 if (sel
instanceof IStructuredSelection
) {
34 IStructuredSelection selection
= (IStructuredSelection
) sel
;
35 for (Object data
: selection
.toList()) {
36 if (!(data
instanceof ITmfFilterTreeNode
)) {
38 } else if (treeNodeToDrop
!= null) {
39 // should never occur, since tree has SWT.SINGLE style
42 treeNodeToDrop
= (ITmfFilterTreeNode
) data
;
46 return treeNodeToDrop
;