Swt/Jface進度條(Eclipse Plug-in)
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
if(monitor == null)
monitor = new NullProgressMonitor();
doSth(monitor);
} finally {
monitor.done();
}
}
};
try {
new ProgressMonitorDialog(shell).run(true, true, runnable);
} catch (InterruptedException e) {
} catch (InvocationTargetException e) {
}
private void doSth(IProgressMonitor monitor){
monitor.beginTask("TaskName", 200);
//Task1
monitor.worked(100);
//Task2
monitor.worked(100);
}