Skip to content

Commit

Permalink
Use application manager instead of swing utilities for invoke later
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitja Leino committed Apr 28, 2024
1 parent 8d22246 commit c2158f7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/main/kotlin/com/mituuz/fuzzier/Fuzzier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ open class Fuzzier : FuzzyAction() {
private val fuzzyDimensionKey: String = "FuzzySearchPopup"

override fun actionPerformed(actionEvent: AnActionEvent) {
setCustomHandlers()
SwingUtilities.invokeLater {
setCustomHandlers()
ApplicationManager.getApplication().invokeLater {
defaultDoc = EditorFactory.getInstance().createDocument("")
actionEvent.project?.let { project ->
component = FuzzyFinderComponent(project)
Expand Down Expand Up @@ -78,7 +78,7 @@ open class Fuzzier : FuzzyAction() {

override fun updateListContents(project: Project, searchString: String) {
if (StringUtils.isBlank(searchString)) {
SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.fileList.model = DefaultListModel()
defaultDoc?.let { (component as FuzzyFinderComponent).previewPane.updateFile(it) }
}
Expand All @@ -104,7 +104,7 @@ open class Fuzzier : FuzzyAction() {

listModel = fuzzierUtil.sortAndLimit(listModel)

SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.fileList.model = listModel
component.fileList.cellRenderer = getCellRenderer()
component.fileList.setPaintBusy(false)
Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/com/mituuz/fuzzier/FuzzierVCS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import com.mituuz.fuzzier.components.FuzzyFinderComponent
import com.mituuz.fuzzier.entities.FuzzyMatchContainer
import org.apache.commons.lang3.StringUtils
import javax.swing.DefaultListModel
import javax.swing.SwingUtilities


class FuzzierVCS : Fuzzier() {
override var title: String = "Fuzzy Search (Only VCS Tracked Files)"
override fun updateListContents(project: Project, searchString: String) {
if (StringUtils.isBlank(searchString)) {
SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.fileList.model = DefaultListModel()
defaultDoc?.let { (component as FuzzyFinderComponent).previewPane.updateFile(it) }
}
Expand Down Expand Up @@ -44,7 +42,7 @@ class FuzzierVCS : Fuzzier() {

listModel = fuzzierUtil.sortAndLimit(listModel)

SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.fileList.model = listModel
component.fileList.cellRenderer = getCellRenderer()
component.fileList.setPaintBusy(false)
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/com/mituuz/fuzzier/FuzzyMover.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FuzzyMover : FuzzyAction() {

override fun actionPerformed(actionEvent: AnActionEvent) {
setCustomHandlers()
SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
actionEvent.project?.let { project ->
component = SimpleFinderComponent()
val projectBasePath = project.basePath
Expand Down Expand Up @@ -117,7 +117,7 @@ class FuzzyMover : FuzzyAction() {
}
}
}
SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.isDirSelector = true
component.searchField.text = ""
component.fileList.setEmptyText("Select target folder")
Expand Down Expand Up @@ -164,7 +164,7 @@ class FuzzyMover : FuzzyAction() {

override fun updateListContents(project: Project, searchString: String) {
if (StringUtils.isBlank(searchString)) {
SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.fileList.model = DefaultListModel()
}
return
Expand Down Expand Up @@ -194,7 +194,7 @@ class FuzzyMover : FuzzyAction() {

listModel = fuzzierUtil.sortAndLimit(listModel)

SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
component.fileList.model = listModel
component.fileList.cellRenderer = getCellRenderer()
component.fileList.setPaintBusy(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class TestBenchComponent : JPanel() {

fun updateListContents(project: Project, searchString: String) {
if (StringUtils.isBlank(searchString)) {
SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
table.model = DefaultTableModel()
}
return
Expand Down Expand Up @@ -136,7 +136,7 @@ class TestBenchComponent : JPanel() {

val tableModel = DefaultTableModel(data, columnNames)

SwingUtilities.invokeLater {
ApplicationManager.getApplication().invokeLater {
table.model = tableModel
table.setPaintBusy(false)
}
Expand Down

0 comments on commit c2158f7

Please sign in to comment.