Seeking resources for creating completely custom editors?

Some plugins (e.g. 'CSV Plugin' or the 'BinEd' hex editor) are able to display a completely different editor UI inside of JetBrains IDEs. I've set about developing the same sort of UI for a custom binary file format, so that the various values in the file can be edited as individual text fields or lists.

What is the best way to go about this in the JetBrains platform? By looking through the source code of the two plugins I listed above, I've created:

  • A `MyFormatFileType` to represent the type of file I want to edit.
  • A 'MyFormatEditorProvider':
        - `accept` ensures that the VirtualFile's fileType is the type I created earlier, and
        - `createEditor` constructs a `MyFormatEditor` for the given virtualFile.
  • A `MyFormatEditor` (impl both `FileEditor` and `DumbAware`). This is where implementation really gets difficult as it's not clear how to deal with things like the file being changed externally on disk, multiple editors managing the same file, flagging the file as modified, etc.

This is what I have major issues with:

  • `isValid` - is there any condition under which this should actually return false?
  • I'm unclear of what to do with the `getUserData`, `putUserData` methods.
  • How do I handle saving my file? Should I be directly modifying the VirtualFile buffer whenever something changes in my UI? How do I detect Ctrl/Cmd+S from the user, or Save All, etc.?
  • How do I get notified of my file being changed externally on the disk, so that I can rectify this? (Or, does the platform handle this and then re-create my editor if the file has changed?)
  • The state of my editor seems to be entirely reset if I move it to a different splitscreen panel - how do I persist unsaved modifications to the file for this?

Are there any good docs / guidance on implementing simple custom editors? Looking at existing code makes it hard to separate implementation-specific behaviour from what I'll actually need to do, as you can tell from my confusion.


Please sign in to leave a comment.