chore: improve plugin settings

This commit is contained in:
hstyi
2025-06-29 13:00:53 +08:00
committed by hstyi
parent efa9613d26
commit b1e1f38b50
2 changed files with 13 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
private val busyLabel = JXBusyLabel()
private val coroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
private val failedLabel = JLabel()
private val isLoading = AtomicBoolean(false)
val isLoading = AtomicBoolean(false)
private val marketplaceManager get() = MarketplaceManager.getInstance()
@@ -112,7 +112,6 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
pluginsPanel.add(createMarketplacePluginPanel(plugin))
pluginsPanel.add(JToolBar.Separator())
}
pluginsPanel.add(createRetry())
cardLayout.show(cardPanel, PanelState.Plugins.name)
} else {
failedLabel.text = "No plugins found"
@@ -134,7 +133,7 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
private fun createRetry(): JComponent {
val box = Box.createHorizontalBox()
box.add(Box.createHorizontalGlue())
box.add(JXHyperlink(object : AbstractAction(I18n.getString("termora.transport.sftp.retry")) {
box.add(JXHyperlink(object : AbstractAction(I18n.getString("termora.transport.table.contextmenu.refresh")) {
override fun actionPerformed(e: ActionEvent) {
marketplaceManager.clear()
reload()

View File

@@ -31,9 +31,11 @@ class PluginOption : JPanel(BorderLayout()), OptionsPane.Option, Disposable, Acc
private val tabbed = FlatTabbedPane()
private val toolbar = FlatToolBar()
private val settingsButton = JButton(Icons.settings)
private val refreshButton = JButton(Icons.refresh)
private val owner get() = SwingUtilities.getWindowAncestor(this)
private val marketplacePanel = MarketplacePanel()
private val installedPanel = InstalledPanel()
private val marketplaceManager get() = MarketplaceManager.getInstance()
init {
initView()
@@ -58,10 +60,12 @@ class PluginOption : JPanel(BorderLayout()), OptionsPane.Option, Disposable, Acc
tabbed.addTab(I18n.getString("termora.settings.plugin.installed"), installedPanel)
toolbar.add(Box.createHorizontalGlue())
toolbar.add(refreshButton)
toolbar.add(settingsButton)
tabbed.trailingComponent = toolbar
tabbed.selectedIndex = EnableManager.getInstance().getFlag("PluginOption.defaultTab", 0)
refreshButton.isVisible = tabbed.selectedIndex == 0
add(tabbed, BorderLayout.CENTER)
@@ -73,6 +77,13 @@ class PluginOption : JPanel(BorderLayout()), OptionsPane.Option, Disposable, Acc
.let { Disposer.register(this, it) }
settingsButton.addActionListener { showContextMenu() }
refreshButton.addActionListener {
if (marketplacePanel.isLoading.get().not()) {
marketplaceManager.clear()
marketplacePanel.reload()
}
}
tabbed.addChangeListener { refreshButton.isVisible = tabbed.selectedIndex == 0 }
}
override fun getIcon(isSelected: Boolean): Icon {