Exception trying to open editor programmatically

Hi the appended exception occurs executing the following lines of code inside a plugin's action:



What am I doing wrong here? (tVirtualFile is not null)
What is the correct way to open an editor for a given file?

1 comment
Comment actions Permalink

Hello Frank,

FB> Hi the appended exception occurs executing the following lines of
FB> code inside a plugin's action:
FB>
FB> VirtualFileManager.getInstance().findFileByUrl( FB> "file://C:/Dokumente und FB> Einstellungen/frb/IdeaProjects/OpenWithDefaultApplication/META-INF/p FB> lugin.xml" FB> ); FB> Project tProject = FB> ProjectManager.getInstance().getDefaultProject(); FB> final FileEditorManager tManager = FB> FileEditorManager.getInstance(tProject); FB> tManager.openFile(tVirtualFile, true); FB> ]]>
FB> What am I doing wrong here? (tVirtualFile is not null) What is the
FB> correct way to open an editor for a given file?

The exception happens because you open the file in the default project. The
default project does not have any UI components, so it cannot be used for
opening editors. You need to open the file in a real project.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Please sign in to leave a comment.