fix: don't use override-only actionPerformed to invoke action (#7608)
It's resolving one of problems during plugin verification. I manually tested this feature to make sure there are no regressions. Solves error: Override-only method AddLicenseKey.actionPerformed(AnActionEvent) is invoked in AddLicenseKey.createErrorAction$1.invoke(...). This method is marked with @ApiStatus.OverrideOnly annotation, which indicates that the method must be only overridden but not invoked by client code. See documentation of the @ApiStatus.OverrideOnly for more info.
This commit is contained in:
parent
6789833a77
commit
18ec563762
3 changed files with 15 additions and 19 deletions
|
|
@ -21,6 +21,7 @@ class ContinueErrorSubmitter : ErrorReportSubmitter() {
|
|||
consumer: Consumer<in SubmittedReportInfo>
|
||||
): Boolean {
|
||||
try {
|
||||
// todo: IdeaReportingEvent is deprecated; migrate to IdeaLoggingEvent + figure out how to read attachments
|
||||
val event = events.filterIsInstance<IdeaReportingEvent>()
|
||||
.firstOrNull() ?: return false
|
||||
service<ContinueSentryService>().report(
|
||||
|
|
|
|||
|
|
@ -5,22 +5,27 @@ import com.github.continuedev.continueintellijextension.utils.castNestedOrNull
|
|||
import com.intellij.notification.NotificationAction
|
||||
import com.intellij.notification.NotificationGroupManager
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
|
||||
class AddLicenseKey : AnAction() {
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val dialog = AddLicenseKeyDialog(e.project)
|
||||
performAddLicenseKey(e.project)
|
||||
}
|
||||
|
||||
private fun performAddLicenseKey(project: Project?) {
|
||||
if (project == null)
|
||||
return
|
||||
val dialog = AddLicenseKeyDialog(project)
|
||||
dialog.show()
|
||||
if (dialog.exitCode != DialogWrapper.OK_EXIT_CODE)
|
||||
return
|
||||
val messenger = e.project?.service<ContinuePluginService>()?.coreMessenger
|
||||
val messenger = project.service<ContinuePluginService>().coreMessenger
|
||||
?: return
|
||||
messenger.request("mdm/setLicenseKey", mapOf("licenseKey" to dialog.licenseKey), null) { response ->
|
||||
val isValid = response.castNestedOrNull<Boolean>("content") ?: false
|
||||
|
|
@ -28,7 +33,7 @@ class AddLicenseKey : AnAction() {
|
|||
createSuccessAction()
|
||||
else
|
||||
createErrorAction()
|
||||
notification.notify(e.project)
|
||||
notification.notify(project)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +42,7 @@ class AddLicenseKey : AnAction() {
|
|||
"License key is valid. A restart is required for it to take effect.",
|
||||
NotificationType.INFORMATION
|
||||
).addAction(
|
||||
NotificationAction.create("Restart IDE") { event, notification ->
|
||||
NotificationAction.create("Restart IDE") { _, _ ->
|
||||
ApplicationManager.getApplication().restart()
|
||||
}
|
||||
)
|
||||
|
|
@ -49,17 +54,7 @@ class AddLicenseKey : AnAction() {
|
|||
).addAction(
|
||||
NotificationAction.create("Try again") { event, notification ->
|
||||
notification.expire()
|
||||
val action = this@AddLicenseKey
|
||||
action.actionPerformed(
|
||||
AnActionEvent(
|
||||
null,
|
||||
event.dataContext,
|
||||
ActionPlaces.UNKNOWN,
|
||||
action.templatePresentation.clone(),
|
||||
ActionManager.getInstance(),
|
||||
0
|
||||
)
|
||||
)
|
||||
performAddLicenseKey(event.project)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package com.github.continuedev.continueintellijextension.license
|
|||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.ui.ValidationInfo
|
||||
import com.intellij.ui.dsl.builder.AlignX
|
||||
import com.intellij.ui.dsl.builder.bindText
|
||||
import com.intellij.ui.dsl.builder.panel
|
||||
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
|
||||
import javax.swing.JComponent
|
||||
|
||||
class AddLicenseKeyDialog(project: Project?) : DialogWrapper(project) {
|
||||
|
|
@ -22,7 +22,7 @@ class AddLicenseKeyDialog(project: Project?) : DialogWrapper(project) {
|
|||
panel {
|
||||
row {
|
||||
textField().bindText(::licenseKey)
|
||||
.horizontalAlign(HorizontalAlign.FILL)
|
||||
.align(AlignX.FILL)
|
||||
.focused()
|
||||
.validationOnApply {
|
||||
if (it.text.isBlank())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue