1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

[241870] - applying patch to enable PluginTransferDrop

This commit is contained in:
Alena Laskavaia 2008-07-28 18:53:11 +00:00
parent 0ff272e50e
commit fe6577cf5a
2 changed files with 64 additions and 3 deletions

View file

@ -74,6 +74,7 @@ import org.eclipse.ui.part.ISetSelectionTarget;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.PluginTransfer;
import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
@ -102,6 +103,7 @@ import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter;
import org.eclipse.cdt.internal.ui.dnd.DelegatingDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.FileTransferDragAdapter;
import org.eclipse.cdt.internal.ui.dnd.FileTransferDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.PluginTransferDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.ResourceTransferDragAdapter;
import org.eclipse.cdt.internal.ui.dnd.ResourceTransferDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.TransferDragSourceListener;
@ -380,7 +382,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
Transfer[] transfers= new Transfer[] {
LocalSelectionTransfer.getInstance(),
ResourceTransfer.getInstance(),
FileTransfer.getInstance()
FileTransfer.getInstance(),
};
TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
new SelectionTransferDragAdapter(viewer),
@ -395,11 +397,14 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
Transfer[] transfers= new Transfer[] {
LocalSelectionTransfer.getInstance(),
ResourceTransfer.getInstance(),
FileTransfer.getInstance()};
FileTransfer.getInstance(),
PluginTransfer.getInstance()
};
TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
new SelectionTransferDropAdapter(viewer),
new ResourceTransferDropAdapter(viewer),
new FileTransferDropAdapter(viewer)
new FileTransferDropAdapter(viewer),
new PluginTransferDropAdapter(viewer),
};
viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
}

View file

@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2002, 2008 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.dnd;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.ui.part.PluginDropAdapter;
import org.eclipse.ui.part.PluginTransfer;
import org.eclipse.cdt.core.model.ICElement;
/**
* PluginTransferDropAdapter
* Enable DND to support PluginTransfer type.
* The actual DND operation is a call back to the
* org.eclipse.ui.dropActions delegate.
*
*/
public class PluginTransferDropAdapter extends PluginDropAdapter implements
TransferDropTargetListener {
public PluginTransferDropAdapter (StructuredViewer viewer) {
super(viewer);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener#getTransfer()
*/
public Transfer getTransfer() {
return PluginTransfer.getInstance();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener#isEnabled(org.eclipse.swt.dnd.DropTargetEvent)
*/
public boolean isEnabled(DropTargetEvent event) {
Object target= event.item != null ? event.item.getData() : null;
if (target == null) {
return false;
}
return target instanceof ICElement || target instanceof IResource;
}
}