newbie question. please help!!!

Hello to everyone,

I'm trying to develop a plugin to help me do my work better.
The plugin is a kind of version control plugin for some custom type sources. The sources are Java Script and some custom SQL type. These sources along with the history and version information resides in a database. I managed so far to create a new ToolWindow containing a tree view with my sources (categories->aplications->sources).
My problem for the moment is that I can't figure out how I can open these "files" in the editor. Let say for example using the plain text editor or the JS editor. I quoted "files" because they are not really local file system files. Those items in my tree come from a database.
I have tried creating my VirtualFile implementation and use it like this:

StarlimsVirtualFile starlimsVirtualFile = new StarlimsVirtualFile(item);
FileEditorManager.getInstance(project).openFile(starlimsVirtualFile, true);

but I get an exeption:

java.lang.IllegalArgumentException: file is not valid: com.starlims.idea.StarlimsVirtualFile@12ae739
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWithProviders(FileEditorManagerImpl.java:199)
at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.java:2)
at com.starlims.idea.StarlimsTreeView$1.mouseClicked(StarlimsTreeView.java:60)

I'm using Idea 6.0.4(build 6148) for this plugin development.

Please, somebody help me!

Thank you,

Daniel

3 comments
Comment actions Permalink

Common guys, nobody there with an idea. :)
I'd really appreciate any help or opinion.

Related to my StarlimsVirtualFile implementation I overridden the getFileType() method to return the "txt" FileType.

public FileType getFileType() {
return FileTypeManager.getInstance().getFileTypeByExtension("txt");
}

But this didn't help either.

Daniel

0
Comment actions Permalink

I think I'm confused... You had mentioned that you weren't actually dealing with physical files; is that true? If so, I don't think messing with file type extensions is going to get you anywhere.

It seems to me that the first area to look at is what you're doing inside you StarlimsVirtualFile constructor - how are you building that guy?

Just a guess - I'm just another plugin developer, not a JetBrains dude.

KurtC

0
Comment actions Permalink

Yes my "Virtual File System" is build from database records and the content of the items is extracted from database. I have a class StarlimsItem which represents a tree node in my JTree model. That class, for the leaf nodes contains also a byte[] with the content extracted from database. I use an instance of StarlimsItem to pass it to the StarlimsVirtualFile constructor.
My question is, this time, if anybody knows which are the reason, that can cause this code:

StarlimsItem item = ...;
StarlimsVirtualFile starlimsVirtualFile = new StarlimsVirtualFile(item);
FileEditorManager.getInstance(project).openFile(starlimsVirtualFile, true);

to throw this exception:

java.lang.IllegalArgumentException: file is not valid: com.starlims.idea.StarlimsVirtualFile@12ae739
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWithProviders(FileEditorManagerImpl.java:199)
at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.java:2)
at com.starlims.idea.StarlimsTreeView$1.mouseClicked(StarlimsTreeView.java:60)

Maybe some of the Jetbrains guys can look inside the code of FileEditorManagerImpl and tell me why this exception is thrown.

Thank you,

Daniel

0

Please sign in to leave a comment.