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

[265472] - Drag-Copy of Make Targets in the same folder should not be allowed without Ctrl key, patch applied

This commit is contained in:
Alena Laskavaia 2009-03-12 18:23:28 +00:00
parent d87cfdf0b6
commit c3755751d8
5 changed files with 23 additions and 20 deletions

View file

@ -32,7 +32,7 @@ import org.eclipse.swt.dnd.TransferData;
public abstract class AbstractContainerAreaDropAdapter implements TransferDropTargetListener {
private int originallyRequestedOperation = DND.DROP_NONE;
private IContainer lastDragOverContainer = null;
private Object lastDragOverTarget = null;
private int lastDragOverOperation = DND.DROP_NONE;
/**
@ -60,6 +60,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
*
* @param operation - incoming operation.
* @param dropContainer - container where drop is going to be.
* @param dropTarget - drop target.
* @return changed operation. The return must be one of
* {@link org.eclipse.swt.dnd.DND} operations.
*
@ -71,7 +72,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
* @see DND#DROP_LINK
* @see DND#DROP_DEFAULT
*/
protected abstract int dragOverOperation(int operation, IContainer dropContainer);
protected abstract int dragOverOperation(int operation, IContainer dropContainer, Object dropTarget);
/**
* Implementation of the actual drop of {@code dropObject} to {@code dropContainer}.
@ -120,7 +121,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
* @see DropTargetEvent
*/
public void dragEnter(DropTargetEvent event) {
lastDragOverContainer = null;
lastDragOverTarget = null;
lastDragOverOperation = DND.DROP_NONE;
if (isSupportedType(event.currentDataType)) {
@ -143,7 +144,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
public void dragOperationChanged(DropTargetEvent event) {
originallyRequestedOperation = event.detail;
event.detail = dragOverOperationCached(originallyRequestedOperation,
determineDropContainer(event));
determineDropContainer(event), determineDropTarget(event));
}
/**
@ -156,7 +157,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
*/
public void dragOver(DropTargetEvent event) {
event.detail = dragOverOperationCached(originallyRequestedOperation,
determineDropContainer(event));
determineDropContainer(event), determineDropTarget(event));
if (originallyRequestedOperation != DND.DROP_NONE) {
// let user discover items even if event.detail is DND.DROP_NONE
@ -205,7 +206,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
public void drop(DropTargetEvent event) {
IContainer dropContainer = determineDropContainer(event);
if (dropContainer != null) {
event.detail = dragOverOperationCached(event.detail, dropContainer);
event.detail = dragOverOperationCached(event.detail, dropContainer, determineDropTarget(event));
dropToContainer(event.data, dropContainer, event.detail);
} else {
event.detail = DND.DROP_NONE;
@ -218,6 +219,7 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
*
* @param operation - incoming operation.
* @param dropContainer - container where drop is going to be.
* @param dropTarget - drop target.
* @return changed operation. The return must be one of
* org.eclipse.swt.dnd.DND operations such as {@link DND#DROP_NONE},
* {@link DND#DROP_COPY}, {@link DND#DROP_MOVE},
@ -226,10 +228,10 @@ public abstract class AbstractContainerAreaDropAdapter implements TransferDropTa
*
* @see DropTargetListener#dragOver(DropTargetEvent)
*/
private int dragOverOperationCached(int operation, IContainer dropContainer) {
if (dropContainer != lastDragOverContainer || operation != lastDragOverOperation) {
lastDragOverOperation = dragOverOperation(operation, dropContainer);
lastDragOverContainer = dropContainer;
private int dragOverOperationCached(int operation, IContainer dropContainer, Object dropTarget) {
if (dropTarget != lastDragOverTarget || operation != lastDragOverOperation) {
lastDragOverOperation = dragOverOperation(operation, dropContainer, dropTarget);
lastDragOverTarget = dropTarget;
}
return lastDragOverOperation;
}

View file

@ -66,7 +66,7 @@ public class FileTransferDropTargetListener extends AbstractContainerAreaDropAda
*/
@Override
public int dragEnterOperation(int operation) {
return dragOverOperation(operation, null);
return dragOverOperation(operation, null, null);
}
/**
@ -77,7 +77,7 @@ public class FileTransferDropTargetListener extends AbstractContainerAreaDropAda
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
public int dragOverOperation(int operation, IContainer dropContainer, Object dropTarget) {
// This class is intended only for drag/drop between eclipse instances,
// so DND_COPY always set and we don't bother checking if the target is the source
if (operation!=DND.DROP_NONE) {

View file

@ -90,17 +90,18 @@ public class LocalTransferDropTargetListener extends AbstractContainerAreaDropAd
* Operation on dragging over target . Adjusted to be the least of user
* initiated operation and best supported operation for a given selection
* considering drop container. The operation will be indicated by mouse
* cursor.
* cursor. Note that drop on itself is not allowed here.
*
* @param operation - incoming operation.
* @param dropContainer - container where drop is going to be.
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
public int dragOverOperation(int operation, IContainer dropContainer, Object dropTarget) {
int bestOperation = DND.DROP_NONE;
if (dropContainer != null) {
bestOperation = determineBestOperation(getSelection(), dropContainer);
IStructuredSelection selection = getSelection();
if (dropContainer != null && selection != null && !selection.toList().contains(dropTarget)) {
bestOperation = determineBestOperation(selection, dropContainer);
if (bestOperation > operation) {
bestOperation = operation;
}

View file

@ -55,7 +55,7 @@ public class MakeTargetTransferDropTargetListener extends AbstractContainerAreaD
*/
@Override
public int dragEnterOperation(int operation) {
return dragOverOperation(operation, null);
return dragOverOperation(operation, null, null);
}
/**
@ -66,7 +66,7 @@ public class MakeTargetTransferDropTargetListener extends AbstractContainerAreaD
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
public int dragOverOperation(int operation, IContainer dropContainer, Object dropTarget) {
// This class is intended only for drag/drop between eclipse instances,
// so DND_COPY always set and we don't bother checking if the target is the source
if (operation!=DND.DROP_NONE) {

View file

@ -63,7 +63,7 @@ public class TextTransferDropTargetListener extends AbstractContainerAreaDropAda
*/
@Override
public int dragEnterOperation(int operation) {
return dragOverOperation(operation, null);
return dragOverOperation(operation, null, null);
}
/**
@ -74,7 +74,7 @@ public class TextTransferDropTargetListener extends AbstractContainerAreaDropAda
* @return changed operation.
*/
@Override
public int dragOverOperation(int operation, IContainer dropContainer) {
public int dragOverOperation(int operation, IContainer dropContainer, Object dropTarget) {
// This class is intended only for drag/drop between eclipse instances,
// so DND_COPY always set and we don't bother checking if the target is the source
if (operation!=DND.DROP_NONE) {