Project

General

Profile

Revision 63d2e106

ID63d2e1069d54cdf3c2d9cabf5eb7ed7ec424e11b
Parent 87f1ced1
Child bfbad836

Added by Patrick Plitzner almost 4 years ago

ref #6779 Allow dragging of features into authority editor

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/dnd/CdmAuthorityTableDropTargetListener.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.dnd;
10 10

  
11
import java.util.Collection;
11 12
import java.util.Iterator;
12 13

  
13
import org.eclipse.jface.util.LocalSelectionTransfer;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.TreeSelection;
14
import org.eclipse.jface.viewers.IStructuredSelection;
16 15
import org.eclipse.swt.dnd.DropTargetEvent;
17 16
import org.eclipse.swt.dnd.DropTargetListener;
18 17

  
......
54 53

  
55 54
	@Override
56 55
	public void drop(DropTargetEvent dtevent) {
57
	    ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
58
        if (selection instanceof TreeSelection) {
59

  
60
            Iterator<?> selectionIterator = ((TreeSelection) selection).iterator();
56
	    Object data = dtevent.data;
57
	    if (data instanceof IStructuredSelection) {
58
	        Iterator<?> selectionIterator = ((IStructuredSelection) dtevent.data).iterator();
59
	        while (selectionIterator.hasNext()){
60
	            addAuthority(selectionIterator.next());
61
	        }
62
	    }
63
	    else if(data instanceof Object[]) {
64
	        for(int i=0;i<((Object[])data).length;i++){
65
	            addAuthority(((Object[])data)[i]);
66
	        }
67
	    }
68
	    else if(data instanceof Collection) {
69
	        ((Collection) data).forEach(d->addAuthority(d));
70
	    }
71
	    else{
72
	        addAuthority(data);
73
	    }
74
	}
61 75

  
62
            while (selectionIterator.hasNext()){
63
                Object next = selectionIterator.next();
64
                if(CdmBase.class.isAssignableFrom(next.getClass()) ) {
65
                    viewer.addCdmAuthority((CdmBase)next);
66
                }
67
            }
68
		}
76
	private void addAuthority(Object authority){
77
	    if(CdmBase.class.isAssignableFrom(authority.getClass()) ) {
78
	        viewer.addCdmAuthority((CdmBase)authority);
79
	    }
69 80
	}
70 81

  
71 82
	@Override
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/group/grantedauthority/CdmAuthorityComposite.java
29 29
import org.eclipse.ui.forms.widgets.FormToolkit;
30 30

  
31 31
import eu.etaxonomy.taxeditor.dnd.CdmAuthorityTableDropTargetListener;
32
import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer;
32 33

  
33 34
/**
34 35
 * Composite class which consists of a {@link CompositeTable} built specifically
......
72 73
		numOfInitialCdmAuthorities = viewer.getCdmAuthorities().size();
73 74
		setLayout(new GridLayout(2, false));
74 75
		setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
75
	    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
76
	    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer(), TermTransfer.getInstance() };
76 77

  
77 78
	    toolkit.adapt(this);
78 79
		toolkit.paintBordersFor(this);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)