码迷,mamicode.com
首页 > 编程语言 > 详细

[Java][RCP] 记 ProgressView的使用

时间:2016-05-17 00:33:44      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

进度条效果图

技术分享

As a part of the process of decoupling Eclipse services from workbench, the Progress View has been extracted to a separate plug-in and refactored in order to be available for Eclipse4 applications.

ProgressView已经作为一个独立的plug-in存在了

Currently, the Progress View plug-in is not shipped with Eclipse SDK packages, but it can be installed from update site: https://hudson.eclipse.org/platform/job/eclipse4-progress-view/lastSuccessfulBuild/artifact/releng/org.eclipse.e4.ui.progress.update/target/repository/

Step1: Add plug-in

URL is :

https://hudson.eclipse.org/platform/job/eclipse4-progress-view/lastSuccessfulBuild/artifact/releng/org.eclipse.e4.ui.progress.update/target/repository/

技术分享

 

Step2: 新建Eclipse RCP项目ProgressViewModel

技术分享

 

技术分享

这里只是测试ProgressView,check Create Simple Content

技术分享

Step 3: 在项目中引入plug-in

技术分享

Step 4:添加一个Add-ons,Class URI绑定为bundleclass://org.eclipse.e4.ui.progress/org.eclipse.e4.ui.progress.ProgressViewAddon(Find不到的话就直接写上去)

让它随项目的启动而初始化

技术分享

Step5: 添加一个Part, URI绑定为:bundleclass://org.eclipse.e4.ui.progress/org.eclipse.e4.ui.progress.ProgressView(Find不到的话就直接写上去),让它显示进度条

技术分享

 

Step6: 实例化一个Job,Code as follows,至于Job应该研究一下(http://www.vogella.com/tutorials/EclipseJobs/article.html#prerequisite

button.addSelectionListener(new SelectionListener() {
            
            @Override
            public void widgetSelected(SelectionEvent arg0) {
                Job job = Job.create("Runing Job", monitor -> {
                    SubMonitor subMonitor = SubMonitor.convert(monitor);

                    subMonitor.beginTask("Beging Task...", 5000);

                    for (int i = 0; i < 50; i++) {
                        try {
                            Thread.sleep(500L);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        subMonitor.worked(100);
                    }

                    return Status.OK_STATUS;
                });

                job.schedule();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent arg0) {}
        });

效果如下:

技术分享

[Java][RCP] 记 ProgressView的使用

标签:

原文地址:http://www.cnblogs.com/chenyongblog/p/5499901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!