Page 1 of 1

Multiple CustomAttributeValueEditor

Posted: Fri Mar 19, 2021 7:25 pm
by cedporter
I have implemented a CustomAttributeValueEditor for one attribute, and following the example in the SDF project sample, I am able to use it in our framework. Maybe I am misunderstanding the use case of this class, but I don't immediately see how to add additional CustomAttributeValueEditors for other attributes in the extension bundle. The overridden method (createCustomAttributeValueEditor) appears to only accept one. Is there a way to have several CustomAttributeValueEditors in a single extension bundle?

Re: Multiple CustomAttributeValueEditor

Posted: Mon Mar 22, 2021 9:56 am
by Radu
Hi,

Whenever an attribute value is edited, the method "ro.sync.ecss.extensions.api.ExtensionsBundle.createCustomAttributeValueEditor(boolean)" should be called and you can provide your own CustomAttributeValueEditor implementation on it as you probably already do.
Then the method "CustomAttributeValueEditor.shouldHandleAttribute(EditedAttribute, CustomAttributeValueEditingContext)" is called in your CustomAttributeValueEditor implementation providing you with an "ro.sync.ecss.extensions.api.EditedAttribute" interface from which you can obtain the name and current value of the edited attribute. So depending on the details in the received "EditedAttribute" interface you decide if the attribute name is interesting for you or not. Then you receive the callback "CustomAttributeValueEditor.getAttributeValue(EditedAttribute, Object)" again with the "EditedAttribute" interface allowing you to edit the attribute in any number of ways depending on its name.

Regards,
Radu

Re: Multiple CustomAttributeValueEditor

Posted: Mon Mar 22, 2021 3:24 pm
by cedporter
Thanks, I realized this was the approach I should use over the weekend. Will do so.