override fun modify()

in jetbrains-core/src/software/aws/toolkits/jetbrains/services/dynamic/explorer/DynamicResourceTreeStructureProvider.kt [11:35]


    override fun modify(parent: AbstractTreeNode<*>, children: MutableCollection<AbstractTreeNode<*>>): MutableCollection<AbstractTreeNode<*>> {
        if (parent is OtherResourcesNode) {
            val list = children.toMutableList()
            // Forces the filter node to the start of the list
            val index = list.indexOfFirst { it is DynamicResourceSelectorNode }
            if (index > 0) {
                list.add(0, list.removeAt(index))
            }

            return list
        }

        if (parent !is AwsExplorerRootNode) {
            return children
        }

        val list = children.toMutableList()
        // Forces the other resources node to the end of the list
        val index = list.indexOfFirst { it is OtherResourcesNode }
        if (index >= 0) {
            list.add(list.removeAt(index))
        }

        return list
    }