diff options
author | Pierre Sachot | 2017-04-21 14:13:16 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2017-04-28 16:09:18 +0000 |
commit | 10b1e6e4c7e7b55cdc46c9378f9b9f0b7d23d06e (patch) | |
tree | a957b2224e3c9a51f8fa301c22b55de2b546a851 /dsf/org.eclipse.cdt.dsf.ui | |
parent | 9462c1db2421f05ab00e271da33a18d30bac7bbb (diff) | |
download | org.eclipse.cdt-10b1e6e4c7e7b55cdc46c9378f9b9f0b7d23d06e.tar.gz org.eclipse.cdt-10b1e6e4c7e7b55cdc46c9378f9b9f0b7d23d06e.tar.xz org.eclipse.cdt-10b1e6e4c7e7b55cdc46c9378f9b9f0b7d23d06e.zip |
Bug 515296: New Preferences for Source not found Editor
You now have more precise options for the Source not
Found Editor.
Change-Id: I7391e50c0a9bf7fc712a45d1946e5a24e91c4991
Signed-off-by: Pierre Sachot <sachot.pierre@laposte.net>
Signed-off-by: Yannick Mayeur <yannick.mayeur@gmail.com>
Also-by: Pierre Sachot <sachot.pierre@laposte.net>
Also-by: Yannick Mayeur <yannick.mayeur@gmail.com>
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf.ui')
-rw-r--r-- | dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index 2817285afca..1aee1d442a5 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -53,6 +53,7 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; @@ -419,20 +420,24 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl if (!page.getWorkbenchWindow().getWorkbench().isClosing()) { try { if (input instanceof CSourceNotFoundEditorInput) { - if (Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, - CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, true, null)) { - editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); - /* - * Don't open additional source not found - * editors if there is one to reuse. - */ - editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); - if (editor[0] instanceof IReusableEditor) { - IReusableEditor re = (IReusableEditor) editor[0]; - if (!input.equals(re.getEditorInput())) { - re.setInput(input); - } + CSourceNotFoundEditorInput cSourceInput = ((CSourceNotFoundEditorInput) input); + String showEditor = Platform.getPreferencesService().getString(CCorePlugin.PLUGIN_ID, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_DEFAULT, null); + switch (showEditor) { + case CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_SOMETIMES: + if (isSourceFileNameKnown(cSourceInput)) { + editor[0] = openCSourceNotFoundEditor(input, id); } + break; + case CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_NEVER: + // does nothing because we don't want to + // display the source not found editor + break; + case CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_ALL_THE_TIME: + default: + editor[0] = openCSourceNotFoundEditor(input, id); + break; } } else { editor[0] = page.openEditor(input, id, false); @@ -441,6 +446,40 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl } } } + + private boolean isSourceFileNameKnown(CSourceNotFoundEditorInput input) { + Object artifact = input.getArtifact(); + String missingFile = null; + if (artifact instanceof CSourceNotFoundElement) { + CSourceNotFoundElement element = (CSourceNotFoundElement) artifact; + missingFile = element.getFile(); + } else if (artifact instanceof ITranslationUnit) { + ITranslationUnit tunit = (ITranslationUnit) artifact; + IPath tuPath = tunit.getLocation(); + if (tuPath != null) + missingFile = tuPath.toOSString(); + } else { + missingFile = ""; //$NON-NLS-1$ + } + if (missingFile != null && missingFile.length() > 0) + return true; + return false; + } + + private IEditorPart openCSourceNotFoundEditor(IEditorInput input, String id) throws PartInitException { + IEditorPart editor = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); + /* + * Don't open additional source not found editors if there + * is one to reuse. + */ + if (editor instanceof IReusableEditor) { + IReusableEditor re = (IReusableEditor) editor; + if (!input.equals(re.getEditorInput())) { + re.setInput(input); + } + } + return editor; + } }; BusyIndicator.showWhile(Display.getDefault(), r); return editor[0]; |