public static void openEditor(IFile file, int offset, int length) { IEditorPart ep = null; try { ep = EditorUtility.openInEditor(file); } catch (PartInitException e) { e.printStackTrace(); } if (ep != null) EditorUtility.revealInEditor(ep, offset, length); }
/** * Links to editor (if option enabled) * * @param selection the selection */ private void linkToEditor(ISelection selection) { Object obj = SelectionUtil.getSingleElement(selection); if (obj != null) { IEditorPart part = EditorUtility.isOpenInEditor(obj); if (part != null) { IWorkbenchPage page = getSite().getPage(); page.bringToTop(part); if (obj instanceof IJavaElement) EditorUtility.revealInEditor(part, (IJavaElement) obj); } } }
public IEditorPart openInEditor(Object object, boolean activate) throws PartInitException, CoreException { if (object instanceof IJavaElement) { IEditorPart editor = EditorUtility.openInEditor(object, activate); if (editor != null) { EditorUtility.revealInEditor(editor, (IJavaElement) object); } return editor; } return null; }