fix: Add JCEF not supported warning (#6762)
* fix: Add JCEF not supported warning Related to: #5107, #4598, #649, #596 * fix: provide guidance on how to install the correct JDK
This commit is contained in:
parent
69cd220d83
commit
621e1dbf6b
2 changed files with 69 additions and 40 deletions
|
|
@ -2,62 +2,69 @@ package com.github.continuedev.continueintellijextension.toolWindow
|
|||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.components.service
|
||||
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.ContentFactory
|
||||
import com.intellij.ui.dsl.builder.AlignX
|
||||
import com.intellij.ui.dsl.builder.panel
|
||||
import com.intellij.ui.jcef.JBCefApp
|
||||
import com.intellij.util.ui.JBUI.Borders.empty
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
|
||||
const val JS_QUERY_POOL_SIZE = "200"
|
||||
|
||||
class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val continueToolWindow = ContinuePluginWindow(project)
|
||||
val content =
|
||||
ContentFactory.getInstance().createContent(continueToolWindow.content, null, false)
|
||||
toolWindow.contentManager.addContent(content)
|
||||
val titleActions = mutableListOf<AnAction>()
|
||||
createTitleActions(titleActions)
|
||||
|
||||
// Add MaximizeToolWindow action
|
||||
val action = ActionManager.getInstance().getAction("MaximizeToolWindow")
|
||||
if (action != null) {
|
||||
titleActions.add(action)
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val inner = if (JBCefApp.isSupported())
|
||||
ContinuePluginWindow(project).content
|
||||
else
|
||||
createNotSupportedPanel()
|
||||
val content = ContentFactory.getInstance().createContent(inner, null, false)
|
||||
toolWindow.contentManager.addContent(content)
|
||||
toolWindow.setTitleActions(
|
||||
listOf(
|
||||
ActionManager.getInstance().getAction("ContinueSidebarActionsGroup"),
|
||||
ActionManager.getInstance().getAction("MaximizeToolWindow")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
toolWindow.setTitleActions(titleActions)
|
||||
}
|
||||
override fun shouldBeAvailable(project: Project) = true
|
||||
|
||||
private fun createTitleActions(titleActions: MutableList<in AnAction>) {
|
||||
val action = ActionManager.getInstance().getAction("ContinueSidebarActionsGroup")
|
||||
if (action != null) {
|
||||
titleActions.add(action)
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldBeAvailable(project: Project) = true
|
||||
|
||||
class ContinuePluginWindow(project: Project) {
|
||||
private val defaultGUIUrl = "http://continue/index.html"
|
||||
|
||||
init {
|
||||
System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE)
|
||||
System.setProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")
|
||||
System.setProperty("ide.browser.jcef.out-of-process.enabled", "false")
|
||||
private fun createNotSupportedPanel(): JPanel {
|
||||
val html = ContinuePluginToolWindowFactory::class.java.classLoader
|
||||
.getResourceAsStream("jcef_error.html")
|
||||
.bufferedReader()
|
||||
.readText()
|
||||
return panel {
|
||||
row {
|
||||
text(html)
|
||||
}
|
||||
}.withBorder(empty(10))
|
||||
}
|
||||
|
||||
val browser: ContinueBrowser by lazy {
|
||||
val url = System.getenv("GUI_URL")?.toString() ?: defaultGUIUrl
|
||||
class ContinuePluginWindow(project: Project) {
|
||||
private val defaultGUIUrl = "http://continue/index.html"
|
||||
|
||||
val browser = ContinueBrowser(project, url)
|
||||
project.service<ContinuePluginService>().continuePluginWindow = this
|
||||
browser
|
||||
init {
|
||||
System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE)
|
||||
System.setProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")
|
||||
System.setProperty("ide.browser.jcef.out-of-process.enabled", "false")
|
||||
}
|
||||
|
||||
val browser: ContinueBrowser by lazy {
|
||||
val url = System.getenv("GUI_URL") ?: defaultGUIUrl
|
||||
|
||||
val browser = ContinueBrowser(project, url)
|
||||
project.service<ContinuePluginService>().continuePluginWindow = this
|
||||
browser
|
||||
}
|
||||
|
||||
val content: JComponent
|
||||
get() = browser.browser.component
|
||||
}
|
||||
|
||||
val content: JComponent
|
||||
get() = browser.browser.component
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
extensions/intellij/src/main/resources/jcef_error.html
Normal file
22
extensions/intellij/src/main/resources/jcef_error.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!--suppress ALL-->
|
||||
<html>
|
||||
<h2>
|
||||
<center>Continue Chat is Unable to Load</center>
|
||||
</h2>
|
||||
<p>Continue Chat requires a JRE that supports the Java Chromium Embedded Framework (JCEF) to render our webview. You can
|
||||
still use Autocomplete and Edit.</p>
|
||||
<h3>How to Fix It?</h3>
|
||||
<p>You can manually switch to a JRE that supports JCEF:</p>
|
||||
<ol>
|
||||
<li>In the main menu, go to <b>Help | Find Action</b> or press
|
||||
<b>Ctrl + Shift + A</b>.
|
||||
</li>
|
||||
<li>Find and select the <b>Choose Boot Java Runtime for the IDE</b> action.</li>
|
||||
<li>Select the runtime that comes with JCEF support and click <b>OK</b>.</li>
|
||||
<li>Restart with the new runtime.</li>
|
||||
</ol>
|
||||
<p>Runtimes that support JCEF are usually called <b>JetBrains Runtime</b> and have the <code>-jcef</code> suffix,
|
||||
for example <code>21.0.3+13-509.11-jcef</code>.</p>
|
||||
<br>
|
||||
<small>You can find more information in the <a href="https://www.jetbrains.com/help/idea/switching-boot-jdk.html">JetBrains documentation</a>.</small>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue