import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
-import eu.etaxonomy.cdm.model.description.FeatureNode;
+import eu.etaxonomy.cdm.model.term.FeatureNode;
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
public class FeatureNodeDragListener extends DragSourceAdapter {
@Override
public void dragSetData(DragSourceEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- FeatureNode[] featureNodes = (FeatureNode[]) selection.toList().toArray(new FeatureNode[selection.size()]);
- if (FeatureNodeTransfer.getInstance().isSupportedType(event.dataType)) {
- event.data = featureNodes;
+ if(selection!=null && !selection.isEmpty()){
+ FeatureNode[] featureNodes = (FeatureNode[]) selection.toList().toArray(new FeatureNode[selection.size()]);
+ if (FeatureNodeTransfer.getInstance().isSupportedType(event.dataType)) {
+ event.data = featureNodes;
+ }
}
}
*/
@Override
public void dragStart(DragSourceEvent event) {
- event.doit = !viewer.getSelection().isEmpty();
+ event.doit = !viewer.getSelection().isEmpty()
+ && ((IStructuredSelection) viewer.getSelection()).toList()
+ .stream().allMatch(element -> element instanceof FeatureNode);
}
}
\ No newline at end of file