1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Fix for bug 141484 - Data loss when dnd elements in C/C++ Project browser

This commit is contained in:
Anton Leherbauer 2006-06-21 14:48:17 +00:00
parent 406419e29a
commit 7fc9ce0335
4 changed files with 21 additions and 11 deletions

View file

@ -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) {

View file

@ -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();

View file

@ -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.

View file

@ -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;
}