mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
feat: 在工具栏添加 SFTP 快速打开
This commit is contained in:
@@ -52,4 +52,9 @@ object Actions {
|
||||
* 终端日志记录
|
||||
*/
|
||||
const val TERMINAL_LOGGER = "TerminalLogAction"
|
||||
|
||||
/**
|
||||
* 打开 SFTP Tab Action
|
||||
*/
|
||||
const val SFTP = "SFTPAction"
|
||||
}
|
||||
@@ -260,17 +260,16 @@ class CustomizeToolBarDialog(
|
||||
removeWindowListener(this)
|
||||
|
||||
val allActions = toolbar.getAllActions().toMutableList()
|
||||
val shownActions = toolbar.getShownActions().filter { it.visible }
|
||||
.map { it.id }
|
||||
allActions.removeAll(shownActions)
|
||||
val shownActions = toolbar.getShownActions().associate { Pair(it.id, it.visible) }
|
||||
|
||||
for (action in allActions) {
|
||||
actionManager.getAction(action)?.let { leftList.model.addElement(ActionHolder(action, it)) }
|
||||
if (shownActions[action] == false) {
|
||||
actionManager.getAction(action)?.let { leftList.model.addElement(ActionHolder(action, it)) }
|
||||
} else {
|
||||
actionManager.getAction(action)?.let { rightList.model.addElement(ActionHolder(action, it)) }
|
||||
}
|
||||
}
|
||||
|
||||
for (action in shownActions) {
|
||||
actionManager.getAction(action)?.let { rightList.model.addElement(ActionHolder(action, it)) }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import app.termora.highlight.KeywordHighlightDialog
|
||||
import app.termora.keymgr.KeyManagerDialog
|
||||
import app.termora.macro.MacroAction
|
||||
import app.termora.tlog.TerminalLoggerAction
|
||||
import app.termora.transport.SFTPAction
|
||||
import com.formdev.flatlaf.FlatClientProperties
|
||||
import com.formdev.flatlaf.FlatLaf
|
||||
import com.formdev.flatlaf.extras.FlatDesktop
|
||||
@@ -205,6 +206,9 @@ class TermoraFrame : JFrame() {
|
||||
// 终端日志记录
|
||||
ActionManager.getInstance().addAction(Actions.TERMINAL_LOGGER, TerminalLoggerAction())
|
||||
|
||||
// SFTP
|
||||
ActionManager.getInstance().addAction(Actions.SFTP, SFTPAction())
|
||||
|
||||
// macro
|
||||
ActionManager.getInstance().addAction(Actions.MACRO, MacroAction())
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class TermoraToolBar(
|
||||
|
||||
fun getAllActions(): List<String> {
|
||||
return listOf(
|
||||
Actions.SFTP,
|
||||
Actions.TERMINAL_LOGGER,
|
||||
Actions.MACRO,
|
||||
Actions.KEYWORD_HIGHLIGHT,
|
||||
|
||||
@@ -7,11 +7,11 @@ import java.awt.event.ActionEvent
|
||||
import javax.swing.Icon
|
||||
|
||||
class QuickCommandFindEverywhereProvider : FindEverywhereProvider {
|
||||
|
||||
private val actionManager get() = ActionManager.getInstance()
|
||||
|
||||
override fun find(pattern: String): List<FindEverywhereResult> {
|
||||
val list = mutableListOf<FindEverywhereResult>()
|
||||
ActionManager.getInstance().getAction(Actions.ADD_HOST)?.let {
|
||||
actionManager?.let {
|
||||
list.add(CreateHostFindEverywhereResult())
|
||||
}
|
||||
|
||||
@@ -21,34 +21,21 @@ class QuickCommandFindEverywhereProvider : FindEverywhereProvider {
|
||||
Icons.terminal
|
||||
) {
|
||||
override fun actionPerformed(evt: ActionEvent) {
|
||||
ActionManager.getInstance().getAction(Actions.OPEN_HOST)
|
||||
?.actionPerformed(
|
||||
OpenHostActionEvent(
|
||||
this, Host(
|
||||
name = name,
|
||||
protocol = Protocol.Local
|
||||
)
|
||||
actionManager.getAction(Actions.OPEN_HOST)?.actionPerformed(
|
||||
OpenHostActionEvent(
|
||||
this, Host(
|
||||
name = name,
|
||||
protocol = Protocol.Local
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}))
|
||||
|
||||
// SFTP
|
||||
list.add(ActionFindEverywhereResult(object : AnAction("SFTP", Icons.fileTransfer) {
|
||||
override fun actionPerformed(evt: ActionEvent) {
|
||||
val terminalTabbedManager = Application.getService(TerminalTabbedManager::class)
|
||||
val tabs = terminalTabbedManager.getTerminalTabs()
|
||||
for (i in tabs.indices) {
|
||||
val tab = tabs[i]
|
||||
if (tab is SFTPTerminalTab) {
|
||||
terminalTabbedManager.setSelectedTerminalTab(tab)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 创建一个新的
|
||||
terminalTabbedManager.addTerminalTab(SFTPTerminalTab())
|
||||
}
|
||||
}))
|
||||
actionManager.getAction(Actions.SFTP)?.let {
|
||||
list.add(ActionFindEverywhereResult(it))
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
20
src/main/kotlin/app/termora/transport/SFTPAction.kt
Normal file
20
src/main/kotlin/app/termora/transport/SFTPAction.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package app.termora.transport
|
||||
|
||||
import app.termora.*
|
||||
import java.awt.event.ActionEvent
|
||||
|
||||
class SFTPAction : AnAction("SFTP", Icons.fileTransfer) {
|
||||
override fun actionPerformed(evt: ActionEvent) {
|
||||
val terminalTabbedManager = Application.getService(TerminalTabbedManager::class)
|
||||
val tabs = terminalTabbedManager.getTerminalTabs()
|
||||
for (tab in tabs) {
|
||||
if (tab is SFTPTerminalTab) {
|
||||
terminalTabbedManager.setSelectedTerminalTab(tab)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 创建一个新的
|
||||
terminalTabbedManager.addTerminalTab(SFTPTerminalTab())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user