Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schreiber2014-05-19 07:18:44 +0000
committerSergey Prigogin2014-05-19 17:38:45 +0000
commit38863b65d7d94bfd931422d716412a0adacc930e (patch)
treecf055a849cbe8a36bb0c8301032cfc0cf2bfacfb
parent17900f3f59a76ba5b8c0a4532dbf01c66d1d784e (diff)
downloadorg.eclipse.cdt-38863b65d7d94bfd931422d716412a0adacc930e.tar.gz
org.eclipse.cdt-38863b65d7d94bfd931422d716412a0adacc930e.tar.xz
org.eclipse.cdt-38863b65d7d94bfd931422d716412a0adacc930e.zip
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
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java50
1 files changed, 30 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index 1d538ab38e3..6fa1c6b9148 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -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();

Back to the top