major
#28694
Description of model parts as formatted text (rich text)
Attributes (as well as types and modules) can be assigned a description in the Model Editor. This description is displayed as a tooltip—in the Model Editor, as a tooltip for the field label in instance forms, and as a tooltip for a table column header.
Tooltips are HTML. However, the description was simply a multi-line text field and was inserted unchanged into the tooltip HTML. If it contained special XML characters (e.g., <`, `>, &):
this resulted in invalid HTML, and the tooltip could no longer be displayed at all:
Solution
The description of a model part is now formatted text and is edited using the WYSIWYG HTML editor. This ensures that it is converted into a valid, safe format upon saving, rather than having to be processed each time it is displayed:
- InternationalizedDescription, Internationalized, and ScriptParameter provide the description as an HtmlResKey. The existing HtmlResKeyEditor is registered for this value type—the same mechanism used by ScriptConfiguration. Editing thus takes place without additional annotation and without depending on the WYSIWYG module.
- The editor generates valid HTML and validates it with SafeHTML upon saving. Special characters entered as text are masked in the process.
- All display locations insert the saved HTML text unchanged. This ensures that the tooltip for the table column header (Column) is also correct, without requiring custom code there.
In addition, the language-specific storage of the name and description of a model part (TLMetaModelUtil) has been standardized:
- Each language is read and saved without a fallback. A value entered in only one language is no longer copied to the other languages—where it could not be distinguished from a genuine translation—but is resolved via the resource fallback only when displayed.
- Empty translations are deleted: A value that is empty in all languages is removed as if it had never been set.
- Missing languages are filled in only when automatic translation is enabled, and this is done by actually translating an entered value rather than by copying it.
Migration
Application code: Description is an `HtmlResKey`
`InternationalizedDescription.getDescription() ` and `setDescription() ` work with `HtmlResKey ` instead of `ResKey`. This also applies to the overriding declarations in `Internationalized ` and `ScriptParameter`. Application code that programmatically sets or reads the description of a model part must be adapted:
{{{#!java // Set: Wrap ResKey in an HtmlResKey. config.setDescription(new DefaultHtmlResKey(descriptionKey));
// Read the underlying ResKey. HtmlResKey description = config.getDescription(); ResKey descriptionKey = description == null ? null : ((DefaultHtmlResKey) description).content();
// Display as HTML. HTMLFragment tooltip = description.getHtml(); }}}
The content of a description set in this way must be valid HTML. Plain text containing special characters (<`, `>, &`) must be escaped beforehand (`TagUtil.encodeXML`) — unlike when entering data via the editor, no one handles this for programmatically set values.
Data: No data migration required
The configuration binding of HtmlResKey (DefaultHtmlResKey.ValueBinding) delegates to ResKey.ValueBinding and thus uses the same storage format. Descriptions that have already been saved—including those from ScriptParameter —are loaded unchanged.
Existing descriptions with special characters
Legacy data is not automatically converted: A description saved as plain text that contains <`, `> or & remains invalid HTML, and its tooltip remains incorrect until it is edited again. Such descriptions must be opened once in the Model Editor and saved again; the editor will convert them to the safe format during this process. The previous workaround—manually escaping the special characters in the description—remains valid but is no longer necessary.
Scripted Tests
Scripted tests that populate or verify the description field of a model part now target the structured HTML editor instead of a simple text field (see the changes to TestAttributeI18N and TestResourceAttribute).