Project

General

Profile

Download (1.51 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.definedterm.e4;
10

    
11
import java.util.List;
12

    
13
import org.eclipse.jface.util.LocalSelectionTransfer;
14
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.swt.dnd.DragSourceAdapter;
17
import org.eclipse.swt.dnd.DragSourceEvent;
18

    
19
import eu.etaxonomy.cdm.persistence.dto.TermDto;
20

    
21
/**
22
 *
23
 * @author pplitzner
24
 * @since Aug 22, 2017
25
 *
26
 */
27
public class DefinedTermDragListenerE4 extends DragSourceAdapter {
28

    
29
	private Viewer viewer;
30

    
31
	public DefinedTermDragListenerE4(Viewer viewer) {
32
		this.viewer = viewer;
33
	}
34

    
35
	@Override
36
	public void dragStart(DragSourceEvent event) {
37
	    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
38
	    List list = selection.toList();
39
	    for (Object object : list) {
40
            if(!(object instanceof TermDto)){
41
                event.doit = false;
42
                return;
43
            }
44
        }
45
		event.doit = true;
46
	}
47

    
48
	@Override
49
	public void dragSetData(DragSourceEvent event) {
50
	    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
51
        if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
52
            LocalSelectionTransfer.getTransfer().setSelection(selection);
53
        }
54

    
55
	}
56

    
57
}
(1-1/4)