From 6228d0c595708d2d6a6f9662af7bd7c25c887799 Mon Sep 17 00:00:00 2001 From: MrCoder Date: Sun, 22 Dec 2024 21:26:57 +1100 Subject: [PATCH] perf: ensure actions are updated on EDT thread - Update BaseChangeSplitLayoutAction, ZenUmlEditorOnlyLayoutChangeAction, and ShowSequenceAction to specify EDT thread for action updates - Add getActionUpdateThread() method to each action class, returning ActionUpdateThread.EDT - This change ensures that action updates are performed on the Event Dispatch Thread, improving performance and avoiding potential threading issues --- .../actions/editorLayout/BaseChangeSplitLayoutAction.java | 7 +++++++ .../editorLayout/ZenUmlEditorOnlyLayoutChangeAction.java | 8 ++++++++ src/org/intellij/sequencer/ShowSequenceAction.java | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/src/org/intellij/plugins/markdown/ui/actions/editorLayout/BaseChangeSplitLayoutAction.java b/src/org/intellij/plugins/markdown/ui/actions/editorLayout/BaseChangeSplitLayoutAction.java index b1821e13..b01ceadc 100644 --- a/src/org/intellij/plugins/markdown/ui/actions/editorLayout/BaseChangeSplitLayoutAction.java +++ b/src/org/intellij/plugins/markdown/ui/actions/editorLayout/BaseChangeSplitLayoutAction.java @@ -1,5 +1,6 @@ package org.intellij.plugins.markdown.ui.actions.editorLayout; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Toggleable; @@ -17,6 +18,12 @@ protected BaseChangeSplitLayoutAction(@Nullable SplitFileEditor.SplitEditorLayou myLayoutToSet = layoutToSet; } + @Override + @NotNull + public ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } + @Override public void update(@NotNull AnActionEvent e) { final SplitFileEditor splitFileEditor = MarkdownActionUtil.findSplitEditor(e); diff --git a/src/org/intellij/plugins/markdown/ui/actions/editorLayout/ZenUmlEditorOnlyLayoutChangeAction.java b/src/org/intellij/plugins/markdown/ui/actions/editorLayout/ZenUmlEditorOnlyLayoutChangeAction.java index 41f06cac..2dd3af9b 100644 --- a/src/org/intellij/plugins/markdown/ui/actions/editorLayout/ZenUmlEditorOnlyLayoutChangeAction.java +++ b/src/org/intellij/plugins/markdown/ui/actions/editorLayout/ZenUmlEditorOnlyLayoutChangeAction.java @@ -1,9 +1,17 @@ package org.intellij.plugins.markdown.ui.actions.editorLayout; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import org.intellij.plugins.markdown.ui.split.SplitFileEditor; +import org.jetbrains.annotations.NotNull; public class ZenUmlEditorOnlyLayoutChangeAction extends BaseChangeSplitLayoutAction { protected ZenUmlEditorOnlyLayoutChangeAction() { super(SplitFileEditor.SplitEditorLayout.FIRST); } + + @Override + @NotNull + public ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/org/intellij/sequencer/ShowSequenceAction.java b/src/org/intellij/sequencer/ShowSequenceAction.java index 6eb505aa..dcad02cc 100644 --- a/src/org/intellij/sequencer/ShowSequenceAction.java +++ b/src/org/intellij/sequencer/ShowSequenceAction.java @@ -1,5 +1,6 @@ package org.intellij.sequencer; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -11,6 +12,7 @@ import org.intellij.sequencer.generator.filters.NoGetterSetterFilter; import org.intellij.sequencer.generator.filters.NoPrivateMethodsFilter; import org.intellij.sequencer.generator.filters.ProjectOnlyFilter; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; @@ -23,6 +25,12 @@ public class ShowSequenceAction extends AnAction { private boolean _noConstructors; private boolean _smartInterface = true; + @Override + @NotNull + public ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } + public ShowSequenceAction() { }