Open a file => execute custom code, instead of opening a new editor

I have MyFileEditorProvider and MyFileEditor, and every time I open a file with the .xxx extension my editor is used.
But I want in some cases the .xxx not to be opened (e.g when I double click on it in the tree).
How can I do this?

Later edit:
I'd like to rephrase: when a file is opened (e.g. by double clicking it in the tree), I'd like to be able to have some custom code executed, that might decide not to open an editor. Right now:

  • MyFileEditorProvider.createEditor() is invoked. This is OK, because I can have some custom code here
  • but my custom code might say "I don't want to open an editor", and maybe open a message box displaying a message. This doesn't seem OK, because this method is expected to return a not null result


In an Eclipse environment, this might be achieved using a "launcher" concept.

Thank you in advance.
Best regards,
Sebastian.

4 comments
Comment actions Permalink

You can't. There are a huge number of places in the IntelliJ IDEA UI which can trigger navigating to a file, and having different behavior depending on where the navigation was initiated would be very confusing to the users, so there is no support in the framework for that.

What exactly are you trying to accomplish?

0
Comment actions Permalink

MyEditor contains a browser. When i open a file it shows the file in a graphical form.
What i would like to do next, is when i try to open a second file, to be able just execute a command ( myEditor1.getBrowser.execute(...)), that will open this second file in the first Editor but in a new browser tab (instead of opening it in a new Editor). (e.g. If i open 3 files, i want to see one Editor opened that will contain 3 tabs).
Is this posible?

0
Comment actions Permalink

Dear Dmitry,

I haved edited my post, and rephrased my question. I paste here my update as well.

I'd like to rephrase: when a file is opened (e.g. by double clicking it in the tree), I'd like to be able to have some custom code executed, that might decide not to open an editor. Right now:

  • MyFileEditorProvider.createEditor() is invoked. This is OK, because I can have some custom code here
  • but my custom code might say "I don't want to open an editor", and maybe open a message box displaying a message. This doesn't seem OK, because this method is expected to return a not null result


In an Eclipse environment, this might be achieved using a "launcher" concept.



Thank you!
Best Regards,
Sebastian

0
Comment actions Permalink

Not without major hacks. You can't simply decide not to open an editor when one is requested; a lot of the code in the system depends on this method returning a valid editor.

0

Please sign in to leave a comment.