diff options
author | Markus Schorn | 2010-10-21 09:13:38 +0000 |
---|---|---|
committer | Markus Schorn | 2010-10-21 09:13:38 +0000 |
commit | 7b99473f65e4c5d141a9e9ea5bc3f082e57893f2 (patch) | |
tree | f54bc2a87e3ac233ed3d862a136ff6a248c46f02 /core | |
parent | 8a6ca5e26126391ca9ee1f096f20e70f0e285953 (diff) | |
download | org.eclipse.cdt-7b99473f65e4c5d141a9e9ea5bc3f082e57893f2.tar.gz org.eclipse.cdt-7b99473f65e4c5d141a9e9ea5bc3f082e57893f2.tar.xz org.eclipse.cdt-7b99473f65e4c5d141a9e9ea5bc3f082e57893f2.zip |
Bug 328321: Handle attempt to open editor for closed resources.
Diffstat (limited to 'core')
5 files changed, 24 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java index 137cd1b19e0..005357c149d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java @@ -839,7 +839,7 @@ public class CElementBaseLabels { if (getFlag(flags, T_FULLY_QUALIFIED)) { ICElement parent= elem.getParent(); boolean isQualifier= true; - if (parent != null && parent.exists()) { + if (parent != null) { switch (parent.getElementType()) { case ICElement.C_ARCHIVE: case ICElement.C_BINARY: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java index 15c3b2bb2ba..224b77a5304 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java @@ -846,7 +846,7 @@ public class CElementLabelComposer { if (getFlag(flags, CElementLabels.T_FULLY_QUALIFIED)) { ICElement parent= elem.getParent(); boolean isQualifier= true; - if (parent != null && parent.exists()) { + if (parent != null) { switch (parent.getElementType()) { case ICElement.C_ARCHIVE: case ICElement.C_BINARY: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java index 8e45922946a..8109b182bed 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java @@ -20,8 +20,11 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Region; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.texteditor.ITextEditor; @@ -38,6 +41,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.model.ext.ICElementHandle; import org.eclipse.cdt.internal.ui.util.EditorUtility; +import org.eclipse.cdt.internal.ui.util.StatusLineHandler; /** * An utility to open editors for references or elements. @@ -54,6 +58,13 @@ public class EditorOpener { timestamp= file.getLocalTimeStamp(); } try { + // Bug 328321: Linked resources of closed projects report wrong location. + if (!file.exists()) { + final IWorkbenchPartSite site = page.getActivePart().getSite(); + showStatus(site, 3000, + NLS.bind(Messages.EditorOpener_fileDoesNotExist, file.getName())); + return; + } editor= IDE.openEditor(page, file, false); } catch (PartInitException e) { CUIPlugin.log(e); @@ -62,6 +73,15 @@ public class EditorOpener { } } + private static void showStatus(final IWorkbenchPartSite site, int duration, String msg) { + StatusLineHandler.showStatusLineMessage(site, msg); + Display.getCurrent().timerExec(duration, new Runnable() { + public void run() { + StatusLineHandler.clearStatusLine(site); + } + }); + } + private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) { if (editor instanceof ITextEditor) { ITextEditor te= (ITextEditor) editor; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java index 74ff73efe3f..13eecf1e087 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java @@ -14,6 +14,7 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.viewsupport.messages"; //$NON-NLS-1$ + public static String EditorOpener_fileDoesNotExist; public static String IndexedFilesCache_jobName; public static String IndexUI_infoNotInIndex; public static String IndexUI_infoNotInSource; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties index 52402c7d06f..74bd740d5e9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties @@ -8,6 +8,7 @@ # Contributors: # Markus Schorn - initial API and implementation ################################################################################ +EditorOpener_fileDoesNotExist=File ''{0}'' no longer exists IndexedFilesCache_jobName=Initialize C/C++ Index Label Provider IndexUI_infoNotInSource=The element ''{0}'' does not belong to a source file. IndexUI_infoNotInIndex=The file ''{0}'' is currently not part of the index. |