feat: show remark on node hover

This commit is contained in:
imblowsnow
2025-09-18 09:04:59 +08:00
committed by GitHub
parent 613a1ca78a
commit f73e7f4214

View File

@@ -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 {
}
}
}