转: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 ...
随机推荐
- Windows Phone 十、数据绑定
数据绑定:是一种 XAML 和后台数据交互的方式(桥梁) 通过后台进行数据绑定 <Grid> <TextBox x:Name="txtHello" Text=&q ...
- rdesktop的使用
整个地球都知道rdesktop,有了它,我们可以从Solaris或者Linux使用Windows,当然Windows要开启Windows Terminal Service.虽然也有基于GTK+的tsc ...
- 07_编写天气预报和手机归属地的WebService
<s:element ref="s:schema" /> <s:any /> <s:any minOccurs="2" maxOc ...
- h5视频上传之前端视频压缩研究
今天领导接到一个h5上传手机视频的需求,主要是要看用户在这个视频中有没有完成某个任务,比如投篮进了几个球. 但是由于手机拍摄的视频文件大小有点大,直接上传的话,用户流量顶不住,而且特别耗时,在这样的情 ...
- 理解timestamp
大多数资料都说timestamp表示自从1970-1-1 00:00:00开始到现在的秒数,一般称为epoch time,却忽略了时区的概念.其实,不同时区记录timesamp的基准时间是不一样的,比 ...
- 数据流 in redux
之前用学过的react和react-router写了个单页面应用,但写完后总感觉还欠缺点什么,怎么说呢,就是感觉在数据流的控制上被框架约束的厉害,很不自由,比如兄弟组件间的通信就很不方便.然后才了解到 ...
- DEV皮肤颜色获取
Skin GridSkin = GridSkins.GetSkin(UserLookAndFeel.Default.ActiveLookAndFeel); evenColor = GridSkin[G ...
- 用ssh整合时,用sessionfactory的getCurrentSession()获取不到session
在用ssh整合时,一开始用的是getCurrentSession(),获取当前线程上的session,但是总是抛异常,不能获取. 后来用sessionfactory的openSession(),但是, ...
- windows环境安装和配置Apache-Tomcat7.0
转自:http://blog.sina.com.cn/s/blog_7c35df9b010111sh.html 说明: Tomcat Manager的用户名和密码可以到"Tomcat安装目录 ...
- [C#] Control.Invoke方法和跨线程访问控件(转载)
转载前,在网上找了好多INVOKE方法的文章,就这个看着还可以,明白了大概,以后再深用的时候再研究 ,废话少说上转载(连转载都说的这么有气势,哈哈) 在设计界面时,我们经常需要将一些需要时间才能完 ...