diff options
author | Tobias Schwarz | 2013-06-11 11:05:44 +0000 |
---|---|---|
committer | Tobias Schwarz | 2013-06-11 11:05:44 +0000 |
commit | 5b0dee1c55dd62a95cd0ecbe628bee7ea75927b3 (patch) | |
tree | b29a3e5ce66d2e0134f03b4001474617205f79b3 /target_explorer | |
parent | fc68b361baf9f9b0763af7433f4803d82af22ba6 (diff) | |
download | org.eclipse.tcf-5b0dee1c55dd62a95cd0ecbe628bee7ea75927b3.tar.gz org.eclipse.tcf-5b0dee1c55dd62a95cd0ecbe628bee7ea75927b3.tar.xz org.eclipse.tcf-5b0dee1c55dd62a95cd0ecbe628bee7ea75927b3.zip |
Target Explorer: fix drop peer in editor
Diffstat (limited to 'target_explorer')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DragAssistant.java | 110 |
1 files changed, 64 insertions, 46 deletions
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<EditorInputData> data = new ArrayList<EditorInputTransfer.EditorInputData>(); + 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; + } +} |