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"
|
const val TERMINAL_LOGGER = "TerminalLogAction"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开 SFTP Tab Action
|
||||||
|
*/
|
||||||
|
const val SFTP = "SFTPAction"
|
||||||
}
|
}
|
||||||
@@ -260,17 +260,16 @@ class CustomizeToolBarDialog(
|
|||||||
removeWindowListener(this)
|
removeWindowListener(this)
|
||||||
|
|
||||||
val allActions = toolbar.getAllActions().toMutableList()
|
val allActions = toolbar.getAllActions().toMutableList()
|
||||||
val shownActions = toolbar.getShownActions().filter { it.visible }
|
val shownActions = toolbar.getShownActions().associate { Pair(it.id, it.visible) }
|
||||||
.map { it.id }
|
|
||||||
allActions.removeAll(shownActions)
|
|
||||||
|
|
||||||
for (action in allActions) {
|
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.keymgr.KeyManagerDialog
|
||||||
import app.termora.macro.MacroAction
|
import app.termora.macro.MacroAction
|
||||||
import app.termora.tlog.TerminalLoggerAction
|
import app.termora.tlog.TerminalLoggerAction
|
||||||
|
import app.termora.transport.SFTPAction
|
||||||
import com.formdev.flatlaf.FlatClientProperties
|
import com.formdev.flatlaf.FlatClientProperties
|
||||||
import com.formdev.flatlaf.FlatLaf
|
import com.formdev.flatlaf.FlatLaf
|
||||||
import com.formdev.flatlaf.extras.FlatDesktop
|
import com.formdev.flatlaf.extras.FlatDesktop
|
||||||
@@ -205,6 +206,9 @@ class TermoraFrame : JFrame() {
|
|||||||
// 终端日志记录
|
// 终端日志记录
|
||||||
ActionManager.getInstance().addAction(Actions.TERMINAL_LOGGER, TerminalLoggerAction())
|
ActionManager.getInstance().addAction(Actions.TERMINAL_LOGGER, TerminalLoggerAction())
|
||||||
|
|
||||||
|
// SFTP
|
||||||
|
ActionManager.getInstance().addAction(Actions.SFTP, SFTPAction())
|
||||||
|
|
||||||
// macro
|
// macro
|
||||||
ActionManager.getInstance().addAction(Actions.MACRO, MacroAction())
|
ActionManager.getInstance().addAction(Actions.MACRO, MacroAction())
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class TermoraToolBar(
|
|||||||
|
|
||||||
fun getAllActions(): List<String> {
|
fun getAllActions(): List<String> {
|
||||||
return listOf(
|
return listOf(
|
||||||
|
Actions.SFTP,
|
||||||
Actions.TERMINAL_LOGGER,
|
Actions.TERMINAL_LOGGER,
|
||||||
Actions.MACRO,
|
Actions.MACRO,
|
||||||
Actions.KEYWORD_HIGHLIGHT,
|
Actions.KEYWORD_HIGHLIGHT,
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import java.awt.event.ActionEvent
|
|||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
|
|
||||||
class QuickCommandFindEverywhereProvider : FindEverywhereProvider {
|
class QuickCommandFindEverywhereProvider : FindEverywhereProvider {
|
||||||
|
private val actionManager get() = ActionManager.getInstance()
|
||||||
|
|
||||||
override fun find(pattern: String): List<FindEverywhereResult> {
|
override fun find(pattern: String): List<FindEverywhereResult> {
|
||||||
val list = mutableListOf<FindEverywhereResult>()
|
val list = mutableListOf<FindEverywhereResult>()
|
||||||
ActionManager.getInstance().getAction(Actions.ADD_HOST)?.let {
|
actionManager?.let {
|
||||||
list.add(CreateHostFindEverywhereResult())
|
list.add(CreateHostFindEverywhereResult())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,34 +21,21 @@ class QuickCommandFindEverywhereProvider : FindEverywhereProvider {
|
|||||||
Icons.terminal
|
Icons.terminal
|
||||||
) {
|
) {
|
||||||
override fun actionPerformed(evt: ActionEvent) {
|
override fun actionPerformed(evt: ActionEvent) {
|
||||||
ActionManager.getInstance().getAction(Actions.OPEN_HOST)
|
actionManager.getAction(Actions.OPEN_HOST)?.actionPerformed(
|
||||||
?.actionPerformed(
|
OpenHostActionEvent(
|
||||||
OpenHostActionEvent(
|
this, Host(
|
||||||
this, Host(
|
name = name,
|
||||||
name = name,
|
protocol = Protocol.Local
|
||||||
protocol = Protocol.Local
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// SFTP
|
// SFTP
|
||||||
list.add(ActionFindEverywhereResult(object : AnAction("SFTP", Icons.fileTransfer) {
|
actionManager.getAction(Actions.SFTP)?.let {
|
||||||
override fun actionPerformed(evt: ActionEvent) {
|
list.add(ActionFindEverywhereResult(it))
|
||||||
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())
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
return list
|
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