cleanup (rename bundle, drop irrelevant showcase code)

This commit is contained in:
Dmitry Batkovich 2025-05-20 16:44:56 +02:00
parent ea305cb70a
commit e901750938
6 changed files with 9 additions and 37 deletions

View File

@ -5,9 +5,9 @@ import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey import org.jetbrains.annotations.PropertyKey
@NonNls @NonNls
private const val BUNDLE = "messages.MyBundle" private const val BUNDLE = "messages.ComposeTemplate"
object MyBundle : DynamicBundle(BUNDLE) { object ComposeTemplateBundle : DynamicBundle(BUNDLE) {
@JvmStatic @JvmStatic
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =

View File

@ -1,17 +1,8 @@
package org.jetbrains.plugins.template.services package org.jetbrains.plugins.template.services
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 org.jetbrains.plugins.template.MyBundle
@Service(Service.Level.PROJECT)
class MyProjectService(project: Project) {
init {
thisLogger().info(MyBundle.message("projectService", project.name))
thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.")
}
@Service
class MyProjectService() {
fun getRandomNumber() = (1..100).random() fun getRandomNumber() = (1..100).random()
} }

View File

@ -1,12 +0,0 @@
package org.jetbrains.plugins.template.startup
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
class MyProjectActivity : ProjectActivity {
override suspend fun execute(project: Project) {
thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.")
}
}

View File

@ -1,14 +1,11 @@
package org.jetbrains.plugins.template.toolWindow package org.jetbrains.plugins.template.toolWindow
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
@ -19,15 +16,12 @@ 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
import com.intellij.ui.components.JBLabel
import com.intellij.ui.components.JBPanel
import com.intellij.ui.content.ContentFactory import com.intellij.ui.content.ContentFactory
import org.jetbrains.jewel.bridge.JewelComposePanel import org.jetbrains.jewel.bridge.JewelComposePanel
import org.jetbrains.jewel.ui.component.DefaultButton import org.jetbrains.jewel.ui.component.DefaultButton
import org.jetbrains.jewel.ui.component.Text import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.plugins.template.MyBundle import org.jetbrains.plugins.template.ComposeTemplateBundle
import org.jetbrains.plugins.template.services.MyProjectService import org.jetbrains.plugins.template.services.MyProjectService
import javax.swing.JButton
class MyToolWindowFactory : ToolWindowFactory { class MyToolWindowFactory : ToolWindowFactory {
@ -51,12 +45,12 @@ class MyToolWindowFactory : ToolWindowFactory {
fun getContent() = JewelComposePanel { fun getContent() = JewelComposePanel {
Column(Modifier.fillMaxWidth().padding(16.dp)) { Column(Modifier.fillMaxWidth().padding(16.dp)) {
var param by remember { mutableStateOf("?") } var param by remember { mutableStateOf("?") }
Text(MyBundle.message("randomLabel", param)) Text(ComposeTemplateBundle.message("randomLabel", param))
Spacer(Modifier.height(8.dp)) Spacer(Modifier.height(8.dp))
DefaultButton(onClick = { DefaultButton(onClick = {
param = service.getRandomNumber().toString() param = service.getRandomNumber().toString()
}) { }) {
Text(MyBundle.message("shuffle")) Text(ComposeTemplateBundle.message("shuffle"))
} }
} }
} }

View File

@ -1,7 +1,7 @@
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html --> <!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin> <idea-plugin>
<id>org.jetbrains.plugins.template</id> <id>org.jetbrains.plugins.compose.template</id>
<name>IntelliJ Platform Plugin Template</name> <name>Compose Template Example</name>
<vendor>JetBrains</vendor> <vendor>JetBrains</vendor>
<dependencies> <dependencies>
@ -21,6 +21,5 @@
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<toolWindow factoryClass="org.jetbrains.plugins.template.toolWindow.MyToolWindowFactory" id="MyToolWindow"/> <toolWindow factoryClass="org.jetbrains.plugins.template.toolWindow.MyToolWindowFactory" id="MyToolWindow"/>
<postStartupActivity implementation="org.jetbrains.plugins.template.startup.MyProjectActivity" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>