All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.simiacryptus.skyenet.AgentPatterns.kt Maven / Gradle / Ivy

There is a newer version: 1.2.21
Show newest version
package com.simiacryptus.skyenet

import com.simiacryptus.skyenet.webui.application.ApplicationInterface
import java.util.*

object AgentPatterns {

    fun displayMapInTabs(
        map: Map,
        ui: ApplicationInterface? = null,
        split: Boolean = map.entries.map { it.value.length + it.key.length }.sum() > 10000
    ): String = if (split && ui != null) {
        val tasks = map.entries.map { (key, value) ->
            key to ui.newTask(root = false)
        }.toMap()
        ui.socketManager?.scheduledThreadPoolExecutor?.schedule({
            tasks.forEach { (key, task) ->
                task.complete(map[key]!!)
            }
        }, 200, java.util.concurrent.TimeUnit.MILLISECONDS)
        displayMapInTabs(tasks.mapValues { it.value.placeholder }, ui = ui, split = false)
    } else {
        """
${ map.keys.joinToString("\n") { key -> """""" } }
${ map.entries.withIndex().joinToString("\n") { (idx, t) -> val (key, value) = t """
"" } }" data-tab="$key"> ${value/*.indent(" ")*/}
""" } }
""" } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy