我正在开发一个带有自定义文本编辑器的Eclipse插件。
我需要在这个自定义编辑器内以编程方式打开文件,当我使用Eclipse的DefaultTextEditor打开它时,文件会被打开,并且可以编辑文本等操作。
但当我尝试使用我的编辑器打开文件时,编辑器显示为空白且无法编辑。这是我正在使用的源代码。
我需要在这个自定义编辑器内以编程方式打开文件,当我使用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();
}
谢谢