Can you please correct me If I am wrong? Is this t...
# jewel
m
Can you please correct me If I am wrong? Is this the correct way to use Jewel in ToolWindow?
Copy code
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.Content
import com.intellij.ui.content.ContentFactory
import org.jetbrains.jewel.bridge.JewelToolWindowComposePanel
import org.jetbrains.jewel.foundation.InternalJewelApi
import org.jetbrains.jewel.ui.component.Text

class ChatToolWindowFactory: ToolWindowFactory, DumbAware {

    @OptIn(InternalJewelApi::class)
    override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
        val component = JewelToolWindowComposePanel {
            Text("Hello World!")
        }
        val contentFactory = ContentFactory.getInstance()
        val content: Content = contentFactory.createContent(component, "", false)
        toolWindow.contentManager.addContent(content)
    }
}
Under the hood it uses Swing to Compose bridge API. Will this be deprecated in future?
f
That looks fine to me. You can also use a shortcut with:
Copy code
import org.jetbrains.jewel.bridge.addComposeTab

class PanelPlugin : ToolWindowFactory, DumbAware {
    override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
        toolWindow.addComposeTab("") {
                MyPanel(project, airChatService)
        }
    }
m
Yeah, but I don't need a tab
It seems
addComposeTab
also uses the
JewelToolWindowComposePanel
as I used under the hood.
f
I believe that if you pass "" for the tab name, it actually won't show it, but yeah you can just use the more verbose way like you have it now
🙌 1
s
All toolwindows have tabs, it's just invisible if it's only one 🙂
🙌 1