mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
PY-71860: add AI Completion Promotion to Settings of PyCharm Community
GitOrigin-RevId: e4741fd50d0e24308a9566a07c135dd1feadfbf1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
702406397d
commit
6fd89125f9
@@ -11,13 +11,13 @@ import javax.swing.Icon
|
||||
import javax.swing.JComponent
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal abstract class ProPromoConfigurable : ConfigurableWithId, Configurable.Promo {
|
||||
abstract class ProPromoConfigurable : ConfigurableWithId, Configurable.Promo {
|
||||
override fun isModified(): Boolean = false
|
||||
override fun apply() = Unit
|
||||
override fun getPromoIcon(): Icon = AllIcons.Ultimate.Lock
|
||||
}
|
||||
|
||||
internal abstract class ProPromoConfigurableProvider(private val clazz: KClass<out Configurable>) : ConfigurableProvider() {
|
||||
abstract class ProPromoConfigurableProvider(private val clazz: KClass<out Configurable>) : ConfigurableProvider() {
|
||||
final override fun createConfigurable(): Configurable? {
|
||||
return clazz.java.getConstructor().newInstance()
|
||||
}
|
||||
@@ -27,7 +27,6 @@ internal class PromoDatabaseConfigurableProvider : ProPromoConfigurableProvider(
|
||||
internal class PromoJSConfigurableProvider : ProPromoConfigurableProvider(PromoJSConfigurable::class)
|
||||
internal class PromoTSConfigurableProvider : ProPromoConfigurableProvider(PromoTSConfigurable::class)
|
||||
internal class PromoDjangoConfigurableProvider : ProPromoConfigurableProvider(PromoDjangoConfigurable::class)
|
||||
internal class PromoAiAssistantConfigurableProvider : ProPromoConfigurableProvider(PromoAiAssistantConfigurable::class)
|
||||
internal class PromoJupyterConfigurableProvider : ProPromoConfigurableProvider(PromoJupyterConfigurable::class)
|
||||
internal class PromoRemoteSshConfigurableProvider : ProPromoConfigurableProvider(PromoRemoteSshConfigurable::class)
|
||||
|
||||
@@ -59,13 +58,6 @@ internal class PromoDjangoConfigurable : ProPromoConfigurable() {
|
||||
override fun createComponent(): JComponent = djangoFeatures(PromoEventSource.SETTINGS)
|
||||
}
|
||||
|
||||
internal class PromoAiAssistantConfigurable : ProPromoConfigurable() {
|
||||
override fun getId(): String = "promo.ai"
|
||||
override fun getDisplayName(): String = PyCharmCommunityCustomizationBundle.message("promo.configurable.ai")
|
||||
override fun createComponent(): JComponent = aiAssistantFeatures(PromoEventSource.SETTINGS)
|
||||
}
|
||||
|
||||
|
||||
internal class PromoJupyterConfigurable : ProPromoConfigurable() {
|
||||
override fun getId(): String = "promo.jupyter"
|
||||
override fun getDisplayName(): String = PyCharmCommunityCustomizationBundle.message("promo.configurable.jupyter")
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
package com.intellij.pycharm.community.ide.impl.promotion
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.llmInstaller.LLMIcons
|
||||
import com.intellij.llmInstaller.LLMInstallerBundle
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.*
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.pycharm.community.ide.impl.PyCharmCommunityCustomizationBundle
|
||||
@@ -30,32 +26,6 @@ private fun featurePage(@NlsContexts.Label title: String, items: List<PromoFeatu
|
||||
)
|
||||
}
|
||||
|
||||
private fun aiAssistantFeaturePage(@NlsContexts.Label title: String, items: List<PromoFeatureListItem>,
|
||||
source: PromoEventSource): JComponent {
|
||||
val page = object: PromoFeaturePage(
|
||||
productIcon = PythonIcons.Python.Pycharm,
|
||||
suggestedIde = PluginAdvertiserService.pyCharmProfessional,
|
||||
descriptionHtml = title,
|
||||
features = items,
|
||||
trialLabel = "",
|
||||
pluginId = null
|
||||
) {
|
||||
override fun getButtonOpenPromotionText() = PyCharmCommunityCustomizationBundle.message("feature.ai.assistant.open.toolwindow")
|
||||
|
||||
override fun getTitle() = PyCharmCommunityCustomizationBundle.message("feature.ai.assistant.title")
|
||||
}
|
||||
return PromoPages.build(
|
||||
page = page,
|
||||
openLearnMore = createOpenLearnMorePageLambda(source, PromoTopic.AiCodeCompletion),
|
||||
openDownloadLink = { dialog ->
|
||||
ProjectManager.getInstance().openProjects.forEach {
|
||||
activateAIAssistantToolwindow(it)
|
||||
}
|
||||
dialog?.close(DialogWrapper.CLOSE_EXIT_CODE)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
internal fun databaseFeatures(source: PromoEventSource): JComponent = featurePage(
|
||||
FeaturePromoBundle.message("feature.database.description.html", "https://www.jetbrains.com/help/pycharm/relational-databases.html"),
|
||||
listOf(
|
||||
@@ -89,13 +59,6 @@ internal fun djangoFeatures(source: PromoEventSource): JComponent {
|
||||
)
|
||||
}
|
||||
|
||||
internal fun aiAssistantFeatures(source: PromoEventSource): JComponent {
|
||||
return aiAssistantFeaturePage(
|
||||
PyCharmCommunityCustomizationBundle.message("feature.ai.assistant.description.html", "https://www.jetbrains.com/ai"),
|
||||
aiAssistantFeatureList,
|
||||
source
|
||||
)
|
||||
}
|
||||
|
||||
internal fun jupyterFeatures(source: PromoEventSource): JComponent {
|
||||
return featurePage(
|
||||
@@ -132,15 +95,6 @@ internal val djangoPromoFeatureList = listOf(
|
||||
PromoFeatureListItem(AllIcons.General.Web, PyCharmCommunityCustomizationBundle.message("feature.django.endpoints"))
|
||||
)
|
||||
|
||||
internal val aiAssistantFeatureList = listOf(
|
||||
PromoFeatureListItem(LLMIcons.Login.FeatureContext, LLMInstallerBundle.message("panel.activate.suggestion.enjoy.ai.features")),
|
||||
PromoFeatureListItem(LLMIcons.Login.FeatureComment, LLMInstallerBundle.message("panel.activate.suggestion.ask.anything")),
|
||||
PromoFeatureListItem(LLMIcons.Login.FeatureCodeBlock, LLMInstallerBundle.message("panel.activate.suggestion.generate.code")),
|
||||
PromoFeatureListItem(LLMIcons.Login.FeatureAnswer, LLMInstallerBundle.message("panel.activate.suggestion.explain.errors")),
|
||||
PromoFeatureListItem(LLMIcons.Login.FeatureDocs, LLMInstallerBundle.message("panel.activate.suggestion.generate.commit.messages"))
|
||||
|
||||
)
|
||||
|
||||
internal val javaScriptPromoFeatureList = listOf(
|
||||
PromoFeatureListItem(AllIcons.Actions.ReformatCode, FeaturePromoBundle.message("feature.javascript.code")),
|
||||
PromoFeatureListItem(AllIcons.Actions.SuggestedRefactoringBulb, FeaturePromoBundle.message("feature.javascript.refactor")),
|
||||
|
||||
@@ -25,7 +25,7 @@ object PyCharmPromoCollector : CounterUsagesCollector() {
|
||||
internal val PromoLearnModeEvent = GROUP.registerEvent("open.learn.more.page", PromoEventSourceField, PromoTopicField)
|
||||
}
|
||||
|
||||
internal enum class PromoEventSource {
|
||||
enum class PromoEventSource {
|
||||
GO_TO_ACTION,
|
||||
NEW_FILE,
|
||||
PROJECT_WIZARD,
|
||||
@@ -33,7 +33,7 @@ internal enum class PromoEventSource {
|
||||
FILE_PREVIEW,
|
||||
}
|
||||
|
||||
internal enum class PromoTopic {
|
||||
enum class PromoTopic {
|
||||
AiCodeCompletion,
|
||||
Database,
|
||||
Dataframe,
|
||||
@@ -52,7 +52,7 @@ internal fun createOpenDownloadPageLambda(promoEventSource: PromoEventSource, pr
|
||||
PromoOpenDownloadPageEvent.log(promoEventSource, promoTopic)
|
||||
}
|
||||
|
||||
internal fun createOpenLearnMorePageLambda(promoEventSource: PromoEventSource, promoTopic: PromoTopic): (String) -> Unit = { url ->
|
||||
fun createOpenLearnMorePageLambda(promoEventSource: PromoEventSource, promoTopic: PromoTopic): (String) -> Unit = { url ->
|
||||
BrowserUtil.browse(createLinkWithInfo(promoTopic, url))
|
||||
PromoLearnModeEvent.log(promoEventSource, promoTopic)
|
||||
}
|
||||
|
||||
@@ -83,11 +83,6 @@
|
||||
provider="com.intellij.pycharm.community.ide.impl.promotion.PromoDjangoConfigurableProvider"
|
||||
bundle="messages.PyCharmCommunityCustomizationBundle"
|
||||
key="promo.configurable.django"/>
|
||||
<applicationConfigurable id="promo.ai.assistant"
|
||||
groupId="tools"
|
||||
provider="com.intellij.pycharm.community.ide.impl.promotion.PromoAiAssistantConfigurableProvider"
|
||||
bundle="messages.PyCharmCommunityCustomizationBundle"
|
||||
key="promo.configurable.ai"/>
|
||||
<applicationConfigurable id="promo.remoteSsh"
|
||||
groupId="tools"
|
||||
provider="com.intellij.pycharm.community.ide.impl.promotion.PromoRemoteSshConfigurableProvider"
|
||||
|
||||
Reference in New Issue
Block a user