Devel/RCP(Rich Client Platform)
eclipse 4 rcp process dialog example
kogun82
2020. 9. 16. 14:05
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
try {
progressDialog.run(false, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
int workload = 100;
// Tell the user what you are doing
monitor.beginTask("Copying files", workload);
// Do your work
for (int i = 0; i < workload; i++) {
// Optionally add subtasks
monitor.subTask("Copying file " + (i + 1) + " of " + workload + "...");
Thread.sleep(2000);
// Tell the monitor that you successfully finished one item of "workload"-many
monitor.worked(1);
// Check if the user pressed "cancel"
if (monitor.isCanceled()) {
monitor.done();
return;
}
}
// You are done
monitor.done();
}
});
} catch (Exception e) {
e.printStackTrace();
}
반응형