diff options
Diffstat (limited to 'profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java')
-rw-r--r-- | profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java b/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java index ab3fc2dacc..2748edac00 100644 --- a/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java +++ b/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java @@ -89,37 +89,37 @@ public class ProfileUIUtils { } } - /** - * Open a file in the Editor at the specified offset, highlighting the given length - * - * @param path : Absolute path pointing to the file which will be opened. - * @param line - line number to select, 0 to not select a line - * @param project - current project object - * @throws BadLocationException - Line number not valid in file - * @throws PartInitException if the editor could not be initialized - * @throws CoreException if the proxy cannot be initialized - * @since 3.1 - */ - public static void openEditorAndSelect(String path, int line, IProject project) throws PartInitException, BadLocationException, CoreException { - IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IRemoteFileProxy proxy = null; - proxy = RemoteProxyManager.getInstance().getFileProxy(project); - IFileStore file = proxy.getResource(path); - if (file.fetchInfo().exists()) { - IEditorPart editor = IDE.openEditorOnFileStore(activePage, file); - if (editor instanceof ITextEditor) { - ITextEditor textEditor = (ITextEditor) editor; - - if (line > 0) { - IDocumentProvider provider = textEditor.getDocumentProvider(); - IDocument document = provider.getDocument(textEditor.getEditorInput()); - - int start = document.getLineOffset(line - 1); //zero-indexed - textEditor.selectAndReveal(start, 0); - } - } - } - } + /** + * Open a file in the Editor at the specified offset, highlighting the given length + * + * @param path : Absolute path pointing to the file which will be opened. + * @param line - line number to select, 0 to not select a line + * @param project - current project object + * @throws BadLocationException - Line number not valid in file + * @throws PartInitException if the editor could not be initialized + * @throws CoreException if the proxy cannot be initialized + * @since 3.1 + */ + public static void openEditorAndSelect(String path, int line, IProject project) throws PartInitException, BadLocationException, CoreException { + IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IRemoteFileProxy proxy = null; + proxy = RemoteProxyManager.getInstance().getFileProxy(project); + IFileStore file = proxy.getResource(path); + if (file.fetchInfo().exists()) { + IEditorPart editor = IDE.openEditorOnFileStore(activePage, file); + if (editor instanceof ITextEditor) { + ITextEditor textEditor = (ITextEditor) editor; + + if (line > 0) { + IDocumentProvider provider = textEditor.getDocumentProvider(); + IDocument document = provider.getDocument(textEditor.getEditorInput()); + + int start = document.getLineOffset(line - 1); //zero-indexed + textEditor.selectAndReveal(start, 0); + } + } + } + } /** |