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
Please sign in to leave a comment.
Hello Janusz,
Is FileEditorProvider.accept() called on your FileEditorProvider? Do you
return true from it?
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
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
Hello Janusz,
One thing that's definitely missing in your code is the implementation of
getInputStream() method on your VirtualFile.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
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.
Remember to override getModificationStamp() in your VirtualFile implementation.
I don't get why it is not abstract anyway...