简体   繁体   中英

How can I connect my own class?

I'm working on a RCP application and I would like to do something during the opening of a file in the editor. For that, I wrote this:

public class MyFileEditorInput extends FileEditorInput {

    public MyFileEditorInput(IFile file) {
        super(file);
        // TODO Auto-generated constructor stub
    }
}

This class extends of the FileEditorInput class but at the start of my application, It's FileEditorInput which is opening. How can I replace by my own method?

If your editor is being opened by Eclipse using one of the normal mechanisms (such as double clicking on the file or using 'Open With...') then FileEditorInput will always be used. You can't change this.

If you open the file using one of the IDE class

IEditorPart openEditor(IWorkbenchPage page, IEditorInput input, String editorId)

IEditorPart openEditor(IWorkbenchPage page, IEditorInput input, String editorId, boolean activate)

methods or the various IWorkbenchPage openEditor methods which take an IEditorInput then you can specify your editor input class.

@ greg-449 : Do you have a tutorial to do this? I'm trying to create my own editor. I do this in my eclipse.platform.custom plugin, Is It the good way? Project Architecture

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM