From 0b1973ee481ccdd2f5780de0d265b877042a4b92 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:16:59 +0200 Subject: [PATCH] fix ActionUpdateThread.OLD_EDT deprecation on DumbAwareActions --- .../actions/generation/CreateAPluginAction.java | 9 ++++++++- .../actions/generation/CreateAnObserverAction.java | 9 ++++++++- .../actions/generation/InjectAViewModelAction.java | 9 ++++++++- .../generation/OverrideClassByAPreferenceAction.java | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java b/src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java index 4aabe0fe9..3411a9dd1 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java @@ -5,6 +5,8 @@ package com.magento.idea.magento2plugin.actions.generation; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.ActionUpdateThreadAware; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.Caret; @@ -24,7 +26,7 @@ import com.magento.idea.magento2plugin.util.magento.plugin.IsPluginAllowedForMethodUtil; import org.jetbrains.annotations.NotNull; -public class CreateAPluginAction extends DumbAwareAction { +public class CreateAPluginAction extends DumbAwareAction implements ActionUpdateThreadAware { public static final String ACTION_NAME = "Create a new Plugin"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Plugin"; @@ -90,6 +92,11 @@ public boolean isDumbAware() { return false; } + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + private Pair findPhpClass(final @NotNull AnActionEvent event) { final PsiFile psiFile = event.getData(PlatformDataKeys.PSI_FILE); diff --git a/src/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java b/src/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java index e50692c0d..58ff1064f 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/CreateAnObserverAction.java @@ -6,6 +6,8 @@ package com.magento.idea.magento2plugin.actions.generation; import com.intellij.lang.ASTNode; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.ActionUpdateThreadAware; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.Caret; @@ -28,7 +30,7 @@ import com.magento.idea.magento2plugin.project.Settings; import org.jetbrains.annotations.NotNull; -public class CreateAnObserverAction extends DumbAwareAction { +public class CreateAnObserverAction extends DumbAwareAction implements ActionUpdateThreadAware { public static final String ACTION_NAME = "Create a new Observer for this event"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Observer"; @@ -87,6 +89,11 @@ public boolean isDumbAware() { return false; } + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + private PsiElement getElement(final @NotNull AnActionEvent event) { final Caret caret = event.getData(PlatformDataKeys.CARET); diff --git a/src/com/magento/idea/magento2plugin/actions/generation/InjectAViewModelAction.java b/src/com/magento/idea/magento2plugin/actions/generation/InjectAViewModelAction.java index 682f50b04..b869e22a5 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/InjectAViewModelAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/InjectAViewModelAction.java @@ -5,6 +5,8 @@ package com.magento.idea.magento2plugin.actions.generation; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.ActionUpdateThreadAware; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.Caret; @@ -21,7 +23,7 @@ import com.magento.idea.magento2plugin.project.Settings; import org.jetbrains.annotations.NotNull; -public class InjectAViewModelAction extends DumbAwareAction { +public class InjectAViewModelAction extends DumbAwareAction implements ActionUpdateThreadAware { public static final String ACTION_NAME = "Inject a new View Model for this block"; public static final String ACTION_DESCRIPTION = "Inject a new Magento 2 View Model"; @@ -68,6 +70,11 @@ public boolean isDumbAware() { return false; } + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + /** * Get focused (target) element for the event. * diff --git a/src/com/magento/idea/magento2plugin/actions/generation/OverrideClassByAPreferenceAction.java b/src/com/magento/idea/magento2plugin/actions/generation/OverrideClassByAPreferenceAction.java index 1daf41ed0..ffb88797b 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/OverrideClassByAPreferenceAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/OverrideClassByAPreferenceAction.java @@ -5,6 +5,8 @@ package com.magento.idea.magento2plugin.actions.generation; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.ActionUpdateThreadAware; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.DumbAwareAction; @@ -19,7 +21,7 @@ import com.magento.idea.magento2plugin.util.GetFirstClassOfFile; import org.jetbrains.annotations.NotNull; -public class OverrideClassByAPreferenceAction extends DumbAwareAction { +public class OverrideClassByAPreferenceAction extends DumbAwareAction implements ActionUpdateThreadAware { public static final String ACTION_NAME = "Override this class by a new Preference"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Preference"; public static final String INTERFACE_ACTION = "Override this interface by a new Preference"; @@ -75,6 +77,11 @@ public boolean isDumbAware() { return false; } + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + private Pair findPhpClass(@NotNull final AnActionEvent event) { final PsiFile psiFile = event.getData(PlatformDataKeys.PSI_FILE);