Eclipse插件:一旦作业完成,如何更新视图 [英] Eclipse plug-in: how to update a view once a Job is complete

查看:250
本文介绍了Eclipse插件:一旦作业完成,如何更新视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我要在一个Job类中显示这些数组,结果视图,我创建了一个表和2列,每个数组一个。



如何引用视图并在其结尾处显示这些数组运行方法(在Job类中)?



即使你不能帮我解答,如果有人可以指点我的方向,我会很高兴,因为我没有理念。我唯一可以想到的是事件处理,但我也不太了解。

  class RunnerJob extends Job {
protected IStatus run(IProgressMonitor monitor){
//做某些东西
double [] col1 = someStuff1();
double [] col2 = someStuff2();

//在结果视图中显示?
}
}

根据Suraj Chandran的回答,这是代码我用于引用视图的静态方法,

  display.syncExec(
new Runnable(){
public void run(){
try {
PlatformUI.getWorkbench()。getActiveWorkbenchWindow()。getActivePage()。showView(ResultsView.ID);
} catch(PartInitException e){
e.printStackTrace();
}
ResultsView.update(< object with value>);
}
});


解决方案

在您的视图类中有一个静态方法,如getInstance ()将返回引用给你的对象。一旦你拥有对象,你可以在其中设置数组。


The run method in my Job class, does some stuff (the details are irrelevant) and outputs 2 arrays of doubles.

I want to display these arrays in a results view which I have created with a Table and 2 columns, one for each array.

How can I reference the view and display these arrays in it at the end of the run method (in the Job class)?

Even if you cannot help me with the answer, I would be happy if someone can point me in some direction because I have no idea. The only thing I could think of was event handling but I don't know very much about that either.

class RunnerJob extends Job {
     protected IStatus run(IProgressMonitor monitor) {
          //does some stuff
          double[] col1 = someStuff1();
          double[] col2 = someStuff2();

          //display in results view?
  }
}

Based on Suraj Chandran's answer, this is the code I used to reference a view's static method,

display.syncExec(
    new Runnable() {
       public void run(){
           try { 
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ResultsView.ID);
           } catch (PartInitException e) {
                e.printStackTrace();
             }
                 ResultsView.update(<object with values>);
             }
     });

解决方案

In your view class have a static method something like getInstance() that would return reference to you view object. Once you have the object you can set the arrays in it.

这篇关于Eclipse插件:一旦作业完成,如何更新视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆