mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
feat: detecting SFTP program (#241)
This commit is contained in:
@@ -26,6 +26,18 @@ class SFTPPtyTerminalTab(windowScope: WindowScope, host: Host) : PtyHostTerminal
|
||||
private var sshSession: ClientSession? = null
|
||||
private var lastPasswordReporterDataListener: PasswordReporterDataListener? = null
|
||||
|
||||
companion object {
|
||||
val canSupports by lazy {
|
||||
val process = if (SystemInfo.isWindows) {
|
||||
ProcessBuilder("cmd.exe", "/c", "where", "sftp1").start()
|
||||
} else {
|
||||
ProcessBuilder("which", "sftp1").start()
|
||||
}
|
||||
process.waitFor()
|
||||
return@lazy process.exitValue() == 0
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun openPtyConnector(): PtyConnector {
|
||||
|
||||
|
||||
|
||||
@@ -18,11 +18,8 @@ import java.awt.event.MouseAdapter
|
||||
import java.awt.event.MouseEvent
|
||||
import java.beans.PropertyChangeListener
|
||||
import java.util.*
|
||||
import javax.swing.Icon
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.*
|
||||
import javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT
|
||||
import javax.swing.SwingUtilities
|
||||
import kotlin.math.min
|
||||
|
||||
class TerminalTabbed(
|
||||
@@ -243,8 +240,17 @@ class TerminalTabbed(
|
||||
popupMenu.addSeparator()
|
||||
val sftpCommand = popupMenu.add(I18n.getString("termora.tabbed.contextmenu.sftp-command"))
|
||||
sftpCommand.addActionListener {
|
||||
actionManager.getAction(OpenHostAction.OPEN_HOST)
|
||||
?.actionPerformed(OpenHostActionEvent(this, tab.host.copy(protocol = Protocol.SFTPPty), it))
|
||||
if (SFTPPtyTerminalTab.canSupports) {
|
||||
actionManager.getAction(OpenHostAction.OPEN_HOST)
|
||||
?.actionPerformed(OpenHostActionEvent(this, tab.host.copy(protocol = Protocol.SFTPPty), it))
|
||||
} else {
|
||||
OptionPane.showMessageDialog(
|
||||
SwingUtilities.getWindowAncestor(this),
|
||||
I18n.getString("termora.tabbed.contextmenu.sftp-not-install"),
|
||||
messageType = JOptionPane.ERROR_MESSAGE
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,13 @@ class OpenHostAction : AnAction() {
|
||||
val terminalTabbedManager = evt.getData(DataProviders.TerminalTabbedManager) ?: return
|
||||
val windowScope = evt.getData(DataProviders.WindowScope) ?: return
|
||||
|
||||
// 如果不支持 SFTP 那么不处理这个响应
|
||||
if (evt.host.protocol == Protocol.SFTPPty) {
|
||||
if (!SFTPPtyTerminalTab.canSupports) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
val tab = when (evt.host.protocol) {
|
||||
Protocol.SSH -> SSHTerminalTab(windowScope, evt.host)
|
||||
Protocol.Serial -> SerialTerminalTab(windowScope, evt.host)
|
||||
|
||||
@@ -207,6 +207,7 @@ termora.keymgr.ssh-copy-id.end=End of public key copying
|
||||
# Tabbed
|
||||
termora.tabbed.contextmenu.rename=Rename
|
||||
termora.tabbed.contextmenu.sftp-command=SFTP Command
|
||||
termora.tabbed.contextmenu.sftp-not-install=SFTP programme not found, please install and try again
|
||||
termora.tabbed.contextmenu.clone=Clone
|
||||
termora.tabbed.contextmenu.open-in-new-window=Open in New Window
|
||||
termora.tabbed.contextmenu.close=Close
|
||||
|
||||
@@ -199,6 +199,7 @@ termora.tools.multiple=将命令发送到所有会话
|
||||
# Tabbed
|
||||
termora.tabbed.contextmenu.rename=重命名
|
||||
termora.tabbed.contextmenu.sftp-command=SFTP 终端
|
||||
termora.tabbed.contextmenu.sftp-not-install=没有找到 SFTP 程序,请安装后重试
|
||||
termora.tabbed.contextmenu.clone=克隆
|
||||
termora.tabbed.contextmenu.open-in-new-window=在新窗口打开
|
||||
termora.tabbed.contextmenu.close=关闭
|
||||
|
||||
@@ -195,6 +195,7 @@ termora.tools.multiple=將指令傳送到所有會話
|
||||
# Tabbed
|
||||
termora.tabbed.contextmenu.rename=重新命名
|
||||
termora.tabbed.contextmenu.sftp-command=SFTP 終端
|
||||
termora.tabbed.contextmenu.sftp-not-install=沒有找到 SFTP 程序,請安裝後重試
|
||||
termora.tabbed.contextmenu.clone=克隆
|
||||
termora.tabbed.contextmenu.open-in-new-window=在新視窗打開
|
||||
termora.tabbed.contextmenu.close=關閉
|
||||
|
||||
Reference in New Issue
Block a user