JFace中进度条的应用
???? 在项目使用进度条,定制特定功能的进度条的。必须使用的东东。
?
???? 在创建进度条对话框ProgressMonitorDialog,执行相关的run方法。
?
实现相关的IRunnableWithProgress的各种信息。
?
?
package com.vnvntrip.plugin.dev.views.custom;import java.lang.reflect.InvocationTargetException;import org.eclipse.core.runtime.IProgressMonitor;import org.eclipse.jface.dialogs.ProgressMonitorDialog;import org.eclipse.jface.operation.IRunnableWithProgress;import org.eclipse.swt.widgets.Shell;/** * 普通的进度条 * @author longgangbai * */public class OrdinaryProgress{ private Shell shell; public OrdinaryProgress(Shell parent) { this.shell=shell; } public void run(){try { new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress(){ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("generate", 30); for (int i = 0; i < 100; i++) {if(monitor.isCanceled()){ return ;}monitor.worked(1);Thread.sleep(50); } monitor.done(); } });} catch (InvocationTargetException e) {} catch (InterruptedException e) {} } }
?
?