Custom editor for a custom virtual file type - what am I doing wrong?

Hi,
I would like to be able to open a JIRA ticket as a custom file in a custom editor. I am trying to do this like so (from the actionPerformed() method):

VirtualFile vf = new JIRAIssueVirtualFile();

fileEditorManager fileEditorManager =FileEditorManager.getInstance(DataKeys.PROJECT.getData(event.getDataContext()));
fileEditorManager.openFile(vf, false);

I have created a derivative of the FileEditorProvider class, which is supposed to produce (for now) a simple JPanel.
The JIRAIssueVirtualFile is a class implementting VirtualFile, with trivial (mostly empty) method implementations (see attachements for the full sources).
What happens is, when I invoke the action above, I get the "@NotNull method com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.openFileImpl2 must not return null" and a dialog box pops up, saying "Cannot perform operation. Too complex, sorry.".

The exception stack trace is like so:

at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl2(FileEditorManagerImpl.java)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.a(FileEditorManagerImpl.java:80)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWithProviders(FileEditorManagerImpl.java:111)
at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.java:2)
at com.atlassian.theplugin.idea.action.jira.ShowCommentsAction.actionPerformed(ShowCommentsAction.java:24)


What am I doing wrong?

Janusz



Attachment(s):
ShowCommentsAction.java
ThePluginApplicationComponent.java
5 comments
Comment actions Permalink

Hello Janusz,

Is FileEditorProvider.accept() called on your FileEditorProvider? Do you
return true from it?

Hi,
I would like to be able to open a JIRA ticket as a custom file in a
custom editor. I am trying to do this like so (from the
actionPerformed() method):
VirtualFile vf = new JIRAIssueVirtualFile();

+fileEditorManager fileEditorManager
=FileEditorManager.getInstance(DataKeys.PROJECT.getData(event.getDataC
ontext()));+

fileEditorManager.openFile(vf, false);

I have created a derivative of the FileEditorProvider class, which
is supposed to produce (for now) a simple JPanel.

The JIRAIssueVirtualFile is a class implementting VirtualFile,
with trivial (mostly empty) method implementations (see attachements
for the full sources).

What happens is, when I invoke the action above, I get the +"@NotNull
method
com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.openFileImp
l2 must not return null"+ and a dialog box pops up, saying +"Cannot
perform operation. Too complex, sorry."+.

The exception stack trace is like so:

+at
com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImp
l2(FileEditorManagerImpl.java)+

+at
com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.a(FileEdito
rManagerImpl.java:80)+

+at
com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWit
hProviders(FileEditorManagerImpl.java:111)+

+at
com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEd
itorManagerEx.java:2)+

+at
com.atlassian.theplugin.idea.action.jira.ShowCommentsAction.actionPerf
ormed(ShowCommentsAction.java:24)+

What am I doing wrong?

Janusz

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Yes, accept() is being called and I am returning true from it for files with .JIRAIssue extension.

The order of calls, as seen from within the plugin is such:

file.getName()
provider.accept()
provider.getPolicy()
file.getName() - 10 times - I assume this is being called from accept() of various editor providers
provider.accept()
provider.createEditor()
editor.isValid()
editor.addPropertyChangeListener()
messagebox is shown
exception is thrown

What's interesting is that regular files with .JIRAIssue extension open fine in my "editor", so there is probably something wrong with my implementation of VirtualFile. But unfortunately I have no idea what is wrong there.

Janusz

0
Comment actions Permalink

Hello Janusz,

One thing that's definitely missing in your code is the implementation of
getInputStream() method on your VirtualFile.

Yes, accept() is being called and I am returning true from it for
files with .JIRAIssue extension.

The order of calls, as seen from within the plugin is such:

file.getName()

provider.accept()

provider.getPolicy()

+file.getName() - 10 times - I assume this is being called from
accept() of various editor providers+

provider.accept()

provider.createEditor()

editor.isValid()

editor.addPropertyChangeListener()

messagebox is shown

exception is thrown

What's interesting is that regular files with .JIRAIssue extension
open fine in my "editor", so there is probably something wrong with my
implementation of VirtualFile. But unfortunately I have no idea what
is wrong there.

Janusz

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Well, I have changed this method to:

public InputStream getInputStream() throws IOException {return new ByteArrayInputStream(new byte[1]);}

but it does not help. This method is not even being called.

0
Comment actions Permalink

Remember to override getModificationStamp() in your VirtualFile implementation.
I don't get why it is not abstract anyway...

0

Please sign in to leave a comment.