enhancement
major
minor
major
minor
major
#29620
TL Views: a tree node is never a link to where its object is displayed, although the display targets declare one
Problem
An object value displayed read-only is offered as a link wherever the application declares a display target (#29532) for its type: following it reveals the views the target names. That holds for table cells and for the read-only values of a form, and the developer documentation names the nodes of a <tree> among them - but a tree node is never a link, in any application.
Observed in the React demo (com.top_logic.demo.react, sidebar Baum-Demo), whose tree shows projects, their milestones and their tickets - all three types have a display target, and the very same objects ARE links in the tables of the application. Every node renders as
<span class="tlResourceCell"><span class="tlResourceLabel">M3</span></span>
instead of an anchor, and clicking one only selects the node.
Ursache
TreeElement builds its model out of DefaultTreeUINode`s wrapping the business object, and `ReactTreeControl hands the node to the content provider that renders the node's label:
{{{#!java control = _contentProvider.createControl(getReactContext(), node); }}}
The provider (MetaResourceControlProvider) creates a ReactResourceCellControl over that value with links enabled. The control then asks whether the value leads anywhere, and DisplayTargetNavigator.canShow answers false for everything that is not a TLObject:
{{{#!java if (!(value instanceof TLObject object)) {
return false;
} }}}
A tree node is no TLObject, so hasLink() is false for every node of every tree. The label is unaffected because the resource provider resolves a tree node to the label of its business object, which is why the defect shows only in the missing link.
Lösung
ReactTreeControl builds a node's content control over the business object the node stands for (TreeUIModel.getBusinessObject(node)) instead of the node, so that the same value decides the label and the link. The wrapping node stays the model of the tree and the key of the control's content cache; only what is handed to the content provider changes, so content providers never see tree nodes.
The designer tree of the view designer (DesignerTreeElement), which is the only other user of the control, renders the DesignTreeNode it is now handed directly; the listener that re-renders a node after its label was edited looks the tree node up in the displayed model, since the tree caches content controls by node.
Verified by tests in TestObjectLinks (a tree node standing for a displayed object is a link and shows the object's label; a node for an object displayed nowhere is plain) and in the React demo's tree: project, milestone and ticket nodes are anchors, following a milestone reveals the milestone tab of its project with the milestone selected, following a ticket opens its detail, and a click beside the label still only selects the node. The developer documentation of the object navigation (docs/faq/react-view-layer.md) states that a tree hands its node content provider the business object a node stands for.