【发布时间】:2016-04-23 21:53:39
【问题描述】:
我正在开发一个 Eclipse 插件,我可以通过它在 Eclipse 编辑器中打开外部文件,如下所示:
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
FileStoreEditorInput editorInput = new FileStoreEditorInput(fileStore);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor");
TextEditor editor = (TextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
editor.selectAndReveal(document.getLineOffset(line - 1), document.getLineLength(line-1));
} catch ( PartInitException e ) {
//Put your exception handler here if you wish to
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
实际上效果很好。但是其中一些文件是 *.py 文件、Python 代码,我希望像在 PyDev 编辑器中那样突出显示文本。
我想我需要打开一个不同的编辑器?!但我不知道如何或在哪里找到它。
非常感谢任何提示!谢谢!!!
【问题讨论】: