【问题标题】:Read-only Properties view for Eclipse editorEclipse 编辑器的只读属性视图
【发布时间】:2012-03-05 06:12:56
【问题描述】:
我正在创建一个在文本编辑器中具有树视图的编辑器。我有一个附加的属性视图,以便在选择每个树项目时显示项目的属性。为此,每个树项都是一个实现 IPropertySource 的类。所以属性值是通过重写 IPropertySource 类的方法(如 getPropertyDescriptors、getPropertyValue、setPropertyValue 等)来获得的。
属性值显示正确。但是,我要求属性视图中的值是只读的。目前,这些名称是不可编辑的。但是在选择属性视图的某一行时,该属性的值是可编辑的。如何将属性视图的所有属性值设为只读(不可编辑)?
谢谢!
【问题讨论】:
标签:
eclipse
plugins
properties
【解决方案1】:
如果您使用来自 Eclipse 的标准属性表页面,则取决于 IPropertySource.getPropertyDescriptors 返回的 IPropertyDescriptor 实现是否以及如何在视图中编辑您的属性。
如果您查看IPropertyDescriptor 的JavaDoc,您可以看到以下内容:
Clients may implement this interface to provide specialized property
descriptors; however, there are standard implementations declared in this
package that take care of the most common cases:
* PropertyDescriptor - read-only property
* TextPropertyDescriptor - edits with a TextCellEditor
* CheckboxPropertyDescriptor - edits with a CheckboxCellEditor
* ComboBoxPropertyDescriptor - edits with a ComboBoxCellEditor
* ColorPropertyDescriptor - edits with a ColorCellEditor
因此,对于您的情况,返回 PropertyDescriptor 应该可以解决问题。