Eclipse编辑器的只读“属性"视图 [英] Read-only Properties view for Eclipse editor

查看:222
本文介绍了Eclipse编辑器的只读“属性"视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个在文本编辑器中具有树视图的编辑器.我附加了一个属性视图,以便在选择每个树项目时显示该项目的属性.为此,每个树项都是一个实现IPropertySource的类.因此,属性值是通过覆盖IPropertySource类的方法(如getPropertyDescriptors,getPropertyValue,setPropertyValue等)获得的. 属性值显示正确.但是,我要求属性视图中的值是只读的.当前,名称不可编辑.但是在选择属性视图的行之一时,该属性的值是可编辑的.如何使属性视图的所有属性值均为只读(不可编辑)?

I am creating an editor that has a tree view in a text Editor. I have a properties view attached to it so that on selection of each tree item, the properties of the item are displayed. For this each tree item is a class that implements IPropertySource. So the property values are obtained by overriding the methods (like getPropertyDescriptors, getPropertyValue, setPropertyValue and so on) of the IPropertySource class. The property values are displayed correctly. However, I require the values in properties view to be read-only. Currently, the names are non-editable. But on selecting one of the rows of the property view, the value of that property is editable. How do I make all values of properties of the properties view read-only (non-editable)?

谢谢!

推荐答案

如果您使用的是Eclipse的标准属性表页面,则取决于IPropertySource.getPropertyDescriptors返回的IPropertyDescriptor实现,以及是否以及如何在其中编辑属性.风景.

If you are using the standard property sheet page from Eclipse, it depends on the IPropertyDescriptor implementation returned by IPropertySource.getPropertyDescriptors whether and how your property is editable in the view.

如果您查看IPropertyDescriptor的JavaDoc,则可以看到以下内容:

If you have a look at the JavaDoc of IPropertyDescriptor, you can see the following:

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应该可以解决问题.

So for your case returning the PropertyDescriptor should do the trick.

这篇关于Eclipse编辑器的只读“属性"视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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