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)
|
editor.preferredSize = Dimension(220, 0)
|
||||||
|
|
||||||
setCellRenderer(object : DefaultXTreeCellRenderer() {
|
setCellRenderer(object : DefaultXTreeCellRenderer() {
|
||||||
|
private val properties get() = Database.getDatabase().properties
|
||||||
override fun getTreeCellRendererComponent(
|
override fun getTreeCellRendererComponent(
|
||||||
tree: JTree,
|
tree: JTree,
|
||||||
value: Any,
|
value: Any,
|
||||||
@@ -65,28 +66,32 @@ class HostTree : JTree(), Disposable {
|
|||||||
): Component {
|
): Component {
|
||||||
val host = value as Host
|
val host = value as Host
|
||||||
var text = host.name
|
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}
|
<html>${host.name}
|
||||||
|
|
||||||
<font color=rgb(${color.red},${color.green},${color.blue})>${host.username}@${host.host}</font></html>
|
<font color=rgb(${color.red},${color.green},${color.blue})>${host.username}@${host.host}</font></html>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
} else if (host.protocol == Protocol.Serial) {
|
} else if (host.protocol == Protocol.Serial) {
|
||||||
text = """
|
text = """
|
||||||
<html>${host.name}
|
<html>${host.name}
|
||||||
|
|
||||||
<font color=rgb(${color.red},${color.green},${color.blue})>${host.options.serialComm.port}</font></html>
|
<font color=rgb(${color.red},${color.green},${color.blue})>${host.options.serialComm.port}</font></html>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val c = super.getTreeCellRendererComponent(tree, text, sel, expanded, leaf, row, hasFocus)
|
val c = super.getTreeCellRendererComponent(tree, text, sel, expanded, leaf, row, hasFocus)
|
||||||
@@ -338,6 +343,7 @@ class HostTree : JTree(), Disposable {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val properties = Database.getDatabase().properties
|
||||||
val popupMenu = FlatPopupMenu()
|
val popupMenu = FlatPopupMenu()
|
||||||
val newMenu = JMenu(I18n.getString("termora.welcome.contextmenu.new"))
|
val newMenu = JMenu(I18n.getString("termora.welcome.contextmenu.new"))
|
||||||
val newFolder = newMenu.add(I18n.getString("termora.welcome.contextmenu.new.folder"))
|
val newFolder = newMenu.add(I18n.getString("termora.welcome.contextmenu.new.folder"))
|
||||||
@@ -355,6 +361,17 @@ class HostTree : JTree(), Disposable {
|
|||||||
popupMenu.addSeparator()
|
popupMenu.addSeparator()
|
||||||
popupMenu.add(newMenu)
|
popupMenu.add(newMenu)
|
||||||
popupMenu.addSeparator()
|
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"))
|
val property = popupMenu.add(I18n.getString("termora.welcome.contextmenu.property"))
|
||||||
|
|
||||||
open.addActionListener { openHosts(it, false) }
|
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.host=Host
|
||||||
termora.welcome.contextmenu.new.folder.name=New Folder
|
termora.welcome.contextmenu.new.folder.name=New Folder
|
||||||
termora.welcome.contextmenu.property=Properties
|
termora.welcome.contextmenu.property=Properties
|
||||||
|
termora.welcome.contextmenu.show-more-info=Show more info
|
||||||
|
|
||||||
# New Host
|
# New Host
|
||||||
termora.new-host.title=Create a 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.host=主机
|
||||||
termora.welcome.contextmenu.new.folder.name=新建文件夹
|
termora.welcome.contextmenu.new.folder.name=新建文件夹
|
||||||
termora.welcome.contextmenu.property=属性
|
termora.welcome.contextmenu.property=属性
|
||||||
|
termora.welcome.contextmenu.show-more-info=显示更多信息
|
||||||
|
|
||||||
# New Host
|
# New Host
|
||||||
termora.new-host.title=新建主机
|
termora.new-host.title=新建主机
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ termora.welcome.contextmenu.new.folder=${termora.folder}
|
|||||||
termora.welcome.contextmenu.new.host=主機
|
termora.welcome.contextmenu.new.host=主機
|
||||||
termora.welcome.contextmenu.new.folder.name=新建資料夾
|
termora.welcome.contextmenu.new.folder.name=新建資料夾
|
||||||
termora.welcome.contextmenu.property=屬性
|
termora.welcome.contextmenu.property=屬性
|
||||||
|
termora.welcome.contextmenu.show-more-info=顯示更多信息
|
||||||
|
|
||||||
# New Host
|
# New Host
|
||||||
termora.new-host.title=新主機
|
termora.new-host.title=新主機
|
||||||
|
|||||||
Reference in New Issue
Block a user