mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12: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() {
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user