Showing progress monitor [message #190065] |
Thu, 29 May 2008 12:19 |
Eclipse User |
|
|
|
Originally posted by: novak.igor.gmail.com
Hi!
I define progress monitor as following:
"
AbstractTransactionalCommand command = new
AbstractTransactionalCommand(...){
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
monitor.beginTask("Updating model", 100);
doStuff(monitor);
monitor.done(); return CommandResult.newOKCommandResult();
}
};
Shell shell =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShel l();
ProgressMonitorPart progressMonitor = new ProgressMonitorPart(shell, null);
OperationHistoryFactory.getOperationHistory().execute(comman d,
progressMonitor, null);
"
but the progress monitor is not shown.
How to define a progress monitor to be shown in doExecuteWithResult or in
my doStuff method?
P.S. This is my third post of the same subject, I always get answer to my
questions, except this one ... should this question be in some other forum?
Thanks in advance, Igor Novak
|
|
|
|
Re: Showing progress monitor [message #190276 is a reply to message #190065] |
Fri, 30 May 2008 11:55 |
Eclipse User |
|
|
|
Originally posted by: jan.herriger.gmx.de
Hi Igor,
following opens a JFace dialog with progress bar:
ProgressMonitorDialog pmd = new ProgressMonitorDialog(myShell);
pmd.setCancelable(true);
pmd.create();
IProgressMonitor monitor = pmd.getProgressMonitor();
try {
pmd.run(true, true,
new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
int steps = 100
monitor.beginTask("My Task", steps);
while (steps >0)
{
if (monitor.isCanceled()) {
//do something or just break loop...
}
monitor.subTask("My Subtask");
//do some work...
monitor.worked(1);
steps--;
}
}
}
);
}
catch (InvocationTargetException ex1) {...}
catch (InterruptedException ex2) {...}
if (monitor.isCanceled()) {...}
Regards,
Jan
|
|
|
Powered by
FUDForum. Page generated in 0.02763 seconds