mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: improve plugin settings
This commit is contained in:
@@ -28,7 +28,7 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
|
|||||||
private val busyLabel = JXBusyLabel()
|
private val busyLabel = JXBusyLabel()
|
||||||
private val coroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
private val coroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
private val failedLabel = JLabel()
|
private val failedLabel = JLabel()
|
||||||
private val isLoading = AtomicBoolean(false)
|
val isLoading = AtomicBoolean(false)
|
||||||
|
|
||||||
private val marketplaceManager get() = MarketplaceManager.getInstance()
|
private val marketplaceManager get() = MarketplaceManager.getInstance()
|
||||||
|
|
||||||
@@ -112,7 +112,6 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
|
|||||||
pluginsPanel.add(createMarketplacePluginPanel(plugin))
|
pluginsPanel.add(createMarketplacePluginPanel(plugin))
|
||||||
pluginsPanel.add(JToolBar.Separator())
|
pluginsPanel.add(JToolBar.Separator())
|
||||||
}
|
}
|
||||||
pluginsPanel.add(createRetry())
|
|
||||||
cardLayout.show(cardPanel, PanelState.Plugins.name)
|
cardLayout.show(cardPanel, PanelState.Plugins.name)
|
||||||
} else {
|
} else {
|
||||||
failedLabel.text = "No plugins found"
|
failedLabel.text = "No plugins found"
|
||||||
@@ -134,7 +133,7 @@ class MarketplacePanel : JPanel(BorderLayout()), Disposable {
|
|||||||
private fun createRetry(): JComponent {
|
private fun createRetry(): JComponent {
|
||||||
val box = Box.createHorizontalBox()
|
val box = Box.createHorizontalBox()
|
||||||
box.add(Box.createHorizontalGlue())
|
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) {
|
override fun actionPerformed(e: ActionEvent) {
|
||||||
marketplaceManager.clear()
|
marketplaceManager.clear()
|
||||||
reload()
|
reload()
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ class PluginOption : JPanel(BorderLayout()), OptionsPane.Option, Disposable, Acc
|
|||||||
private val tabbed = FlatTabbedPane()
|
private val tabbed = FlatTabbedPane()
|
||||||
private val toolbar = FlatToolBar()
|
private val toolbar = FlatToolBar()
|
||||||
private val settingsButton = JButton(Icons.settings)
|
private val settingsButton = JButton(Icons.settings)
|
||||||
|
private val refreshButton = JButton(Icons.refresh)
|
||||||
private val owner get() = SwingUtilities.getWindowAncestor(this)
|
private val owner get() = SwingUtilities.getWindowAncestor(this)
|
||||||
private val marketplacePanel = MarketplacePanel()
|
private val marketplacePanel = MarketplacePanel()
|
||||||
private val installedPanel = InstalledPanel()
|
private val installedPanel = InstalledPanel()
|
||||||
|
private val marketplaceManager get() = MarketplaceManager.getInstance()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
initView()
|
initView()
|
||||||
@@ -58,10 +60,12 @@ class PluginOption : JPanel(BorderLayout()), OptionsPane.Option, Disposable, Acc
|
|||||||
tabbed.addTab(I18n.getString("termora.settings.plugin.installed"), installedPanel)
|
tabbed.addTab(I18n.getString("termora.settings.plugin.installed"), installedPanel)
|
||||||
|
|
||||||
toolbar.add(Box.createHorizontalGlue())
|
toolbar.add(Box.createHorizontalGlue())
|
||||||
|
toolbar.add(refreshButton)
|
||||||
toolbar.add(settingsButton)
|
toolbar.add(settingsButton)
|
||||||
tabbed.trailingComponent = toolbar
|
tabbed.trailingComponent = toolbar
|
||||||
|
|
||||||
tabbed.selectedIndex = EnableManager.getInstance().getFlag("PluginOption.defaultTab", 0)
|
tabbed.selectedIndex = EnableManager.getInstance().getFlag("PluginOption.defaultTab", 0)
|
||||||
|
refreshButton.isVisible = tabbed.selectedIndex == 0
|
||||||
|
|
||||||
add(tabbed, BorderLayout.CENTER)
|
add(tabbed, BorderLayout.CENTER)
|
||||||
|
|
||||||
@@ -73,6 +77,13 @@ class PluginOption : JPanel(BorderLayout()), OptionsPane.Option, Disposable, Acc
|
|||||||
.let { Disposer.register(this, it) }
|
.let { Disposer.register(this, it) }
|
||||||
|
|
||||||
settingsButton.addActionListener { showContextMenu() }
|
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 {
|
override fun getIcon(isSelected: Boolean): Icon {
|
||||||
|
|||||||
Reference in New Issue
Block a user