diff --git a/src/main/kotlin/app/termora/HostTree.kt b/src/main/kotlin/app/termora/HostTree.kt
index 588fdbf..510a9f4 100644
--- a/src/main/kotlin/app/termora/HostTree.kt
+++ b/src/main/kotlin/app/termora/HostTree.kt
@@ -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 = """
${host.name}
${host.username}@${host.host}
""".trimIndent()
- } else if (host.protocol == Protocol.Serial) {
- text = """
+ } else if (host.protocol == Protocol.Serial) {
+ text = """
${host.name}
${host.options.serialComm.port}
""".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) }
diff --git a/src/main/resources/i18n/messages.properties b/src/main/resources/i18n/messages.properties
index 1e5d3cd..6a1296d 100644
--- a/src/main/resources/i18n/messages.properties
+++ b/src/main/resources/i18n/messages.properties
@@ -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
diff --git a/src/main/resources/i18n/messages_zh_CN.properties b/src/main/resources/i18n/messages_zh_CN.properties
index f80974a..8b84678 100644
--- a/src/main/resources/i18n/messages_zh_CN.properties
+++ b/src/main/resources/i18n/messages_zh_CN.properties
@@ -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=新建主机
diff --git a/src/main/resources/i18n/messages_zh_TW.properties b/src/main/resources/i18n/messages_zh_TW.properties
index 90db016..cf92110 100644
--- a/src/main/resources/i18n/messages_zh_TW.properties
+++ b/src/main/resources/i18n/messages_zh_TW.properties
@@ -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=新主機