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

Bug 434852: If the original project of the editor input file is a non

accessiable project, it is a project rename scenario and the move can be
handeled.

Change-Id: Ibb718ea3310c3dfc40fa31d79c588371f78d6c91
Signed-off-by: Martin Schreiber <m.schreiber@bachmann.info>
Reviewed-on: https://git.eclipse.org/r/26815
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Hudson CI
This commit is contained in:
Martin Schreiber 2014-05-19 09:18:44 +02:00 committed by Sergey Prigogin
parent 17900f3f59
commit 38863b65d7

View file

@ -2085,35 +2085,45 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
String oldLanguage = ""; //$NON-NLS-1$
if (originalElement instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) originalElement).getFile();
if (file != null) {
IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
if (type != null) {
oldLanguage = type.getId();
}
if (oldLanguage == null) {
return false;
}
IFile originalFile = getEditorInputFile(originalElement);
if (originalFile != null) {
// if the project of the original input cannot be accessed,
// we do have a project rename scenario and we can handle a move
// see Bug #434852
if (originalFile.getProject() != null && !originalFile.getProject().isAccessible()) {
return true;
}
IContentType type = CCorePlugin.getContentType(originalFile.getProject(), originalFile.getName());
if (type != null) {
oldLanguage = type.getId();
}
if (oldLanguage == null) {
return false;
}
}
String newLanguage = ""; //$NON-NLS-1$
if (movedElement instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) movedElement).getFile();
if (file != null) {
IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
if (type != null) {
newLanguage = type.getId();
}
if (newLanguage == null) {
return false;
}
IFile movedFile = getEditorInputFile(movedElement);
if (movedFile != null) {
IContentType type = CCorePlugin.getContentType(movedFile.getProject(), movedFile.getName());
if (type != null) {
newLanguage = type.getId();
}
if (newLanguage == null) {
return false;
}
}
return oldLanguage.equals(newLanguage);
}
private IFile getEditorInputFile(IEditorInput editorInput) {
if (editorInput instanceof IFileEditorInput) {
return ((IFileEditorInput) editorInput).getFile();
}
return null;
}
@Override
protected void createActions() {
super.createActions();