minor
#27264
Selection components should not unpack one-element sets
Currently, Top-Logic’s approach is that in selection components (tl:TableComponent, tl:TreeComponent, tl:TreeTableComponent, and tl:GridComponent) that support multiple selections, single-element and empty selections are handled in a special way: Instead of a single-element set, the “one” element is written to the selection channel, and in the case of an empty selection, “null” is written.
Improvement
If the component supports single selection, getSelected() returns either the selected object or null if nothing is selected.
If the component supports multiple selection, getSelected() is always a collection, which may be empty if nothing is selected.
Code Migration
Components that use the selection of a tl:TableComponent, tl:TreeComponent, tl:TreeTableComponent, or tl:GridComponent with multiple selection as a model must be adapted, since the selection is now always a collection.
For example, a `tl:TransformLinkingByExpression` can be used here. From a `tl:CommandHandler` configuration
target="selection(<component>)"
becomes
<target class="com.top_logic.model.search.providers.TransformLinkingByExpression" input="selection(<component>)" > <function><![CDATA[selection -> if ($selection.size() <= 1, $selection.singleElement(), null)]]></function> </target>
Example
In the demo, under Technical Demo > Components > Tables and Trees, there are examples of selection components with multiple selection and single selection.
Test
TestTreeTableMultiSelection.script.xml, TestTreeMultiSelection.script.xml, TestTableMultiSelection.script.xml, TestGridMultiSelection.script.xml.