From 5b0dee1c55dd62a95cd0ecbe628bee7ea75927b3 Mon Sep 17 00:00:00 2001 From: Tobias Schwarz Date: Tue, 11 Jun 2013 13:05:44 +0200 Subject: Target Explorer: fix drop peer in editor --- .../tcf/te/tcf/ui/navigator/dnd/DragAssistant.java | 110 ++++++++++++--------- 1 file changed, 64 insertions(+), 46 deletions(-) (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf') diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DragAssistant.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DragAssistant.java index 0a6777386..93fd86852 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DragAssistant.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DragAssistant.java @@ -1,46 +1,64 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.navigator.dnd; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.dnd.DragSourceEvent; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.ui.navigator.CommonDragAdapterAssistant; - -/** - * Drag assistant implementation. - */ -public class DragAssistant extends CommonDragAdapterAssistant { - - /* (non-Javadoc) - * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#dragStart(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) - */ - @Override - public void dragStart(DragSourceEvent event, IStructuredSelection selection) { - event.doit = CommonDnD.isDraggable(selection); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes() - */ - @Override - public Transfer[] getSupportedTransferTypes() { - return new Transfer[] {}; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) - */ - @Override - public boolean setDragData(DragSourceEvent anEvent, IStructuredSelection aSelection) { - return false; - } - -} +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.navigator.dnd; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.jface.util.LocalSelectionTransfer; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.dnd.DragSourceEvent; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.tcf.te.ui.views.editor.EditorInput; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.navigator.CommonDragAdapterAssistant; +import org.eclipse.ui.part.EditorInputTransfer; +import org.eclipse.ui.part.EditorInputTransfer.EditorInputData; + +/** + * Drag assistant implementation. + */ +public class DragAssistant extends CommonDragAdapterAssistant { + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#dragStart(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) + */ + @Override + public void dragStart(DragSourceEvent event, IStructuredSelection selection) { + event.doit = CommonDnD.isDraggable(selection); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes() + */ + @Override + public Transfer[] getSupportedTransferTypes() { + return new Transfer[] {LocalSelectionTransfer.getTransfer(), EditorInputTransfer.getInstance()}; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) + */ + @Override + public boolean setDragData(DragSourceEvent event, IStructuredSelection selection) { + if (EditorInputTransfer.getInstance().isSupportedType(event.dataType)) { + List data = new ArrayList(); + Iterator it = selection.iterator(); + while (it.hasNext()) { + IEditorInput input = new EditorInput(it.next()); + data.add(EditorInputTransfer.createEditorInputData("org.eclipse.tcf.te.ui.views.Editor", input)); //$NON-NLS-1$ + } + event.data = data.toArray(new EditorInputData[data.size()]); + return true; + } + return false; + } +} -- cgit v1.2.3