转:ProgressMonitorDialog
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的更多相关文章
- 关于JFace中的进度条对话框(ProgressMonitorDialog类)
在Windows操作系统中,最常用的进度条对话框就是文件复制时的弹出框,如果想让用户愉快的使用你开发 的软件,那么在执行某个较长时间的操作时候,就应该弹出一个进度条提示框,告诉用户程序正在做什么. 做 ...
- RCP:如何保存TaskList及如何获取TaskList
如果我们在Eclipse RCP程序中添加TaskList View,用来管理Task或者TODO项,如下代码: PlatformUI.getWorkbench().getActiveWorkbenc ...
- swt,jface,rcp
//swt-jface-rcp,基本结构:display类,shell类,组件:widget窗口控件,control控件,composites面板,button,label,text文本框,list列 ...
- Eclipse RCP中超长任务单线程,异步线程处理
转自:http://www.blogjava.net/mydearvivian/articles/246028.html 在RCP程序中,常碰到某个线程执行时间比较很长的情况,若处理不好,用户体验度是 ...
- 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 ...
- unieap 导出文档错误
java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalCon ...
随机推荐
- js事件监听/鼠标滚轮/行为/冒泡/键盘的兼容性写法
addEvent:function(el,type,fn,capture) { if (window.addEventListener) { if (type === "mousewheel ...
- Bare Medal on BCM2835 and BCM2836
A few days ago, I have tried to write bare medal program but failed. Now I find that the main mistak ...
- 调用线程无法访问此对象,因为另一个线程拥有该对象 [c# wpf定时器程序报的错误]
WPF:Dispatcher.Invoke 方法,只有在其上创建 Dispatcher 的线程才可以直接访问DispatcherObject.若要从不同于在其上创建 DispatcherObject ...
- 【C解毒】缘木求鱼
见:[C解毒]缘木求鱼
- Hiho coder 1236 2015 北京网络赛 Score
五维偏序..一开始被吓到了,后来知道了一种BITSET分块的方法,感觉非常不错. 呆马: #include <iostream> #include <cstdio> #incl ...
- heartbeat
http://www.bubuko.com/infodetail-1174857.html http://www.cnblogs.com/zhanjindong/p/3618055.html http ...
- Python基础操作-函数
本节内容 1. 函数基本语法及特性2. 参数与局部变量3. 返回值4.递归5.高阶函数 1.函数基本语法及特性函数是什么? 函数一词来源于数学,但编程中的「函数」概念,与数学中的函数是有很大不同的,具 ...
- winfrom 文字滚动
winfrom 文字滚动 http://www.codeproject.com/Articles/6913/Creating-a-professional-looking-GDI-drawn-cust ...
- php如何在某个时间上加一天?一小时? 时间加减
<?php date_default_timezone_set('PRC'); //默认时区 echo "今天:",date("Y-m-d",time() ...
- centos6.x开机卡死
问题描述: centos6.x开机卡死在进度条处 远程登录,查看系统日志,看看卡在哪儿 通过远程连接,tail -fn 20 /var/log/messages 发现报错: init: prefdm ...