Fix red code in MyToolWindowFactory

This commit is contained in:
Yuriy Artamonov 2025-05-21 16:07:06 +02:00
parent 4448c73cb1
commit 02ec572aaf

View File

@ -1,10 +1,6 @@
package org.jetbrains.plugins.template.toolWindow package org.jetbrains.plugins.template.toolWindow
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@ -12,7 +8,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.intellij.openapi.components.service import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory import com.intellij.openapi.wm.ToolWindowFactory
@ -23,24 +18,18 @@ import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.plugins.template.ComposeTemplateBundle import org.jetbrains.plugins.template.ComposeTemplateBundle
import org.jetbrains.plugins.template.services.MyProjectService import org.jetbrains.plugins.template.services.MyProjectService
class MyToolWindowFactory : ToolWindowFactory { class MyToolWindowFactory : ToolWindowFactory {
init {
thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.")
}
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
val myToolWindow = MyToolWindow(toolWindow) val myToolWindow = MyToolWindow()
val content = ContentFactory.getInstance().createContent(myToolWindow.getContent(), null, false) val content = ContentFactory.getInstance().createContent(myToolWindow.getContent(), null, false)
toolWindow.contentManager.addContent(content) toolWindow.contentManager.addContent(content)
} }
override fun shouldBeAvailable(project: Project) = true override fun shouldBeAvailable(project: Project) = true
class MyToolWindow(toolWindow: ToolWindow) { class MyToolWindow() {
private val service = service<MyProjectService>()
private val service = toolWindow.project.service<MyProjectService>()
fun getContent() = JewelComposePanel { fun getContent() = JewelComposePanel {
Column(Modifier.fillMaxWidth().padding(16.dp)) { Column(Modifier.fillMaxWidth().padding(16.dp)) {