FileEditor questions

Hi,

I want to create a plugin which should offer the ability to edit certain
xml files using an own FileEditor (like source editor or GUI builder
editor). But how to assoziate the file extension with my editor class,
so a double-click at the xml-file in the project will open my editor?

I've taken a look at ImageEditor from Alexey Efimov, but was not able to
open an editor by double-clicking images :(

Thanks in advance.

--
Cheers,
Tom

0
18 comments

I've taken a look at ImageEditor from Alexey Efimov, but was not able to
open an editor by double-clicking images :(


It must open... Hmm... That version of IDEA you test?

So, common logic is:
1. You implement FileEditorProvider
2. Check by IDEA request, can you edit file or not.
3. If your FileEditorProvider catch file for editing, then you may control
how it will be edited. As main editor, and disable other editors and as
additional editor - the editor will have tabs on botton.
Thanks!


0

It must open... Hmm... That version of IDEA you test?


Build 1178.

So, common logic is:
1. You implement FileEditorProvider
2. Check by IDEA request, can you edit file or not.
3. If your FileEditorProvider catch file for editing, then you may control
how it will be edited. As main editor, and disable other editors and as
additional editor - the editor will have tabs on botton.


I've created 3 implementations of
com.intellij.openapi.components.ApplicationComponent,
com.intellij.openapi.fileEditor.FileEditorProvider and
com.intellij.openapi.fileEditor.FileEditor. The content of the
META-INF/plugin.xml looks like:
FormBuilder FormBuilder Plugin 0.0.1 Thomas Singer de.regnis.formbuilder.FormBuilderApplicationComponent ]]>

But how do I tell IDEA the name of my FileEditorProvider?

Tom

0

Hello!

You must do implement both ApplicationComponent and FileEditorProvider for
your editor:


This all that you need to create your ouw editor :)

Thanks!


0


Thomas Singer (MoTJ) wrote:

...
I've created 3 implementations of
com.intellij.openapi.components.ApplicationComponent,
com.intellij.openapi.fileEditor.FileEditorProvider and
com.intellij.openapi.fileEditor.FileEditor. The content of the
...
But how do I tell IDEA the name of my FileEditorProvider?


The trick is that the ApplicationComponent also has to implement the
FileEditorProvider, like this:

public class ExampleFileEditorProvider implements ApplicationComponent, FileEditorProvider { }

Then IDEA will find it by itself.


Sascha


0

It must open... Hmm... That version of IDEA you test?

>

Build 1178.


I check it just now, it work on double click and open images :)


0

Sorry, this does not work - neither with my plugin nor with imageEditor.
When I double click a file (which is shown as ) I get an "Register
New Extension" dialog, but there is no imageEditor available...

Maybe somebody from IntelliJ can comment on this issue?

Tom

0

Well, not here :( What icons your graphics have in IDEA's Project view?

Tom

0

Does it mean, IDEA calls accept(Project, VirtualFile) for all plugin's
Application-/ProjectComponents which implement FileEditorProvider and
takes the first one which returns true?

Tom

0


Thomas Singer (MoTJ) wrote:

Does it mean, IDEA calls accept(Project, VirtualFile) for all plugin's
Application-/ProjectComponents which implement FileEditorProvider and
takes the first one which returns true?


I'm pretty sure this is the way it works. However, for unknown file types you'll
always get IDEA's file-type selection box first. As far as I know there's currently
no way for an EditorProvider to register new file types, so this has to be done
manually once.

Sascha


0

Tom,

I have registered Custom type for binary... So, if you look for '?' as icon,
then you need register custom type.


0

Ah, OK, now it is working. I expected, that when IDEA shows the Register
New Extension dialog without any hint of the imageEditor, that IDEA did
not recognized that there is a custom file editor behind.

Any related RFE to vote for?

Tom

0

Any related RFE to vote for?


Any words of API of "FileTypeManager" was in NNTP, but Open API still not
allow do this from plugin.


0

Greetings!

I make it as workaround in PLUS. Take a look at PLUS 0.1.2 API.

Thanks!

0

See subject.

Tom

0

Hi,
IDEA handles document saving internally. Also you may look at com.intellij.openapi.fileEditor.FileDocumentManager may be it helps.

TIA,
Dmitry

0

Also you may look at com.intellij.openapi.fileEditor.FileDocumentManager may be it helps.


Could you please be a little bit more precise about the details? In what
relation FileEditor and Document stay? Could you please provide a simple
example, e.g. by using a JTextArea for editing text files? Thanks in
advance.

Tom

0

Hi,
Probaly like this:
By FileDocumentManager.getDocument(VirtualFile file) you'll get Document for your file. And after this you can do everithing you want with it.

Hope it helps.

TIA,
Dmitry

0

Where can I get this Image Editor code?

0

Please sign in to leave a comment.