새소식

Devel/RCP(Rich Client Platform)

eclipse 4 rcp process dialog example

  • -
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();
}

 

Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.