how to open editor/viewers for arbitrary files

I've been using the StarTeam VCS plugin with great success and I've been trying to add a feature where I can view previous revisions of any file within IntelliJ. I realize the code analysis and some other features probably won't be available with files that aren't in the project sourcepath, so I tried to check out the previous revision (via ST API) to a temp directory, then open the file in an editor/viewer window.

I know that this should be possible because you can do File->Open File... in IntelliJ and open an arbitrary file in some directory (say temp directory). What I can't figure out is how to open the viewer for this temp file programmatically. I've tried creating a Document object with the contents of the previous revision and calling EditorFactory.createViewer() to show the file. This doesn't seem to do anything useful.

I've also tried creating a VirtualFile and OpenFileDescriptor from the file in the temp directory and then calling FileEditorManager.openFile(). If I remember correctly, this seems to throw some kind of exception complaining that the file is not underneath the project directory.

Any ideas?

1
1 comment
Avatar
Permanently deleted user

Hello,
My plugin use FileEditorManager.openFile

Just see source code for http://www.intellij.org/twiki/bin/view/Main/FileAssociations

The action for this logic is class ProjectFileServerListener.

Thanks

0

Please sign in to leave a comment.