【问题标题】:how to bind Eclipse RCP Table View to other thread data如何将 Eclipse RCP 表视图绑定到其他线程数据
【发布时间】:2018-03-29 19:15:14
【问题描述】:

我刚刚开始使用 Eclipse RCP。 我使用 TableViewer 和 WritableList 创建了 Eclipse RCP View 以从其他线程获取数据。 但我看不到任何变化。我只需要显示其他线程正在管理的 List 的内容。

public class View extends ViewPart {
private TableViewer viewer; 
private WritableList input;

我也会出错,

org.eclipse.core.runtime.AssertionFailedException: assertion failed: Getter called outside realm of observable org.eclipse.core.databinding.observable.list.WritableList

我知道什么是 UI 线程。我只是不知道怎么写。请帮忙举个例子。

更新。没有解决,因为时间不够,缺少好的和重点突出的教程。

【问题讨论】:

    标签: multithreading data-binding eclipse-plugin eclipse-rcp


    【解决方案1】:

    我的代码也收到了此错误消息。 数据绑定 observables (WritableList, WritableValue...) 继承自 ChangeManager,它提供 ChangeManager#getRealm 并且领域有 Realm#exec。在提供给exec 的runnable 中,操作在正确的线程中运行。

    此行导致错误(Getter 在 observable 之外调用):

    WritableValue value = getEditor().getWritableValue();
    System.out.println(((RcpEditorModel) value.getValue()).getNumber());
    

    这阻止了异常:

    WritableValue value = getEditor().getWritableValue();
    value.getRealm().exec(() -> System.out.println(((RcpEditorModel) value.getValue()).getNumber()));
    

    同样适用于WritableList,因为它也继承自ChangeManager

    【讨论】:

      猜你喜欢
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多