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) {
}
}
} 相关推荐
laisean 2020-11-11
zhangjie 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
CARBON 2020-10-20
JohnYork 2020-10-16
xiaonamylove 2020-10-16
Julyth 2020-10-16