mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: HostTree.showMoreInfo
This commit is contained in:
@@ -54,6 +54,7 @@ class HostTree : JTree(), Disposable {
|
||||
editor.preferredSize = Dimension(220, 0)
|
||||
|
||||
setCellRenderer(object : DefaultXTreeCellRenderer() {
|
||||
private val properties get() = Database.getDatabase().properties
|
||||
override fun getTreeCellRendererComponent(
|
||||
tree: JTree,
|
||||
value: Any,
|
||||
@@ -65,28 +66,32 @@ class HostTree : JTree(), Disposable {
|
||||
): Component {
|
||||
val host = value as Host
|
||||
var text = host.name
|
||||
val color = if (sel) {
|
||||
if (this@HostTree.hasFocus()) {
|
||||
UIManager.getColor("textHighlightText")
|
||||
} else {
|
||||
this.foreground
|
||||
}
|
||||
} else {
|
||||
UIManager.getColor("textInactiveText")
|
||||
}
|
||||
|
||||
if (host.protocol == Protocol.SSH) {
|
||||
text = """
|
||||
// 是否显示更多信息
|
||||
if (properties.getString("HostTree.showMoreInfo", "false").toBoolean()) {
|
||||
val color = if (sel) {
|
||||
if (this@HostTree.hasFocus()) {
|
||||
UIManager.getColor("textHighlightText")
|
||||
} 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) {
|
||||
text = """
|
||||
} else if (host.protocol == Protocol.Serial) {
|
||||
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)
|
||||
@@ -338,6 +343,7 @@ class HostTree : JTree(), Disposable {
|
||||
return
|
||||
}
|
||||
|
||||
val properties = Database.getDatabase().properties
|
||||
val popupMenu = FlatPopupMenu()
|
||||
val newMenu = JMenu(I18n.getString("termora.welcome.contextmenu.new"))
|
||||
val newFolder = newMenu.add(I18n.getString("termora.welcome.contextmenu.new.folder"))
|
||||
@@ -355,6 +361,17 @@ class HostTree : JTree(), Disposable {
|
||||
popupMenu.addSeparator()
|
||||
popupMenu.add(newMenu)
|
||||
popupMenu.addSeparator()
|
||||
|
||||
val showMoreInfo = JCheckBoxMenuItem(I18n.getString("termora.welcome.contextmenu.show-more-info"))
|
||||
showMoreInfo.isSelected = properties.getString("HostTree.showMoreInfo", "false").toBoolean()
|
||||
showMoreInfo.addActionListener {
|
||||
properties.putString(
|
||||
"HostTree.showMoreInfo",
|
||||
showMoreInfo.isSelected.toString()
|
||||
)
|
||||
SwingUtilities.updateComponentTreeUI(this)
|
||||
}
|
||||
popupMenu.add(showMoreInfo)
|
||||
val property = popupMenu.add(I18n.getString("termora.welcome.contextmenu.property"))
|
||||
|
||||
open.addActionListener { openHosts(it, false) }
|
||||
|
||||
@@ -135,6 +135,7 @@ termora.welcome.contextmenu.new.folder=${termora.folder}
|
||||
termora.welcome.contextmenu.new.host=Host
|
||||
termora.welcome.contextmenu.new.folder.name=New Folder
|
||||
termora.welcome.contextmenu.property=Properties
|
||||
termora.welcome.contextmenu.show-more-info=Show more info
|
||||
|
||||
# New Host
|
||||
termora.new-host.title=Create a new host
|
||||
|
||||
@@ -123,6 +123,7 @@ termora.welcome.contextmenu.new.folder=文件夹
|
||||
termora.welcome.contextmenu.new.host=主机
|
||||
termora.welcome.contextmenu.new.folder.name=新建文件夹
|
||||
termora.welcome.contextmenu.property=属性
|
||||
termora.welcome.contextmenu.show-more-info=显示更多信息
|
||||
|
||||
# New Host
|
||||
termora.new-host.title=新建主机
|
||||
|
||||
@@ -124,6 +124,7 @@ termora.welcome.contextmenu.new.folder=${termora.folder}
|
||||
termora.welcome.contextmenu.new.host=主機
|
||||
termora.welcome.contextmenu.new.folder.name=新建資料夾
|
||||
termora.welcome.contextmenu.property=屬性
|
||||
termora.welcome.contextmenu.show-more-info=顯示更多信息
|
||||
|
||||
# New Host
|
||||
termora.new-host.title=新主機
|
||||
|
||||
Reference in New Issue
Block a user