我正在使用自定义文本编辑器开发Eclipse插件.
我需要在此自定义编辑器中以编程方式打开文件.
当我使用Eclipse的DefaultTextEditor打开它时,该文件将打开文件,并且我可以编辑文本等.
但是,当我尝试使用编辑器打开文件时,该编辑器会变成空白并且无法编辑.这是我正在使用的来源.
File file = new File(filename);
IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(file.toURI());
FileStoreEditorInput editorInput = new FileStoreEditorInput(fileOnLocalDisk);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
try {
// this works fine
page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor");
// this is where the issue is
page.openEditor(editorInput, "MyEditor.editor");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
谢谢