0

I'm trying to use ILabelDecorators to decorate icons in the TableViewer.

I use two-column table to show properties of some model object. The first column displays the property name, the second column it the property value.

Some objects in the second column may have icons and I want these icons decorated.

The number of rows in the table is not constant and depends on the kind of the model.

The problem is that the content provider for the TableViewer assumed to provide the 'row model' objects, so I have to use some containers to pack both property name and value.

Then it comes to decorating, Eclipse uses these containers, but not their 'value' parts, to select the appropriate decorators, and to pass as the argument to the decorate() procedure.

As the result, decoration code are never called, because the class of these containers (I use simple Object array) does not match any classes declared in the enablement sections of the decorator elements in the plugin.xml.

Moreover, even if I do not restrict the decorators by classes, these containers are passed to the decorate() procedure in all my decorators, so I have to make all decorators know about these containers existence, which is quite weird.

At last, I have found some solution, I use an IAdapterFactory object to convert containers to their values. But it seem an overkill a bit.

Does anyone know more simple solutions?

Vladimir
  • 447
  • 5
  • 16
  • 1
    You need to show us the relevant code. – greg-449 Mar 24 '15 at 20:40
  • greg-449, I've updated the case description, please, take a look at it. – Vladimir Mar 25 '15 at 19:49
  • If you just want text decorations `StyledCellLabelProvider` is an alternative to decorators. You might also want to look at `ILightweightLabelDecorator` which puts less load on the UI thread. – greg-449 Mar 25 '15 at 20:10
  • No I need to decorate icons, so I use DecoratingStyledCellLabelProvider. It does not solve the aforementioned problem with the TableViewer model. – Vladimir Mar 26 '15 at 12:11

0 Answers0