mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
Project Explorer: Fix for drop in folder
This commit is contained in:
parent
1f5832d033
commit
78a7a6be39
2 changed files with 71 additions and 51 deletions
|
@ -2000,7 +2000,7 @@
|
||||||
<instanceof value="org.eclipse.cdt.core.model.ISourceReference"/>
|
<instanceof value="org.eclipse.cdt.core.model.ISourceReference"/>
|
||||||
<instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
|
<instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
|
||||||
<instanceof value="org.eclipse.cdt.core.model.ICProject"/>
|
<instanceof value="org.eclipse.cdt.core.model.ICProject"/>
|
||||||
<adapt type="org.eclipse.core.resources.IResource"/>
|
<instanceof value="org.eclipse.core.resources.IResource"/>
|
||||||
</or>
|
</or>
|
||||||
</possibleDropTargets>
|
</possibleDropTargets>
|
||||||
</dropAssistant>
|
</dropAssistant>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -17,6 +17,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -75,14 +76,21 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
public IStatus handleDrop(CommonDropAdapter dropAdapter,
|
public IStatus handleDrop(CommonDropAdapter dropAdapter,
|
||||||
DropTargetEvent event, Object target) {
|
DropTargetEvent event, Object target) {
|
||||||
|
|
||||||
// special case: drop in C source folder
|
try {
|
||||||
if (target instanceof ICContainer || target instanceof ICProject) {
|
// drop in folder
|
||||||
|
if (target instanceof ICContainer ||
|
||||||
|
target instanceof ICProject ||
|
||||||
|
target instanceof IContainer ||
|
||||||
|
(event.detail == DND.DROP_COPY && (
|
||||||
|
target instanceof IFile ||
|
||||||
|
target instanceof ITranslationUnit))) {
|
||||||
|
|
||||||
final Object data= event.data;
|
final Object data= event.data;
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
final IContainer destination= getDestination(target);
|
final IContainer destination= getDestination(target);
|
||||||
if (target == null) {
|
if (destination == null) {
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
IResource[] resources = null;
|
IResource[] resources = null;
|
||||||
|
@ -90,6 +98,12 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(
|
if (LocalSelectionTransfer.getTransfer().isSupportedType(
|
||||||
currentTransfer)) {
|
currentTransfer)) {
|
||||||
resources = getSelectedResources();
|
resources = getSelectedResources();
|
||||||
|
if (target instanceof ITranslationUnit) {
|
||||||
|
if (handleDropCopy(target, event).isOK()) {
|
||||||
|
// drop inside translation unit - we are done
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (ResourceTransfer.getInstance().isSupportedType(
|
} else if (ResourceTransfer.getInstance().isSupportedType(
|
||||||
currentTransfer)) {
|
currentTransfer)) {
|
||||||
resources = (IResource[]) event.data;
|
resources = (IResource[]) event.data;
|
||||||
|
@ -121,7 +135,6 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
switch(event.detail) {
|
switch(event.detail) {
|
||||||
case DND.DROP_MOVE:
|
case DND.DROP_MOVE:
|
||||||
return handleDropMove(target, event);
|
return handleDropMove(target, event);
|
||||||
|
@ -151,8 +164,13 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
public IStatus validateDrop(Object target, int operation,
|
public IStatus validateDrop(Object target, int operation,
|
||||||
TransferData transferType) {
|
TransferData transferType) {
|
||||||
|
|
||||||
// special case: drop in C source folder
|
// drop in folder
|
||||||
if (target instanceof ICContainer || target instanceof ICProject) {
|
if (target instanceof ICContainer ||
|
||||||
|
target instanceof ICProject ||
|
||||||
|
target instanceof IContainer ||
|
||||||
|
(operation == DND.DROP_COPY && (
|
||||||
|
target instanceof IFile ||
|
||||||
|
target instanceof ITranslationUnit))) {
|
||||||
IContainer destination= getDestination(target);
|
IContainer destination= getDestination(target);
|
||||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
|
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
|
||||||
IResource[] selectedResources= getSelectedResources();
|
IResource[] selectedResources= getSelectedResources();
|
||||||
|
@ -251,7 +269,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
|
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
|
||||||
final ICElement[] cElements= getCElements(selection);
|
final ICElement[] cElements= getCElements(selection);
|
||||||
|
|
||||||
if (target instanceof ICElement) {
|
if (target instanceof ICElement && cElements.length > 0) {
|
||||||
ICElement cTarget = (ICElement)target;
|
ICElement cTarget = (ICElement)target;
|
||||||
ICElement parent = cTarget;
|
ICElement parent = cTarget;
|
||||||
boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
|
boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
|
||||||
|
@ -379,6 +397,8 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
return (IContainer)dropTarget;
|
return (IContainer)dropTarget;
|
||||||
} else if (dropTarget instanceof ICElement) {
|
} else if (dropTarget instanceof ICElement) {
|
||||||
return getDestination(((ICElement)dropTarget).getResource());
|
return getDestination(((ICElement)dropTarget).getResource());
|
||||||
|
} else if (dropTarget instanceof IFile) {
|
||||||
|
return ((IFile)dropTarget).getParent();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue