Eclipse平台中“进度条对话框”(ProgressMonitorDialog)的简单实现
2006-03-29 15:13
543 查看
运行环境:Eclipse 3.0.x
下面是的方法实现了一个简单的“进度条对话框”:
private byte[] progressMonitorDialogTest(final String bhContent, final String root, final String userName, final String pwd, final String payload) throws Exception {
final byte[][] result = new byte[1][];
IRunnableWithProgress pro = new IRunnableWithProgress () {
//实现接口中的execute方法:
protected void execute(IProgressMonitor monitor) throws CoreException {
//具体的业务逻辑:
result[0] = invokeDLL(bhContent, root, userName, pwd, payload);
}
//实现接口中的run方法,该方法是一个同步方法:
public synchronized final void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
//总的工作量
int totalWork = IProgressMonitor.UNKNOWN;
monitor.beginTask("A Progress monitor dialog example...", totalWork);
if (result[0] == null)
totalWork = 400;
monitor.worked(totalWork);
//执行业务逻辑:
execute(monitor);
if (result[0] != null) {
totalWork = 1000;
}
else {
totalWork = 700;
}
monitor.worked(totalWork);
}
catch (CoreException e) {
throw new InvocationTargetException(e);
}
catch (OperationCanceledException e) {
throw new InterruptedException(e.getMessage());
}
finally {
monitor.done();
}
}
};
try {
//调用:
new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()).run(true, false, pro);
}
catch (Exception e) {
e.printStackTrace();
}
return result[0];
}
下面是的方法实现了一个简单的“进度条对话框”:
private byte[] progressMonitorDialogTest(final String bhContent, final String root, final String userName, final String pwd, final String payload) throws Exception {
final byte[][] result = new byte[1][];
IRunnableWithProgress pro = new IRunnableWithProgress () {
//实现接口中的execute方法:
protected void execute(IProgressMonitor monitor) throws CoreException {
//具体的业务逻辑:
result[0] = invokeDLL(bhContent, root, userName, pwd, payload);
}
//实现接口中的run方法,该方法是一个同步方法:
public synchronized final void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
//总的工作量
int totalWork = IProgressMonitor.UNKNOWN;
monitor.beginTask("A Progress monitor dialog example...", totalWork);
if (result[0] == null)
totalWork = 400;
monitor.worked(totalWork);
//执行业务逻辑:
execute(monitor);
if (result[0] != null) {
totalWork = 1000;
}
else {
totalWork = 700;
}
monitor.worked(totalWork);
}
catch (CoreException e) {
throw new InvocationTargetException(e);
}
catch (OperationCanceledException e) {
throw new InterruptedException(e.getMessage());
}
finally {
monitor.done();
}
}
};
try {
//调用:
new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()).run(true, false, pro);
}
catch (Exception e) {
e.printStackTrace();
}
return result[0];
}
相关文章推荐
- Eclipse 插件开发 ProgressMonitorDialog 进度条显示的简单应用
- Dialog对话框之ProgressDialog(进度条),DatePickerDialog,Toast
- android应用开发揭秘之examples_04_24(ProgressDialog对话框中的进度条)
- ProgressDialog+Thread实现弹出进度条数据异步加载(配有效果图)
- SDK编程:任务栏TaskBar与对话框Dialog实现一个简单功能
- ProgressDialog+Thread实现弹出进度条数据异步加载(配有效果图)
- (Android实战)ProgressDialog+Thread实现弹出进度条数据异步加载(配有效果图)
- 使用CXTPDialogBase简单实现resize对话框
- Eclipse平台中“MessageDialog”消息对话框的简单实现
- QT中可以用QProgressBar或着QProgressDialog来实现进度条
- Android自定义对话框Dialog的简单实现
- (Android实战)ProgressDialog+Thread实现弹出进度条数据异步加载(配有效果图)
- 显示InputDialog输入对话框实现对用户输入的英文单词进行简单处理
- Android安卓用Dialog对话框简单并且完美实现popupWindow底部弹出效果,有动画效果
- Dialog详解(包括进度条、PopupWindow、自定义view、自定义样式的对话框)
- Android之Dialog进度条对话框
- 用Dialog实现列表对话框
- handler实现自定义对话框(Dialog)的数据定时(TimerTask)更新
- 实现自定义的dialog(类似QQ点击退出后弹出的对话框)
- 用开源项目circular progress button实现有进度条的Button