mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Bug 328321: Handle attempt to open editor for closed resources.
This commit is contained in:
parent
8a6ca5e261
commit
7b99473f65
5 changed files with 24 additions and 2 deletions
|
@ -839,7 +839,7 @@ public class CElementBaseLabels {
|
||||||
if (getFlag(flags, T_FULLY_QUALIFIED)) {
|
if (getFlag(flags, T_FULLY_QUALIFIED)) {
|
||||||
ICElement parent= elem.getParent();
|
ICElement parent= elem.getParent();
|
||||||
boolean isQualifier= true;
|
boolean isQualifier= true;
|
||||||
if (parent != null && parent.exists()) {
|
if (parent != null) {
|
||||||
switch (parent.getElementType()) {
|
switch (parent.getElementType()) {
|
||||||
case ICElement.C_ARCHIVE:
|
case ICElement.C_ARCHIVE:
|
||||||
case ICElement.C_BINARY:
|
case ICElement.C_BINARY:
|
||||||
|
|
|
@ -846,7 +846,7 @@ public class CElementLabelComposer {
|
||||||
if (getFlag(flags, CElementLabels.T_FULLY_QUALIFIED)) {
|
if (getFlag(flags, CElementLabels.T_FULLY_QUALIFIED)) {
|
||||||
ICElement parent= elem.getParent();
|
ICElement parent= elem.getParent();
|
||||||
boolean isQualifier= true;
|
boolean isQualifier= true;
|
||||||
if (parent != null && parent.exists()) {
|
if (parent != null) {
|
||||||
switch (parent.getElementType()) {
|
switch (parent.getElementType()) {
|
||||||
case ICElement.C_ARCHIVE:
|
case ICElement.C_ARCHIVE:
|
||||||
case ICElement.C_BINARY:
|
case ICElement.C_BINARY:
|
||||||
|
|
|
@ -20,8 +20,11 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.Region;
|
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.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchPartSite;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.ide.IDE;
|
import org.eclipse.ui.ide.IDE;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
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.core.model.ext.ICElementHandle;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
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.
|
* An utility to open editors for references or elements.
|
||||||
|
@ -54,6 +58,13 @@ public class EditorOpener {
|
||||||
timestamp= file.getLocalTimeStamp();
|
timestamp= file.getLocalTimeStamp();
|
||||||
}
|
}
|
||||||
try {
|
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);
|
editor= IDE.openEditor(page, file, false);
|
||||||
} catch (PartInitException e) {
|
} catch (PartInitException e) {
|
||||||
CUIPlugin.log(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) {
|
private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
|
||||||
if (editor instanceof ITextEditor) {
|
if (editor instanceof ITextEditor) {
|
||||||
ITextEditor te= (ITextEditor) editor;
|
ITextEditor te= (ITextEditor) editor;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.viewsupport.messages"; //$NON-NLS-1$
|
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 IndexedFilesCache_jobName;
|
||||||
public static String IndexUI_infoNotInIndex;
|
public static String IndexUI_infoNotInIndex;
|
||||||
public static String IndexUI_infoNotInSource;
|
public static String IndexUI_infoNotInSource;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Markus Schorn - initial API and implementation
|
# Markus Schorn - initial API and implementation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
EditorOpener_fileDoesNotExist=File ''{0}'' no longer exists
|
||||||
IndexedFilesCache_jobName=Initialize C/C++ Index Label Provider
|
IndexedFilesCache_jobName=Initialize C/C++ Index Label Provider
|
||||||
IndexUI_infoNotInSource=The element ''{0}'' does not belong to a source file.
|
IndexUI_infoNotInSource=The element ''{0}'' does not belong to a source file.
|
||||||
IndexUI_infoNotInIndex=The file ''{0}'' is currently not part of the index.
|
IndexUI_infoNotInIndex=The file ''{0}'' is currently not part of the index.
|
||||||
|
|
Loading…
Add table
Reference in a new issue