in android/tooling/rib-intellij-plugin/src/main/kotlin/com/uber/intellij/plugin/android/rib/RibViewBrowser.kt [140:173]
override fun configureTree(tree: Tree) {
super.configureTree(tree)
tree.addFocusListener(
object : FocusListener {
override fun focusLost(e: FocusEvent?) {
hasFocus = false
}
override fun focusGained(e: FocusEvent?) {
hasFocus = true
notifySelectedViewChanged()
}
},
)
tree.addTreeSelectionListener { notifySelectedViewChanged() }
// by default, expand the entire tree, and select item if needed
ApplicationManager.getApplication().invokeLater {
expandAll()
if (model.selectedViewId.isNotEmpty() && this.model.ribNode.id == this.model.selectedRibId) {
val ribView: RibView =
RibHierarchyUtils.findRibViewRecursive(
this.model.rootRib.view,
UUID.fromString(model.selectedViewId),
)
?: return@invokeLater
selectionListener?.onSelectedViewChanged(ribView)
ApplicationManager.getApplication().invokeLater { selectById(model.selectedViewId) }
}
}
}