WriteActions and ProgressIndicator

Sorry I'm asking all these questions at once, but I have some loose ends to tie up so I can finish my plugin. I've already been at it it all day now, trying to fix some things that I expected to be really simple, but each and every one of them seems to takes HOURS :(

Does anyone have a proper code-sample of altering a bunch of PsiClasses while showing a ProgressIndicator? I've been searching the OpenAPI docs (which are mostly empty) and this forum (either the solutions provided don't work anymore or the questions are not fully answered).
After about 5 hours of not getting any further I'm getting rather annoyed. I mean.... how hard can it be to just iterate over some object and alter them?

It seems that every way I can find, that allows me to get a ProgressIndicator, requires a seperate Runnable, which means the Thread is no longer the SwingDispatchThread. When I use runWriteAction I cannot seem to get a ProgressIndicator to show up. When does ProgressManager.getInstance().getProgressIndicator() exactly return a ProgressIndicator?
It does after calling runProcessWithProgressSynchronously, but I can't use that, since it requires a seperate Runnable, which is not executed in the SwingDispatchThread?

I'm sure it must be really simple and looking at all those past requests for help on this subject, I find it hard to believe there's still no proper code-example or documentation for this, but I really can't seem to find any. I also haven't been able to find plugins that perform write-actions while showing a ProgressIndicator and have sourcecode available.

So if anyone can help me out, I would really appreciate it.

7 comments
Comment actions Permalink

The reason why you can't find an example is unfortunately very simple: It's just not possible to show any progress for WriteActions due to IDEA's threading model. See http://www.jetbrains.net/jira/browse/IDEABKL-2756 and its relatives.

Sascha

0
Comment actions Permalink

Arghh! That does explain it indeed. Just voted on this issue to be fixed.

Thanks.

0
Comment actions Permalink

Take a look at the source code to my Copyright plugin. I show a progress indicator while changing lots of files.

Go to http://www.intellij.org/twiki/bin/view/Main/CopyrightPlugin

Enjoy,
Rick

0
Comment actions Permalink

Actually I just checked and realized I'm being bit by the same issue. My progress bar appears initially but after it goes away is when all the real work is being done. Oh well.

0
Comment actions Permalink

Hi Rick,

thanks anyway. For the plugin as well... I use the Copyright plugin all the time, it's great!

- Onno

0
Comment actions Permalink

This is exactly what I want to do - is it still true that this can't be done? I see that the issue you cite is still open but a few of its dependent issues have been resolved, is there now a way to do this? I was trying to do this today, and managed to get either a progress bar and an exception about not being in the event thread, or no progress bar and my task executed. I'd love a way to do this...

Thanks,
Colin

0

Please sign in to leave a comment.