3

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. Commented Mar 28, 2013 at 14:34

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.