mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
chore: improve contextmenu (#251)
This commit is contained in:
@@ -352,8 +352,10 @@ class HostTree : JTree(), Disposable {
|
||||
val newFolder = newMenu.add(I18n.getString("termora.welcome.contextmenu.new.folder"))
|
||||
val newHost = newMenu.add(I18n.getString("termora.welcome.contextmenu.new.host"))
|
||||
|
||||
val open = popupMenu.add(I18n.getString("termora.welcome.contextmenu.open"))
|
||||
val openWithSFTP = popupMenu.add(I18n.getString("termora.welcome.contextmenu.open-with-sftp"))
|
||||
val open = popupMenu.add(I18n.getString("termora.welcome.contextmenu.connect"))
|
||||
val openWith = popupMenu.add(JMenu(I18n.getString("termora.welcome.contextmenu.connect-with"))) as JMenu
|
||||
val openWithSFTP = openWith.add("SFTP")
|
||||
val openWithSFTPCommand = openWith.add(I18n.getString("termora.tabbed.contextmenu.sftp-command"))
|
||||
val openInNewWindow = popupMenu.add(I18n.getString("termora.welcome.contextmenu.open-in-new-window"))
|
||||
popupMenu.addSeparator()
|
||||
val copy = popupMenu.add(I18n.getString("termora.welcome.contextmenu.copy"))
|
||||
@@ -380,10 +382,13 @@ class HostTree : JTree(), Disposable {
|
||||
|
||||
open.addActionListener { openHosts(it, false) }
|
||||
openWithSFTP.addActionListener { openWithSFTP(it) }
|
||||
openWithSFTPCommand.addActionListener { openWithSFTPCommand(it) }
|
||||
openInNewWindow.addActionListener { openHosts(it, true) }
|
||||
|
||||
// 如果选中了 SSH 服务器,那么才启用
|
||||
openWithSFTP.isEnabled = getSelectionNodes().any { it.protocol == Protocol.SSH }
|
||||
openWithSFTPCommand.isEnabled = openWithSFTP.isEnabled
|
||||
openWith.isEnabled = openWith.menuComponents.any { it is JMenuItem && it.isEnabled }
|
||||
|
||||
rename.addActionListener {
|
||||
startEditingAtPath(TreePath(model.getPathToRoot(lastHost)))
|
||||
@@ -523,6 +528,15 @@ class HostTree : JTree(), Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private fun openWithSFTPCommand(evt: EventObject) {
|
||||
val nodes = getSelectionNodes().filter { it.protocol == Protocol.SSH }
|
||||
if (nodes.isEmpty()) return
|
||||
val action = ActionManager.getInstance().getAction(OpenHostAction.OPEN_HOST) ?: return
|
||||
for (host in nodes) {
|
||||
action.actionPerformed(OpenHostActionEvent(this, host.copy(protocol = Protocol.SFTPPty), evt))
|
||||
}
|
||||
}
|
||||
|
||||
fun expandNode(node: Host, including: Boolean = false) {
|
||||
expandPath(TreePath(model.getPathToRoot(node)))
|
||||
if (including) {
|
||||
|
||||
@@ -128,8 +128,8 @@ termora.find-everywhere.double-shift-deprecated-instead=${termora.find-everywher
|
||||
|
||||
# Welcome
|
||||
termora.welcome.my-hosts=My hosts
|
||||
termora.welcome.contextmenu.open=Open
|
||||
termora.welcome.contextmenu.open-with-sftp=Open with SFTP
|
||||
termora.welcome.contextmenu.connect=Connect
|
||||
termora.welcome.contextmenu.connect-with=Connect with
|
||||
termora.welcome.contextmenu.open-in-new-window=${termora.tabbed.contextmenu.open-in-new-window}
|
||||
termora.welcome.contextmenu.copy=${termora.copy}
|
||||
termora.welcome.contextmenu.remove=${termora.remove}
|
||||
|
||||
@@ -118,8 +118,8 @@ termora.settings.sftp.edit-command=编辑命令
|
||||
|
||||
# Welcome
|
||||
termora.welcome.my-hosts=我的主机
|
||||
termora.welcome.contextmenu.open=打开
|
||||
termora.welcome.contextmenu.open-with-sftp=使用 SFTP 打开
|
||||
termora.welcome.contextmenu.connect=连接
|
||||
termora.welcome.contextmenu.connect-with=连接到
|
||||
termora.welcome.contextmenu.copy=${termora.copy}
|
||||
termora.welcome.contextmenu.remove=${termora.remove}
|
||||
termora.welcome.contextmenu.rename=重命名
|
||||
|
||||
@@ -117,8 +117,8 @@ termora.settings.about.termora=<html><b>${termora.title}</b> ({0}) 是一個跨
|
||||
|
||||
# Welcome
|
||||
termora.welcome.my-hosts=我的主機
|
||||
termora.welcome.contextmenu.open=打開
|
||||
termora.welcome.contextmenu.open-with-sftp=使用 SFTP 打開
|
||||
termora.welcome.contextmenu.connect=連接
|
||||
termora.welcome.contextmenu.connect-with=連接到
|
||||
termora.welcome.contextmenu.copy=複製
|
||||
termora.welcome.contextmenu.remove=${termora.remove}
|
||||
termora.welcome.contextmenu.rename=重新命名
|
||||
|
||||
Reference in New Issue
Block a user