我一直想知道properties
方法中的参数TreeViewer#update(Object element, String[] properties)
。这些是什么?他们指的是什么?我不确定里面有什么String[]
- 是否有预定义的常量可以使用?或者这些是我的列标题的名称?还有什么?
我找不到任何使用的例子,update()
它没有null
作为properties
. Javadoc 对我没有什么帮助。
谢谢!
我一直想知道properties
方法中的参数TreeViewer#update(Object element, String[] properties)
。这些是什么?他们指的是什么?我不确定里面有什么String[]
- 是否有预定义的常量可以使用?或者这些是我的列标题的名称?还有什么?
我找不到任何使用的例子,update()
它没有null
作为properties
. Javadoc 对我没有什么帮助。
谢谢!
They are conveniences for the viewer's label provider to let it know what properties of the model changed. If the property that changed doesn't affect the display of the item in the view, then the provider can elect to not do anything by implementing the isLabelProperty() method to only return true when an interesting property changes.
If there are no logical properties on the item that changed to trigger the update call, then just pass null or an empty array.
这篇eclipse.org 文章在“响应更改”一章中解释了这些属性的用途:如果您想要完全更新树项的标签或只是标签的文本或标签的图像,您可以微调。它没有详细说明属性的外观。她,我想,如果javadocs还不够的话,你必须直接研究源代码。
TreeViewer 是 SWT 类 Tree 的“增强”版本。所以我猜,这里的属性应该是指TreeItem中存储的属性(可以通过调用setData(String, Object)来设置)。