Looking for examples of ProgressWindow usage


I'm working on a code metrics plugin with a UI modelled on IDEA's inspection panel and inspection toolwindow. The user request metrics be calculated by clicking a menu item, a dialog pops up to allow him to further specify his request (which metrics, what parameters), it churns a while, and a tool-window comes up with his answers neatly formatted and available for graphing. Metrics calculation is not particularly quick, however (~10-20 java files per second)so during the "churns for a while" part of the process, it would be nice if a progress panel would come up, allowing cancellation or backgrounding of the metrics calculations. I would like to use the com.intellij.progress.util.ProgressWindow, so as to keep the L&F of my plugin as close as possible to the inspection panel. Sadly, it doesn't look like ProgressWindow is really "open", and I can't find any documentation on it at all. Does anyone have or know of any code samples using the ProgressWindow?

--Dave Griffith

1 comment

Hi!
This snippet works:

The following snippet works:

Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);
if (project == null)
return;
Runnable process = new Runnable() {
@Override
public void run() {
double i = 0;
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
while (i <= 9) {
System.out.println(i);
indicator.setFraction(i++ / 10);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
indicator.stop();
}
};
ProgressManager.getInstance().runProcessWithProgressSynchronously(process, "123",true,project);
0

Please sign in to leave a comment.