analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / filter / FilterEditUtils.java
CommitLineData
ef906471 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 Kalray
ef906471
XR
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
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.views.filter;
ef906471
XR
14
15import org.eclipse.jface.util.LocalSelectionTransfer;
16import org.eclipse.jface.viewers.ISelection;
17import org.eclipse.jface.viewers.IStructuredSelection;
2bdf0193 18import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode;
ef906471
XR
19
20/**
21 * Utilities for cut/copy/paste/dnd in filter view
22 * @author Xavier Raynaud <xavier.raynaud@kalray.eu>
23 */
24class FilterEditUtils {
25
26 /**
27 * Gets the ITmfFilterTreeNode in LocalSelectionTransfer, if any
28 * @return a ITmfFilterTreeNode or <code>null</code>
29 */
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)) {
37 return null;
38 } else if (treeNodeToDrop != null) {
39 // should never occur, since tree has SWT.SINGLE style
40 return null;
41 } else {
42 treeNodeToDrop = (ITmfFilterTreeNode) data;
43 }
44 }
45 }
46 return treeNodeToDrop;
47 }
48}
This page took 0.074448 seconds and 5 git commands to generate.