Skip to content

Commit

Permalink
fix ActionUpdateThread.OLD_EDT deprecation on DumbAwareActions
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkwiecinski committed Jul 10, 2024
1 parent ad86638 commit 6e1b04a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -90,6 +92,11 @@ public boolean isDumbAware() {
return false;
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

private Pair<PsiFile, PhpClass> findPhpClass(final @NotNull AnActionEvent event) {
final PsiFile psiFile = event.getData(PlatformDataKeys.PSI_FILE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -68,6 +70,11 @@ public boolean isDumbAware() {
return false;
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

/**
* Get focused (target) element for the event.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -75,6 +77,11 @@ public boolean isDumbAware() {
return false;
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

private Pair<PsiFile, PhpClass> findPhpClass(@NotNull final AnActionEvent event) {
final PsiFile psiFile = event.getData(PlatformDataKeys.PSI_FILE);

Expand Down

0 comments on commit 6e1b04a

Please sign in to comment.