mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
feat: show remark on node hover
This commit is contained in:
@@ -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() {
|
actionMap.put("copy", object : AnAction() {
|
||||||
override fun actionPerformed(evt: AnActionEvent) {
|
override fun actionPerformed(evt: AnActionEvent) {
|
||||||
toolkit.systemClipboard.setContents(StringSelection(StringUtils.EMPTY), null)
|
toolkit.systemClipboard.setContents(StringSelection(StringUtils.EMPTY), null)
|
||||||
@@ -193,6 +213,9 @@ class NewHostTree : SimpleTree(), Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
// 销毁
|
||||||
|
ToolTipManager.sharedInstance().unregisterComponent(this)
|
||||||
|
|
||||||
val name = super.getName()
|
val name = super.getName()
|
||||||
if (name.isNullOrBlank().not()) {
|
if (name.isNullOrBlank().not()) {
|
||||||
properties.putString("${name}.state", TreeUtils.saveExpansionState(this))
|
properties.putString("${name}.state", TreeUtils.saveExpansionState(this))
|
||||||
@@ -1151,4 +1174,4 @@ class NewHostTree : SimpleTree(), Disposable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user