http://stackoverflow.com/questions/12986912/using-progressmonitordialog-in-eclipse-4-properly

 public class Progress {
public static void main(String[] args)
{
// Create your new ProgressMonitorDialog with a IRunnableWithProgress
try {
// 10 is the workload, so in your case the number of files to copy
IRunnableWithProgress op = new YourThread(10);
new ProgressMonitorDialog(new Shell()).run(true, true, op);
} catch (InvocationTargetException ex) {
ex.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
} private static class YourThread implements IRunnableWithProgress
{
private int workload; public YourThread(int workload)
{
this.workload = workload;
} @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
// 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();
} }
}

转:ProgressMonitorDialog的更多相关文章

  1. 关于JFace中的进度条对话框(ProgressMonitorDialog类)

    在Windows操作系统中,最常用的进度条对话框就是文件复制时的弹出框,如果想让用户愉快的使用你开发 的软件,那么在执行某个较长时间的操作时候,就应该弹出一个进度条提示框,告诉用户程序正在做什么. 做 ...

  2. RCP:如何保存TaskList及如何获取TaskList

    如果我们在Eclipse RCP程序中添加TaskList View,用来管理Task或者TODO项,如下代码: PlatformUI.getWorkbench().getActiveWorkbenc ...

  3. swt,jface,rcp

    //swt-jface-rcp,基本结构:display类,shell类,组件:widget窗口控件,control控件,composites面板,button,label,text文本框,list列 ...

  4. Eclipse RCP中超长任务单线程,异步线程处理

    转自:http://www.blogjava.net/mydearvivian/articles/246028.html 在RCP程序中,常碰到某个线程执行时间比较很长的情况,若处理不好,用户体验度是 ...

  5. apache poi 读取xlsx并导出为json(没考虑xls)

    1.用到的jar包:fastjson-1.2.9.poi(poi-3.15.poi-ooxml-3.15.poi-ooxml-schemas-3.15.xmlbeans-2.6.0.commons-c ...

  6. unieap 导出文档错误

    java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalCon ...

随机推荐

  1. MS SQL 两种分页

    ------ row number ---------- ------ row number ---------- declare @pageSize int,@pageIndex int ; sel ...

  2. paper 114:Mahalanobis Distance(马氏距离)

    (from:http://en.wikipedia.org/wiki/Mahalanobis_distance) Mahalanobis distance In statistics, Mahalan ...

  3. c#常见的错误集合

    1:a>b>c是不合法的,是不是合法的呢? 2 优先级是这样的:算术>关系>逻辑>三目>赋值:位运算比较乱 这句话是对是错

  4. Cef 架构

    cef支持各种语言和多种操作系统.在设计的时候充分考虑了性能和易用性.cef核心功能提供了c和c++的接口.cef提供了和主程序之间的通信能力(利用 custom plugins, protocols ...

  5. Apache部署django项目

    在此之前,我们一直使用django的manage.py 的runserver 命令来运行django应用,但这只是我们的开发环境,当项目真正部署上线的时候这做就不可行了,必须将我们的项目部署到特定的w ...

  6. EditPlus 3.7.164 中文版(4月3日更新)

    新的版本汉化了之前无法汉化的部分内容,并修复了旧汉化版的部分问题. 欢迎下载新的翻译文件.

  7. Application Pool

  8. windows编程环境

    自行下载VS2010官方原版并破解你也可以从微软官方直接下载VS2010 正式版,然后自行破解.Microsoft Visual Studio 2010官方下载地址如下:页面:http://www.m ...

  9. C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0

    C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0

  10. iOS多线程同步锁

    在iOS中有几种方法来解决多线程访问同一个内存地址的互斥同步问题: 方法一,@synchronized(id anObject),(最简单的方法)会自动对参数对象加锁,保证临界区内的代码线程安全 @s ...