If you create a new type `A` without a supertype and give it a `name` attribute, instances of this type are represented in some places by the value in their `name` attribute (e.g., in references that point to type `A`). In other places, the display is `AttributedWrapper(type:my.app:A, id: GenericObject:3848, name: A3)`, for example, in the title of the context menu for an object of type A and in tooltips.
- Interestingly, the problem seems to disappear after restarting the application.
- The problem also does not seem to occur all the time.
Analysis
When the problem occurs, inconsistent `ResourceProvider ` and `LabelProvider` instances are registered for the newly created type. The reference display uses the `tl:ResourceProvider`, whereas the title display in the context menu and the name display in the tooltip use the ` LabelProvider`.
The problem occurs as follows: After restarting the application, the LabelProviderService caches are empty to the extent that only the directly configured Type->LabelProvider mappings are entered. For the problem to occur, the first domain object for which a label is requested must be a new object from a grid.
A Grid New Object is treated as a (transient) domain object, but it does indeed have a model type (the type that is currently being instantiated). In this case, the type of the Grid New Object is the newly created model type 'A' (see test case description). No configured label provider is defined for this model type. Therefore, the search for a label provider falls back on the Java class hierarchy. However, no label provider is found there either, since a label provider is only stored for `com.top_logic.knowledge.wrap.AbstractWrapper `, and the Grid-New-Object does not derive from `AbstractWrapper`. Consequently, the ` DefaultLabelProvider` is found and subsequently registered in the cache for the newly created model type. If a real object of type `A` is then to be rendered, the `DefaultLabelProvider` is found in the cache. If a LabelProvider for a real `A` object had been requested first , the LabelProvider registered for `AbstractWrapper —"com.top_logic.knowledge.gui.WrapperResourceProvider" —would have been found via the Java class hierarchy.
Test
Note: This problem only occurs if you strictly follow this sequence:
- Create a new app.
- Define a new type A.
- Assign a name attribute (` name `) to the type.
- Switch to the instances view for A.
- Create a new row in the grid; do not save or apply it.
- Display the context menu for the new row.
- Fill in the values and save.
- Give the demo type a reference to itself.
- Create two instances, a1 and a2, of A.
- Havea1 reference a2.
- Display the tooltip for the reference value.