|
Re: Custom LabelProvider for table column? [message #1748860 is a reply to message #1748845] |
Tue, 29 November 2016 07:37   |
Eclipse User |
|
|
|
Hi Johan,
so you want to customize the text displayed in the cells of the Body.
If you just want to display the type in addition of the name, maybe extending the class org.eclipse.papyrus.uml.nattable.provider.UMLTypedElementCellLabelProvider to cancel its behavior could help you. Nevertheless, I will give you the full informations here;
1. Some informations
The text displayed in the cells is returned by the method org.eclipse.papyrus.infra.nattable.provider.NattableTopLabelProvider.getBodyLabel(ILabelProviderCellContextElementWrapper, IConfigRegistry) which call this one: org.eclipse.papyrus.infra.nattable.provider.NattableTopLabelProvider.getLabel(ILabelProviderCellContextElementWrapper, IConfigRegistry, String), with these parameters :
- ILabelProviderCellContextElementWrapper : a wrapper owning a reference to the real cell element
- IConfigRegistry : the config registry of the table
- String : the context to use to get your label, in your case, it will be org.eclipse.papyrus.infra.nattable.utils.Constants.BODY_LABEL_PROVIDER_CONTEXT
2. How to change this text
You need to create a new class extending [b]AbstractNattableCellLabelProvider:
- accept(Object), the object will be a ILabelProviderCellContextElementWrapper
- getElementText(LabelProviderService, Object), here, it is your object
You can use as example the classes:
org.eclipse.papyrus.infra.nattable.provider.GenericCellLabelProvider and
org.eclipse.papyrus.uml.nattable.provider.UMLTypedElementCellLabelProvider
You need to register your class with the extension point called org.eclipse.papyrus.infra.services.labelprovider.labelProvider, with the context : org.eclipse.papyrus.infra.nattable.body.labelprovider and the good priority.
3. It should work.
Regards,
/Vincent Lorenzo
|
|
|
|
Re: Custom LabelProvider for table column? [message #1750153 is a reply to message #1749676] |
Fri, 16 December 2016 08:46  |
Eclipse User |
|
|
|
Hello Johan,
please found in attachment a sample plugin to override the label of the cell for a TypedElement. In addition, I set a snapshot of the result.
FYI, you can show all registered contribution for an extension point (it required toknow which plugin provides it), thank to the Plug-in Registry view (as snapshot too).
I hope it will allow you to fix your problem.
The warning in the plugin.xml for org.eclipse.papyrus.infra.nattable.body.labelprovider is 'normal'.
To avoid to impact all the tables, you need to override the accept method to check the type of the table (see example in attachment).
Regards,
--
Vincent.
|
|
|
Powered by
FUDForum. Page generated in 0.04447 seconds