diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CopyElementsOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CopyElementsOperation.java index 44ff54b3293..d5b91e32f1e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CopyElementsOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CopyElementsOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 QNX Software Systems and others. + * Copyright (c) 2000, 2006 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 @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) - Fixed bug 141484 *******************************************************************************/ package org.eclipse.cdt.internal.core.model; @@ -86,10 +87,10 @@ public class CopyElementsOperation extends MultiOperation { * Returns the nested operation to use for processing this element */ protected CModelOperation getNestedOperation(ICElement element) { - ITranslationUnit unit = getDestinationTranslationUnit(element); + ICElement parentElement = getDestinationParent(element); String name = element.getElementName(); int type = element.getElementType(); - return new CreateSourceReferenceOperation(unit, name, type, getSourceFor(element)); + return new CreateSourceReferenceOperation(parentElement, name, type, getSourceFor(element)); } protected ITranslationUnit getDestinationTranslationUnit(ICElement element) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateSourceReferenceOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateSourceReferenceOperation.java index 314230e5d15..90bf45dd263 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateSourceReferenceOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateSourceReferenceOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2005 QNX Software Systems and others. + * Copyright (c) 2002, 2006 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 @@ -7,12 +7,14 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) - Fixed bug 141484 *******************************************************************************/ package org.eclipse.cdt.internal.core.model; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.ITranslationUnit; /** @@ -56,9 +58,9 @@ public class CreateSourceReferenceOperation extends CreateElementInTUOperation { * @see org.eclipse.cdt.internal.core.model.CreateElementInTUOperation#generateResultHandle() */ protected ICElement generateResultHandle() { - ITranslationUnit unit = getTranslationUnit(); + IParent parent = (IParent)getParentElement(); try { - ICElement[] celements = unit.getChildren(); + ICElement[] celements = parent.getChildren(); for (int i = 0; i < celements.length; ++i) { if (celements[i].getElementType() == fElementType) { String name = celements[i].getElementName(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties index 1536cb3b039..5faea272793 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties @@ -7,6 +7,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Anton Leherbauer (Wind River Systems) - Fixed bug 141484 ############################################################################### @@ -62,3 +63,7 @@ CView.statusLine = {0} items selected CopyToClipboardProblemDialog_title=Problem Copying to Clipboard CopyToClipboardProblemDialog_message=There was a problem when accessing the system clipboard. Retry? + +SelectionTransferDropAdapter.error.title=Drag and Drop Problem +SelectionTransferDropAdapter.error.message=A problem occurred during Drag and Drop. +SelectionTransferDropAdapter.error.exception=An unexpected exception occurred during Drag and Drop. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java index d2bbdf9a5aa..69e6a8f6d8c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2005 QNX Software Systems and others. + * Copyright (c) 2002, 2006 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 @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) - Fixed bug 141484 *******************************************************************************/ package org.eclipse.cdt.internal.ui.cview; @@ -19,7 +20,6 @@ import java.util.List; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.ui.dnd.CDTViewerDropAdapter; @@ -143,7 +143,7 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement } catch (CModelException e){ ExceptionHandler.handle(e, CViewMessages.getString("SelectionTransferDropAdapter.error.title"), CViewMessages.getString("SelectionTransferDropAdapter.error.message")); //$NON-NLS-1$ //$NON-NLS-2$ } catch(InvocationTargetException e) { - ExceptionHandler.handle(e, CViewMessages.getString("OpenRefactoringWizardAction.refactoring"), CViewMessages.getString("OpenRefactoringWizardAction.exception")); //$NON-NLS-1$ //$NON-NLS-2$ + ExceptionHandler.handle(e, CViewMessages.getString("SelectionTransferDropAdapter.error.title"), CViewMessages.getString("SelectionTransferDropAdapter.error.exception")); //$NON-NLS-1$ //$NON-NLS-2$ } catch (InterruptedException e) { //ok } finally { @@ -162,7 +162,7 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement } private int handleValidateMove(Object target, DropTargetEvent event) throws CModelException { - if (target == null) { + if (target == null || fElements.contains(target)) { return DND.DROP_NONE; } if (fMoveData == null) { @@ -247,10 +247,12 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement } private int handleValidateCopy(Object target, DropTargetEvent event) throws CModelException{ + if (target == null) { + return DND.DROP_NONE; + } if (fCopyData == null) { ICElement[] cElements= getCElements(fElements); - ICProject project= null; if (cElements != null && cElements.length > 0) { fCopyData= cElements; }