To be more precise I need to replace the default implementation:
public String getText(Object object) {
String label = ((NamedElement) object).getName();
return label == null || label.length() == 0 ? getString("_UI_NamedElement_type")
: getString("_UI_NamedElement_type") + " " + label;
}
by this one:
public String getText(Object object) {
String label = ((NamedElement) object).getName();
return label == null || label.length() == 0 ? getString("_UI_NamedElement_type")
: label.substring(0, 1).toUpperCase() + label.substring(1);
}
It can't be achived by changing of Label Feature property. The simplest approach is to change these methods manually and to mark them as @generated NOT.
However I try to alternate the implementation without changing the generated code.
I register a custom adapter factory:
<extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
<factory
uri="..."
class="...provider.CustomProductItemProviderAdapterFactory"
supportedTypes="org.eclipse.emf.edit.provider.IItemLabelProvider"/>
</extension>
Disable the default adapter factory in MyEditor.initializeEditingDomain() Because otherwise it overrides my custom adapter factory.
My custom adapter factory creates an item provider with a custom getText() method:
public Adapter adapt(Notifier notifier, Object type) {
if (notifier instanceof NamedElement && IItemLabelProvider.class.isAssignableFrom((Class<?>) type)) {
return createNamedElementAdapter();
}
return super.adapt(notifier, this);
}
It seems that it works. Object labels are created using this method.
But I get NPE at org.eclipse.emf.edit.ui.provider.ComposedImageDescriptor.getSize(ExtendedImageRegistry.java:407)
It seems that I broke an image provider for objects.
All this stuff is too tricky. I guess that my approach is wrong. And if I understood you write there is no a simple way to override getText()