I have some problems when I create my first idea plugin Follow
I'm new to idea from eclipse. I want to create an idea plugin to convert some haml-like files into html files. I built one on eclipse, but I don't know how to do it in idea.
What the plugin will do?
1. When a haml file be created, the plugin will convert it to a html file in background
2. When a haml file be modified, it will be converted to a html file in background
3. When a haml file be deleted, the corresponding html file will be deleted too
My questions:
This kind of plugin on eclipse can be called a builder. I just create a class which implement an builder interface, it will get all the changed files. Then conversion work will be performed in background automatically.
But now it's idea:
1. Is there a similar "builder" as eclipse?
2. How to get the changed files? I can do this:
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
@Override
public void contentsChanged(VirtualFileEvent event) {
// do something
}
});
It works, but not efficient.
I found this article says:The most efficient way to listen to VFS events is to implement the BulkFileListener interface and to subscribe with it to the VirtualFileManager.VFS_CHANGES topic.
But I can't find any example to implement it.
3. How to perform this conversion in background? Is it automatically? Or do I need to create a daemon thread?
4. Is there any similar plugin I can study from? I searched, but not found.
Please sign in to leave a comment.
Hello freewind,
No, there is no direct equivalent in the IntelliJ IDEA API.
>> The most efficient way to listen to VFS events is to implement the
>> BulkFileListener interface and to subscribe with it to the
>> VirtualFileManager.VFS_CHANGES topic.
>>
You can find several simple examples in the Community Edition sources. Here's
one:
http://git.jetbrains.org/?p=idea/community.git;a=blob;f=platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java;hb=HEAD
Use ApplicationManager.getApplication().runOnPooledThread() to run a task
in a background thread.
I don't know of any existing plugin that does something similar.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thank you very much, it's very helpful!