Skip to content

Commit

Permalink
Refine 'addComposeTab' to include closeable option (#118)
Browse files Browse the repository at this point in the history
Introduced 'isCloseable' parameter in 'addComposeTab' function to enable flexibility in controlling behavior of tabs. This option allows programmatically defining whether a tab can be closed or not. Default value set to false to maintain existing function calls.
  • Loading branch information
lamba92 authored Sep 19, 2023
1 parent d19565e commit 33c2750
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import com.intellij.openapi.wm.ToolWindow
fun ToolWindow.addComposeTab(
tabDisplayName: String,
isLockable: Boolean = true,
isCloseable: Boolean = false,
content: @Composable () -> Unit,
) = ComposePanel()
.apply { setContent(content) }
.also { contentManager.addContent(contentManager.factory.createContent(it, tabDisplayName, isLockable)) }
) {
System.setProperty("compose.swing.render.on.graphics", "true")
val composePanel = ComposePanel()
composePanel.setContent(content)
val tabContent = contentManager.factory.createContent(composePanel, tabDisplayName, isLockable)
tabContent.isCloseable = isCloseable
contentManager.addContent(tabContent)
}

0 comments on commit 33c2750

Please sign in to comment.