mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-21 02:11:29 +00:00
fix: UI perf issues
This commit is contained in:
parent
adefb44593
commit
b6eb98db91
2 changed files with 41 additions and 18 deletions
|
|
@ -5,10 +5,12 @@ import com.intellij.openapi.components.service
|
|||
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.ui.components.JBLabel
|
||||
import com.intellij.ui.dsl.builder.AlignX
|
||||
import com.intellij.ui.dsl.builder.panel
|
||||
import com.intellij.util.ui.JBUI
|
||||
import ee.carlrobert.codegpt.settings.persona.PersonaSettings
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Component
|
||||
import java.awt.Dimension
|
||||
import javax.swing.*
|
||||
|
|
@ -85,12 +87,29 @@ class SuggestionListCellRenderer(
|
|||
}
|
||||
|
||||
private fun renderPersonaItem(component: JLabel, item: SuggestionItem.PersonaItem): JPanel {
|
||||
return createDefaultPanel(
|
||||
component,
|
||||
AllIcons.General.User,
|
||||
item.personaDetails.name,
|
||||
item.personaDetails.instructions,
|
||||
)
|
||||
component.apply {
|
||||
icon = AllIcons.General.User
|
||||
iconTextGap = 4
|
||||
val searchText = getSearchText(textPane.text)
|
||||
text = if (searchText != null) {
|
||||
generateHighlightedHtml(item.personaDetails.name, searchText)
|
||||
} else {
|
||||
item.personaDetails.name
|
||||
}
|
||||
}
|
||||
|
||||
return JPanel(BorderLayout()).apply {
|
||||
add(component, BorderLayout.LINE_START)
|
||||
add(
|
||||
JBLabel(item.personaDetails.instructions)
|
||||
.apply {
|
||||
font = JBUI.Fonts.smallFont()
|
||||
foreground = JBColor.gray
|
||||
border = JBUI.Borders.emptyLeft(22)
|
||||
},
|
||||
BorderLayout.SOUTH
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSearchText(text: String): String? {
|
||||
|
|
|
|||
|
|
@ -19,18 +19,14 @@ import ee.carlrobert.codegpt.CodeGPTBundle
|
|||
import ee.carlrobert.codegpt.settings.persona.PersonaDetails
|
||||
import ee.carlrobert.codegpt.settings.persona.PersonaSettings
|
||||
import ee.carlrobert.codegpt.settings.persona.PersonasConfigurable
|
||||
import ee.carlrobert.codegpt.util.showAbove
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import ee.carlrobert.codegpt.util.showAbove
|
||||
import java.awt.Dimension
|
||||
import java.awt.Point
|
||||
import java.awt.*
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
import javax.swing.DefaultListModel
|
||||
import javax.swing.Icon
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.ScrollPaneConstants
|
||||
import javax.swing.*
|
||||
import javax.swing.event.ListDataEvent
|
||||
import javax.swing.event.ListDataListener
|
||||
|
||||
|
|
@ -233,11 +229,19 @@ class SuggestionsPopupManager(
|
|||
val popupPanel = panel {
|
||||
row { cell(scrollPane) }
|
||||
row {
|
||||
cell(
|
||||
JBLabel(CodeGPTBundle.get("shared.escToCancel"))
|
||||
.withFont(JBUI.Fonts.smallFont())
|
||||
.withBorder(JBUI.Borders.empty(0, 8))
|
||||
)
|
||||
cell(JPanel(GridBagLayout()).apply {
|
||||
val gbc = GridBagConstraints()
|
||||
gbc.anchor = GridBagConstraints.WEST
|
||||
gbc.insets = Insets(0, 8, 0, 8)
|
||||
gbc.weightx = 1.0
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL
|
||||
add(
|
||||
JBLabel(CodeGPTBundle.get("shared.escToCancel"))
|
||||
.withFont(JBUI.Fonts.smallFont())
|
||||
.withBorder(JBUI.Borders.empty()), gbc
|
||||
)
|
||||
preferredSize = Dimension(480, 16)
|
||||
})
|
||||
}
|
||||
}
|
||||
return service<JBPopupFactory>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue