I am developing an Eclipse Plugin with my custom text editor.
I need to open files programmatically inside this custom editor. When I open it using Eclipse's DefaultTextEditor, the file opens file and I am able to edit the text, etc.
But when I try to open the file using my editor, the editor turns up blank and is uneditable. Here is the source that I am using.
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();
}
Thanks
Try to use IDE.openEditor(...).
This Eclipse wiki has more information about this:
http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_programmatically%3F
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With