Progress Bar with Write Action
Hi,
I searched the forum but could not find an answer. I am doing a Write Action and would like to display it's progress. Is there any API in IDEA that will allow me to do this? I tried to do it as Task.Modal but it still was executed not on UI thread.
The action is downloading from the Internet so it is potentially long and involves saving downloaded files on Virtual File System - which is a write operation.
Thanks in advance,
Misha
Please sign in to leave a comment.
Hello Misha,
No, write actions always run on the UI thread and cannot display any progress.
The correct way to implement this is to perform the download without taking
either a read or a write action, show the progress in a usual way, save the
downloaded contents to disk using java.io APIs, and then perform a VFS refresh
inside a write action (this is fast so it doesn't need a progress indicator).
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks Dmitry,
I considered what you propose as an option but I do not know IDEA VFS that well and I thought that it may handle internally cases that are not trivial to handle with Java I/O, like write permissions or non-local storage. Anyway, thanks a lot, I will do exactly what you propose.
Best regards,
Misha