I have some java code in a database and wants to write a plugin so that I can edit the code in IDEA directly from the database. I have managed to create a ProjectComponent that loads the code from the database but I can't figure out how to create an editor for the code.
It would be great to be able to use IDEA with all of its refactor options, code formating etc. to edit the code, so my problem is that I have a String object and wants an editor to edit the string with the usual IDEA features.
Since the code is loaded from a database I don't have a file on disk with the code, just a String with the code, and I haven't understood how I could create a VirtualFile with the code ( or if this is what I want to do? ).
Then I also want to get a notification about when the user tries to save or close the document so that I can save the code to the database, but that feels like a later problem since I cant even create a window to display the code at the moment.
I've tried a couple of things, but none of them has worked. For example:
EditorFactory ef = EditorFactory.getInstance();
String code = "//some java code";
Document d = ef.createDocument(code);
Editor e = ef.createEditor(d, myProject);
If a count the numbers of editors ( ef.getEditors().length ), I can see that I've created an editor, but nothing appears on the screen.
I've also tried some things with the FileEditorManager and PsiDocumentManager but that hasn't worked either.
PS I'm using IDEA 5.1.2
Thanks in advanced