View read-only properties for the Eclipse editor

I am creating an editor that has a tree view in a text editor. I have a property view attached to it, so when I select each element of the tree, the properties of the element are displayed. To do this, each element of the tree is a class that implements IPropertySource. Thus, property values ​​are obtained by overriding methods (such as getPropertyDescriptors, getPropertyValue, setPropertyValue, etc.) of the IPropertySource class. Property values ​​are displayed correctly. However, I need the values ​​in the property view to be read-only. Names are not currently editable. But when you select one of the lines representing the property, the value of this property is editable. How to make all property property values ​​read-only (not editable)?

Thanks!

+4
source share
1 answer

If you use the standard property sheet page from Eclipse, it depends on the implementation of IPropertyDescriptor returned by IPropertySource.getPropertyDescriptors , regardless of how or how your property is editable in the view.

If you look at the JavaDoc IPropertyDescriptor , you will 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 

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

+4
source

Source: https://habr.com/ru/post/1399720/


All Articles