Detail
#27264
Selection components should not unpack one-element sets
Currently, the philosophy in Top-Logic is that in selection components (tl:TableComponent, tl:TreeComponent, tl:TreeTableComponent and tl:GridComponent) with multiple selections, one-element and empty selections are treated specially: Instead of a one-element set, the "one" element and for an empty selection, "null" is written to the selection channel.
Improvement
If the component supports a single-selection, getSelected() is either the selected object or null if nothing is selected.
If the component supports multiple selection, getSelected() is always a collection, possibly empty if nothing is selected.
Code migration
Components that have the selection of a tl:TableComponent, tl:TreeComponent, tl:TreeTableComponent or tl:GridComponent with multiple selection as model must be adapted because the selection is now always a collection.
Here, for example, a tl:TransformLinkingByExpression can be used. 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>
Ex.
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.