3
votes

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

1
Are you sure your editor can handle this input type? Try to set a breakpoint or log something in your editor's init method and see if it even gets here. - Alexey Romanov

1 Answers

4
votes

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