diff --git a/src/main/kotlin/app/termora/tree/NewHostTree.kt b/src/main/kotlin/app/termora/tree/NewHostTree.kt index ef3fa15..d52d2ab 100644 --- a/src/main/kotlin/app/termora/tree/NewHostTree.kt +++ b/src/main/kotlin/app/termora/tree/NewHostTree.kt @@ -146,6 +146,26 @@ class NewHostTree : SimpleTree(), Disposable { } }) + // 开启 ToolTip 功能 + ToolTipManager.sharedInstance().registerComponent(this) + + // 设置鼠标移动提示 + addMouseMotionListener(object : java.awt.event.MouseMotionAdapter() { + override fun mouseMoved(e: MouseEvent) { + val path: TreePath? = getPathForLocation(e.x, e.y) + if (path != null) { + val node: HostTreeNode = path.lastPathComponent as HostTreeNode + if (node.host.remark.isNotEmpty()){ + toolTipText = node.host.remark + }else{ + toolTipText = null + } + } else { + toolTipText = null + } + } + }) + actionMap.put("copy", object : AnAction() { override fun actionPerformed(evt: AnActionEvent) { toolkit.systemClipboard.setContents(StringSelection(StringUtils.EMPTY), null) @@ -193,6 +213,9 @@ class NewHostTree : SimpleTree(), Disposable { } override fun dispose() { + // 销毁 + ToolTipManager.sharedInstance().unregisterComponent(this) + val name = super.getName() if (name.isNullOrBlank().not()) { properties.putString("${name}.state", TreeUtils.saveExpansionState(this)) @@ -1151,4 +1174,4 @@ class NewHostTree : SimpleTree(), Disposable { } -} \ No newline at end of file +}