first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.github.cirry.wxreaderjetbrainsplugin
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.ui.Messages
|
||||
|
||||
class HelloAction : DumbAwareAction() {
|
||||
override fun actionPerformed(event: AnActionEvent) {
|
||||
val project = event.getData(PlatformDataKeys.PROJECT)
|
||||
Messages.showMessageDialog(project, "Hello from Kotlin!", "Greeting", Messages.getInformationIcon())
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.github.cirry.wxreaderjetbrainsplugin
|
||||
|
||||
import com.intellij.DynamicBundle
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
@NonNls
|
||||
private const val BUNDLE = "messages.MyBundle"
|
||||
|
||||
object MyBundle : DynamicBundle(BUNDLE) {
|
||||
|
||||
@JvmStatic
|
||||
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
|
||||
getMessage(key, *params)
|
||||
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
|
||||
getLazyMessage(key, *params)
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.github.cirry.wxreaderjetbrainsplugin.listeners
|
||||
|
||||
import com.intellij.openapi.application.ApplicationActivationListener
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.wm.IdeFrame
|
||||
|
||||
internal class MyApplicationActivationListener : ApplicationActivationListener {
|
||||
|
||||
override fun applicationActivated(ideFrame: IdeFrame) {
|
||||
thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.")
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.github.cirry.wxreaderjetbrainsplugin.services
|
||||
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.github.cirry.wxreaderjetbrainsplugin.MyBundle
|
||||
|
||||
@Service(Service.Level.PROJECT)
|
||||
class MyProjectService(project: Project) {
|
||||
|
||||
init {
|
||||
thisLogger().info(MyBundle.message("projectService", project.name))
|
||||
}
|
||||
|
||||
fun getRandomNumber() = (1..100).random()
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.github.cirry.wxreaderjetbrainsplugin.toolWindow
|
||||
|
||||
import com.github.cirry.wxreaderjetbrainsplugin.MyBundle
|
||||
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 com.intellij.ui.jcef.JBCefApp
|
||||
import com.intellij.ui.jcef.JBCefBrowser
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Dimension
|
||||
|
||||
|
||||
class MyToolWindowFactory : ToolWindowFactory {
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val myToolWindow = MyToolWindow(toolWindow)
|
||||
val content = ContentFactory.getInstance().createContent(myToolWindow.getContent(), "", false)
|
||||
toolWindow.contentManager.addContent(content)
|
||||
}
|
||||
|
||||
override fun shouldBeAvailable(project: Project) = true
|
||||
|
||||
class MyToolWindow(toolWindow: ToolWindow) {
|
||||
fun getContent() = JBPanel<JBPanel<*>>().apply {
|
||||
val noSupportLabel = JBLabel(MyBundle.message("noSupport"))
|
||||
if (JBCefApp.isSupported()) {
|
||||
val jbcef = JBCefBrowser()
|
||||
jbcef.component.preferredSize = Dimension(800,900)
|
||||
add(jbcef.component, BorderLayout.CENTER)
|
||||
jbcef.loadURL("https://weread.qq.com/")
|
||||
} else {
|
||||
add(noSupportLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user