1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 328321: Handle attempt to open editor for closed resources.

This commit is contained in:
Markus Schorn 2010-10-21 09:13:38 +00:00
parent 8a6ca5e261
commit 7b99473f65
5 changed files with 24 additions and 2 deletions

View file

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

View file

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

View file

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

View file

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

View file

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