mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
feat: HostTree shows more information (#203)
This commit is contained in:
@@ -64,13 +64,37 @@ class HostTree : JTree(), Disposable {
|
|||||||
hasFocus: Boolean
|
hasFocus: Boolean
|
||||||
): Component {
|
): Component {
|
||||||
val host = value as Host
|
val host = value as Host
|
||||||
val c = super.getTreeCellRendererComponent(tree, host, sel, expanded, leaf, row, hasFocus)
|
var text = host.name
|
||||||
if (host.protocol == Protocol.Folder) {
|
val color = if (sel) {
|
||||||
icon = if (expanded) FlatTreeOpenIcon() else FlatTreeClosedIcon()
|
if (this@HostTree.hasFocus()) {
|
||||||
} else if (host.protocol == Protocol.SSH || host.protocol == Protocol.Local) {
|
UIManager.getColor("textHighlightText")
|
||||||
icon = if (sel && this@HostTree.hasFocus()) Icons.terminal.dark else Icons.terminal
|
} else {
|
||||||
|
this.foreground
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UIManager.getColor("textInactiveText")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host.protocol == Protocol.SSH) {
|
||||||
|
text = """
|
||||||
|
<html>${host.name}
|
||||||
|
|
||||||
|
<font color=rgb(${color.red},${color.green},${color.blue})>${host.username}@${host.host}</font></html>
|
||||||
|
""".trimIndent()
|
||||||
} else if (host.protocol == Protocol.Serial) {
|
} else if (host.protocol == Protocol.Serial) {
|
||||||
icon = if (sel && this@HostTree.hasFocus()) Icons.plugin.dark else Icons.plugin
|
text = """
|
||||||
|
<html>${host.name}
|
||||||
|
|
||||||
|
<font color=rgb(${color.red},${color.green},${color.blue})>${host.options.serialComm.port}</font></html>
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
val c = super.getTreeCellRendererComponent(tree, text, sel, expanded, leaf, row, hasFocus)
|
||||||
|
|
||||||
|
icon = when (host.protocol) {
|
||||||
|
Protocol.Folder -> if (expanded) FlatTreeOpenIcon() else FlatTreeClosedIcon()
|
||||||
|
Protocol.SSH, Protocol.Local -> if (sel && this@HostTree.hasFocus()) Icons.terminal.dark else Icons.terminal
|
||||||
|
Protocol.Serial -> if (sel && this@HostTree.hasFocus()) Icons.plugin.dark else Icons.plugin
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user