mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +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:
parent
17900f3f59
commit
38863b65d7
1 changed files with 30 additions and 20 deletions
|
@ -2085,35 +2085,45 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
@Override
|
@Override
|
||||||
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
|
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
|
||||||
String oldLanguage = ""; //$NON-NLS-1$
|
String oldLanguage = ""; //$NON-NLS-1$
|
||||||
if (originalElement instanceof IFileEditorInput) {
|
IFile originalFile = getEditorInputFile(originalElement);
|
||||||
IFile file = ((IFileEditorInput) originalElement).getFile();
|
|
||||||
if (file != null) {
|
if (originalFile != null) {
|
||||||
IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
|
// if the project of the original input cannot be accessed,
|
||||||
if (type != null) {
|
// we do have a project rename scenario and we can handle a move
|
||||||
oldLanguage = type.getId();
|
// see Bug #434852
|
||||||
}
|
if (originalFile.getProject() != null && !originalFile.getProject().isAccessible()) {
|
||||||
if (oldLanguage == null) {
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
IContentType type = CCorePlugin.getContentType(originalFile.getProject(), originalFile.getName());
|
||||||
|
if (type != null) {
|
||||||
|
oldLanguage = type.getId();
|
||||||
|
}
|
||||||
|
if (oldLanguage == null) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String newLanguage = ""; //$NON-NLS-1$
|
String newLanguage = ""; //$NON-NLS-1$
|
||||||
if (movedElement instanceof IFileEditorInput) {
|
IFile movedFile = getEditorInputFile(movedElement);
|
||||||
IFile file = ((IFileEditorInput) movedElement).getFile();
|
if (movedFile != null) {
|
||||||
if (file != null) {
|
IContentType type = CCorePlugin.getContentType(movedFile.getProject(), movedFile.getName());
|
||||||
IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
|
if (type != null) {
|
||||||
if (type != null) {
|
newLanguage = type.getId();
|
||||||
newLanguage = type.getId();
|
}
|
||||||
}
|
if (newLanguage == null) {
|
||||||
if (newLanguage == null) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oldLanguage.equals(newLanguage);
|
return oldLanguage.equals(newLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IFile getEditorInputFile(IEditorInput editorInput) {
|
||||||
|
if (editorInput instanceof IFileEditorInput) {
|
||||||
|
return ((IFileEditorInput) editorInput).getFile();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createActions() {
|
protected void createActions() {
|
||||||
super.createActions();
|
super.createActions();
|
||||||
|
|
Loading…
Add table
Reference in a new issue