Skip to content

Commit

Permalink
refactor(ui): update RightPanelView action toolbar implementation
Browse files Browse the repository at this point in the history
Replace the custom ActionToolbarImpl with the default createActionToolbar method. This change simplifies the toolbar setup process, removes unnecessary overrides, and ensures the toolbar background color is updated correctly.
  • Loading branch information
phodal committed Dec 1, 2024
1 parent 3cc6f43 commit 6073102
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions core/src/main/kotlin/com/phodal/shirecore/ui/RightPanelView.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.phodal.shirecore.ui

import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.ActionGroup
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.DataProvider
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.command.WriteCommandAction
Expand Down Expand Up @@ -50,25 +49,23 @@ class RightPanelView(
}

private fun setupActionForEditor(project: Project) {
val toolbarActionGroup = ActionManager.getInstance().getAction("Shire.ToolWindow.Toolbar") as? ActionGroup
val toolbarActionGroup = ActionManager.getInstance().getAction("Shire.ToolWindow.Toolbar") as? DefaultActionGroup
toolbarActionGroup?.let {
val toolbar: ActionToolbarImpl =
object : ActionToolbarImpl(ActionPlaces.MAIN_TOOLBAR, toolbarActionGroup, true) {
override fun updateUI() {
super.updateUI()
editor.component.setBorder(JBUI.Borders.empty())
}
}

toolbar.setBackground(editor.backgroundColor)
toolbar.setOpaque(true)
val toolbar = ActionManager.getInstance().createActionToolbar(
ActionPlaces.MAIN_TOOLBAR,
toolbarActionGroup,
true
)

toolbar.component.setBackground(editor.backgroundColor)
toolbar.component.setOpaque(true)
toolbar.targetComponent = editor.contentComponent
editor.headerComponent = toolbar
editor.headerComponent = toolbar.component

val connect = project.messageBus.connect(this)
val topic: Topic<EditorColorsListener> = EditorColorsManager.TOPIC
connect.subscribe(topic, EditorColorsListener {
toolbar.setBackground(editor.backgroundColor)
toolbar.component.setBackground(editor.backgroundColor)
})
}
}
Expand Down

0 comments on commit 6073102

Please sign in to comment.