Can I write a plugin that handles an archive (containing sources) as if it where extracted?
Hi there,
here is the idea.
I want to be able to add a odt-file (OpenDocument Text file http://en.wikipedia.org/wiki/OpenDocument) to my sources. The odt-file is a ZIP with file extension .odt.
It has the following structure:
filename.odt | +-- META-INF | | | +-- manifest.xml | +-- Thumbnails | | | +-- thumbnail.png | +-- Pictures | | | +-- 10000000000001E800000118B5A37F3F.png | +-- mimetype +-- content.xml +-- styles.xml +-- meta.xml +-- settings.xml
So my source tree should look like:src
|
+-- main
|
+-- templates
|
+ filename.odt
+ anotherFile.odt
Now here are my use cases/wishes:
- I want to be able to dive into filename.odt (similar like navigating through jars).
- I want to open e.g. the content.xml file in the editor.
- I want to change the context of the content.xml file
- I want to use the same IntelliLang feature as if I'm opening a "physical" xml file
Can you point me to some sample plugin code? Is this possible with the Open API?
Exciter:
- If I overwrite the odt with another file, I want to see the differences tracked down to the single files inside this archive
Thanks in advance, Leif
请先登录再写评论。
I'd say com.intellij.ide.projectView.TreeStructureProvider is what you are looking for.
Though I didn't use it myself.
You can have a look at the ui-designer plugin. It uses the treeStructureProvider extension point to group forms and their bound classes under a common parent node. In your case the odt is the parent node and the contents of the odt willl be the children.
It really seems like you could do most of this already. You can already browese Jar files in IntelliJ - but they are read-only.
All you would need to do, is to write a plugin to watch for edits to the read-only files in a jar, and then when one occurs, replace the virtual file associated with the document with a new copy of the file that you extract from the jar and add to the project.
At least, thats the first thing that came to mind when I read your question.
I even seen to recall that there was something that would automatically extract jar file content transparently - not sure what it was though