Merge old and new search panels

This commit is contained in:
downthecrop 2025-10-12 19:33:25 -07:00
parent 2d1e2806ec
commit 8ac1bad46f
9 changed files with 352 additions and 336 deletions

View file

@ -2,12 +2,12 @@ package KondoKit.views
import KondoKit.Helpers
import KondoKit.components.*
import KondoKit.components.ReflectiveEditorComponents.CustomSearchField
import KondoKit.components.ReflectiveEditorComponents.GitLabPlugin
import KondoKit.components.ReflectiveEditorComponents.GitLabPluginFetcher
import KondoKit.components.ReflectiveEditorComponents.PluginDownloadManager
import KondoKit.components.ReflectiveEditorComponents.PluginProperties
import KondoKit.components.ReflectiveEditorComponents.PluginStatus
import KondoKit.components.CustomSearchField
import KondoKit.pluginmanager.GitLabPlugin
import KondoKit.pluginmanager.GitLabPluginFetcher
import KondoKit.pluginmanager.PluginDownloadManager
import KondoKit.pluginmanager.PluginProperties
import KondoKit.pluginmanager.PluginInfoWithStatus
import KondoKit.Helpers.showToast
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
import KondoKit.plugin.Companion.TOOLTIP_BACKGROUND
@ -47,7 +47,7 @@ object ReflectiveEditorView : View {
private var gitLabPlugins: List<GitLabPlugin> = listOf()
private var pluginStatuses: List<PluginStatus> = listOf()
private var pluginStatuses: List<PluginInfoWithStatus> = listOf()
private var cogIcon: Icon? = null
@ -133,12 +133,19 @@ object ReflectiveEditorView : View {
panel.layout = BoxLayout(panel, BoxLayout.Y_AXIS)
panel.background = VIEW_BACKGROUND_COLOR
val searchField = CustomSearchField(panel) { searchText ->
pluginSearchText = searchText
SwingUtilities.invokeLater {
addPlugins(reflectiveEditorView!!)
}
}
val searchField = CustomSearchField(
parentPanel = panel,
onSearch = { searchText ->
pluginSearchText = searchText
SwingUtilities.invokeLater {
addPlugins(reflectiveEditorView!!)
}
},
placeholderText = "Search plugins...",
fieldWidth = 230,
fieldHeight = 30,
viewName = "REFLECTIVE_EDITOR_VIEW"
)
this.searchField = searchField
if (pluginSearchText.isNotBlank()) {
searchField.setText(pluginSearchText)
@ -433,7 +440,7 @@ object ReflectiveEditorView : View {
return panel
}
private fun createPluginStatusItemPanel(pluginStatus: PluginStatus): JPanel {
private fun createPluginStatusItemPanel(pluginStatus: PluginInfoWithStatus): JPanel {
val panel = JPanel(BorderLayout())
panel.background = WIDGET_COLOR
panel.border = BorderFactory.createEmptyBorder(10, 10, 10, 10)
@ -948,7 +955,7 @@ object ReflectiveEditorView : View {
}
// Method to start downloading a plugin
private fun startPluginDownload(pluginStatus: PluginStatus) {
private fun startPluginDownload(pluginStatus: PluginInfoWithStatus) {
val gitLabPlugin = pluginStatus.gitLabPlugin
if (gitLabPlugin == null) {
showToast(mainPanel, "Plugin information not available", JOptionPane.ERROR_MESSAGE)
@ -956,7 +963,7 @@ object ReflectiveEditorView : View {
}
// Log the download URL for debugging
val downloadUrl = PluginDownloadManager.testDownloadUrl(gitLabPlugin)
val downloadUrl = PluginDownloadManager.getDownloadUrlForLogging(gitLabPlugin)
System.out.println("Download URL for plugin ${gitLabPlugin.path}: $downloadUrl")
// Update plugin status to show downloading
@ -1022,7 +1029,7 @@ object ReflectiveEditorView : View {
}
// Method to start downloading multiple plugins
private fun startMultiplePluginDownloads(pluginStatuses: List<PluginStatus>) {
private fun startMultiplePluginDownloads(pluginStatuses: List<PluginInfoWithStatus>) {
val gitLabPlugins = pluginStatuses.mapNotNull { it.gitLabPlugin }
if (gitLabPlugins.isEmpty()) {
@ -1092,7 +1099,7 @@ object ReflectiveEditorView : View {
// Update plugin statuses by comparing installed and remote plugins
private fun updatePluginStatuses() {
val loadedPluginNames = getLoadedPluginNames()
val statuses = mutableListOf<PluginStatus>()
val statuses = mutableListOf<PluginInfoWithStatus>()
System.out.println("Updating plugin statuses. Loaded plugins: ${loadedPluginNames.joinToString(", ")}")
@ -1126,7 +1133,7 @@ object ReflectiveEditorView : View {
if (isLoaded) {
// Plugin is currently loaded
statuses.add(PluginStatus(
statuses.add(PluginInfoWithStatus(
name = pluginName,
installedVersion = remoteVersion, // We don't have the actual installed version, but we know it's loaded
remoteVersion = remoteVersion,
@ -1143,7 +1150,7 @@ object ReflectiveEditorView : View {
val versionsMatch = disabledVersion != null && disabledVersion == remoteVersion
if (!versionsMatch) {
// Versions don't match, show update option
statuses.add(PluginStatus(
statuses.add(PluginInfoWithStatus(
name = pluginName,
installedVersion = disabledVersion,
remoteVersion = remoteVersion,
@ -1159,7 +1166,7 @@ object ReflectiveEditorView : View {
// If versions match, we don't add it to the list since there's no point showing it
} else {
// Plugin is not installed at all
statuses.add(PluginStatus(
statuses.add(PluginInfoWithStatus(
name = pluginName,
installedVersion = null,
remoteVersion = remoteVersion,