initial commit
This commit is contained in:
22
src/main/kotlin/MyMessageBundle.kt
Normal file
22
src/main/kotlin/MyMessageBundle.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package dev.hgh
|
||||
|
||||
import com.intellij.DynamicBundle
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
import java.util.function.Supplier
|
||||
|
||||
private const val BUNDLE = "messages.MyMessageBundle"
|
||||
|
||||
internal object MyMessageBundle {
|
||||
private val instance = DynamicBundle(MyMessageBundle::class.java, BUNDLE)
|
||||
|
||||
@JvmStatic
|
||||
fun message(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any?): @Nls String {
|
||||
return instance.getMessage(key, *params)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun lazyMessage(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): Supplier<@Nls String> {
|
||||
return instance.getLazyMessage(key, *params)
|
||||
}
|
||||
}
|
||||
37
src/main/kotlin/MyToolWindowFactory.kt
Normal file
37
src/main/kotlin/MyToolWindowFactory.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package dev.hgh
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.wm.ToolWindow
|
||||
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 javax.swing.JButton
|
||||
import kotlin.random.Random
|
||||
|
||||
class MyToolWindowFactory : ToolWindowFactory {
|
||||
override fun shouldBeAvailable(project: Project) = true
|
||||
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val myToolWindow = MyToolWindow()
|
||||
val content = ContentFactory.getInstance().createContent(myToolWindow.getContent(), null, false)
|
||||
toolWindow.contentManager.addContent(content)
|
||||
}
|
||||
|
||||
class MyToolWindow {
|
||||
private val content = JBPanel<JBPanel<*>>().apply {
|
||||
val label = JBLabel(MyMessageBundle.message("toolwindow.MyToolWindow.number.label", "?"))
|
||||
|
||||
add(label)
|
||||
add(JButton(MyMessageBundle.message("toolwindow.MyToolWindow.shuffle.button")).apply {
|
||||
addActionListener {
|
||||
label.text = MyMessageBundle.message(
|
||||
"toolwindow.MyToolWindow.number.label", Random(System.currentTimeMillis()).nextInt(1000)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getContent(): JBPanel<JBPanel<*>> = content
|
||||
}
|
||||
}
|
||||
33
src/main/resources/META-INF/plugin.xml
Normal file
33
src/main/resources/META-INF/plugin.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
|
||||
<idea-plugin>
|
||||
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
|
||||
<id>dev.hgh.intellijai</id>
|
||||
|
||||
<!-- Public plugin name should be written in Title Case.
|
||||
Guidelines: https://plugins.jetbrains.com/docs/marketplace/best-practices-for-listing.html#plugin-name -->
|
||||
<name>Intellijai</name>
|
||||
|
||||
<!-- A displayed Vendor name or Organization ID displayed on the Plugins Page. -->
|
||||
<vendor url="https://www.yourcompany.com">YourCompany</vendor>
|
||||
|
||||
<!-- Description of the plugin displayed on the Plugin Page and IDE Plugin Manager.
|
||||
Guidelines: https://plugins.jetbrains.com/docs/marketplace/best-practices-for-listing.html#plugin-description -->
|
||||
<description><![CDATA[
|
||||
Enter short description for your plugin here.<br>
|
||||
<em>most HTML tags may be used</em>
|
||||
]]></description>
|
||||
|
||||
<!-- Product and plugin compatibility requirements.
|
||||
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
|
||||
<depends>com.intellij.modules.platform</depends>
|
||||
|
||||
<resource-bundle>messages.MyMessageBundle</resource-bundle>
|
||||
|
||||
<!-- Extensions defined by the plugin.
|
||||
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<toolWindow id="MyToolWindow" factoryClass="dev.hgh.MyToolWindowFactory"
|
||||
icon="AllIcons.Toolwindows.ToolWindowPalette"/>
|
||||
</extensions>
|
||||
|
||||
</idea-plugin>
|
||||
12
src/main/resources/META-INF/pluginIcon.svg
Normal file
12
src/main/resources/META-INF/pluginIcon.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M32.0845 7.94025V4H24.0203V7.9896H16.029V4H7.91553V7.94025H4V36H16.0044V32.0045C16.0058 30.9457 16.4274 29.9308 17.1766 29.1826C17.9258 28.4345 18.9412 28.0143 20 28.0143C21.0588 28.0143 22.0743 28.4345 22.8234 29.1826C23.5726 29.9308 23.9942 30.9457 23.9956 32.0045V36H36V7.94025H32.0845Z"
|
||||
fill="url(#paint0_linear)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear" x1="2.94192" y1="4.89955" x2="37.7772" y2="39.7345"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.15937" stop-color="#3BEA62"/>
|
||||
<stop offset="0.5404" stop-color="#3C99CC"/>
|
||||
<stop offset="0.93739" stop-color="#6B57FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 818 B |
3
src/main/resources/messages/MyMessageBundle.properties
Normal file
3
src/main/resources/messages/MyMessageBundle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
toolwindow.stripe.MyToolWindow=My Tool Window
|
||||
toolwindow.MyToolWindow.number.label=The random number is: {0}
|
||||
toolwindow.MyToolWindow.shuffle.button=Shuffle
|
||||
27
src/test/kotlin/dev/hgh/HarnessSmokeTest.kt
Normal file
27
src/test/kotlin/dev/hgh/HarnessSmokeTest.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package dev.hgh
|
||||
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
|
||||
/**
|
||||
* Validates that the headless test harness works end to end:
|
||||
* a JDK is resolved, the IntelliJ Platform boots, and a fixture can be driven
|
||||
* without launching an IDE.
|
||||
*
|
||||
* If this fails, no other test in the project can be trusted.
|
||||
*/
|
||||
class HarnessSmokeTest : BasePlatformTestCase() {
|
||||
|
||||
fun testPlatformBootsHeadlessly() {
|
||||
val file = myFixture.configureByText("smoke.txt", "hello jai")
|
||||
assertNotNull("fixture should create a PsiFile", file)
|
||||
assertEquals("hello jai", file.text)
|
||||
}
|
||||
|
||||
fun testRunningOnJava21OrLater() {
|
||||
val major = Runtime.version().feature()
|
||||
assertTrue(
|
||||
"IntelliJ Platform test-framework is Java 21 bytecode; running on $major",
|
||||
major >= 21,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user