将TableViewer绑定到由其他几个模型扩展的模型

时间:2015-03-11 14:16:40

标签: java data-binding swt jface eclipse-databinding

我有一个班级File,正在由另外两个班级CopyFileDeleteFile进行扩展。

class File {
    private String filePath;
    /** Setters and getters **/
}

class CopyFile {
    private String destinationPath;
    /**setters and getters**/
}

class DeleteFile {
} 

现在我正在尝试将其绑定到表查看器:

ViewerSupport.bind(tableViewer, new WritableList(realm,
            fileDetailsList, File.class),PojoProperties.values(File.class,
                    new String[] { "filePath","destinationPath"}));

我希望当文件是CopyFilenull""的实例时,如果它是DeleteFile的实例,则显示destinationPath。

但是当我运行它时,它会抛出一个错误:

  

在类File

中找不到名为destinationPath的属性

请帮我解决这个问题并告诉我如何在继承的情况下实现DataBinding。

1 个答案:

答案 0 :(得分:0)

Please note that when you bind File.class the property won't be found since it uses reflection and the property belongs to CopyFile.class. binding is done with Beans or POJOs in order to observe their details.