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
.jface
.util
.LocalSelectionTransfer
;
16 import org
.eclipse
.jface
.viewers
.ISelection
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
19 import org
.eclipse
.swt
.dnd
.DND
;
20 import org
.eclipse
.swt
.dnd
.DragSourceAdapter
;
21 import org
.eclipse
.swt
.dnd
.DragSourceEvent
;
24 * DragSourceListener for filter view
25 * @author Xavier Raynaud <xavier.raynaud@kalray.eu>
27 class FilterDragSourceAdapter
extends DragSourceAdapter
{
29 private FilterViewer fViewer
;
35 * the content of the FilterView
37 public FilterDragSourceAdapter(FilterViewer viewer
) {
39 this.fViewer
= viewer
;
43 public void dragStart(DragSourceEvent event
) {
44 ISelection s
= fViewer
.getTreeViewer().getSelection();
45 LocalSelectionTransfer
.getTransfer().setSelection(s
);
46 LocalSelectionTransfer
.getTransfer().setSelectionSetTime(event
.time
& 0xFFFFFFFFL
);
50 public void dragSetData(DragSourceEvent event
) {
51 event
.data
= LocalSelectionTransfer
.getTransfer().getSelection();
55 public void dragFinished(DragSourceEvent event
) {
56 if (event
.detail
== DND
.DROP_MOVE
) {
57 IStructuredSelection selection
= (IStructuredSelection
) LocalSelectionTransfer
.getTransfer().getSelection();
58 for (Object data
: selection
.toList()) {
59 if (data
instanceof ITmfFilterTreeNode
) {
60 ITmfFilterTreeNode e
= (ITmfFilterTreeNode
) data
;
66 LocalSelectionTransfer
.getTransfer().setSelection(null);
67 LocalSelectionTransfer
.getTransfer().setSelectionSetTime(0);