【发布时间】:2023-03-20 03:25:02
【问题描述】:
我正在使用我的自定义文本编辑器开发一个 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();
}
谢谢
【问题讨论】:
-
您确定您的编辑器可以处理这种输入类型吗?尝试在编辑器的
init方法中设置断点或记录一些内容,看看它是否到达这里。
标签: java eclipse eclipse-plugin eclipse-rcp