Skip to content

Commit

Permalink
Merge pull request #223 from ZenUml/fix/warning-old_edt
Browse files Browse the repository at this point in the history
refactor(jetbrains): specify action update thread for DocumentationAc…
  • Loading branch information
MrCoder authored Dec 23, 2024
2 parents 8594cd7 + c4651f8 commit 9c12671
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.zenuml.license.CheckLicense;
import org.jetbrains.annotations.NotNull;

Expand All @@ -19,6 +20,11 @@ public DemoAction() {
super(TITLE);
}

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

public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
final boolean isLicensed = CheckLicense.isLicensed();
final String message = "Sample Plugin with License Support.\nLicense successfully obtained: " + (isLicensed? "yes" : "no");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import org.jetbrains.annotations.NotNull;

public class DocumentationAction extends AnAction {
Expand All @@ -13,6 +14,11 @@ public DocumentationAction() {
super(TITLE);
}

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

public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
BrowserUtil.browse("https://zenuml.atlassian.net/wiki/spaces/ZEN/pages/233373697/Documentations");
}
Expand Down
42 changes: 41 additions & 1 deletion src/org/intellij/sequencer/SequencePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.intellij.sequencer.generator.filters.SingleClassFilter;
import org.intellij.sequencer.generator.filters.SingleMethodFilter;
import org.intellij.sequencer.ui.MyButtonlessScrollBarUI;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import javax.swing.filechooser.FileFilter;
Expand Down Expand Up @@ -170,6 +171,11 @@ public CloseAction() {
super("Close", "Close sequence", SequencePluginIcons.CLOSE_ICON);
}

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

public void actionPerformed(AnActionEvent event) {
_plugin.closeSequence(SequencePanel.this);
}
Expand All @@ -180,6 +186,11 @@ public ReGenerateAction() {
super("ReGenerate", "Regenerate diagram", SequencePluginIcons.REFRESH_ICON);
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
generate();

Expand All @@ -191,6 +202,11 @@ public ExportAction() {
super("Export", "Export image to file", SequencePluginIcons.EXPORT_ICON);
}

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

public void actionPerformed(AnActionEvent event) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
Expand Down Expand Up @@ -222,6 +238,12 @@ private class ExportTextAction extends AnAction {
public ExportTextAction() {
super("ExportTextFile", "Export call stack as text file", SequencePluginIcons.EXPORT_TEXT_ICON);
}

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

@Override
public void actionPerformed(AnActionEvent event) {
JFileChooser fileChooser = new JFileChooser();
Expand Down Expand Up @@ -258,6 +280,11 @@ public GotoSourceAction(ScreenObject screenObject) {
_screenObject = screenObject;
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
gotoSourceCode(_screenObject);
}
Expand All @@ -271,6 +298,11 @@ public RemoveClassAction(ObjectInfo objectInfo) {
_objectInfo = objectInfo;
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
_sequenceParams.getMethodFilter().addFilter(new SingleClassFilter(_objectInfo.getFullName()));
generate();
Expand All @@ -285,14 +317,18 @@ public RemoveMethodAction(MethodInfo methodInfo) {
_methodInfo = methodInfo;
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
_sequenceParams.getMethodFilter().addFilter(new SingleMethodFilter(
_methodInfo.getObjectInfo().getFullName(),
_methodInfo.getRealName(),
_methodInfo.getArgTypes()
));
generate();

}
}

Expand All @@ -307,6 +343,10 @@ public ExpendInterfaceAction(String face, String impl) {
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
_sequenceParams.getInterfaceImplFilter().put(
face,
Expand Down
17 changes: 11 additions & 6 deletions src/org/intellij/sequencer/SequencePlugin2.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
Expand All @@ -31,16 +30,12 @@
import org.intellij.sequencer.generator.filters.MethodFilter;
import org.intellij.sequencer.ui.ButtonTabComponent;
import org.intellij.sequencer.util.PsiUtil;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class SequencePlugin2 implements ProjectComponent {
Expand Down Expand Up @@ -366,6 +361,11 @@ private class LockUnlockAction extends AnAction {
_isLock = isLock;
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
_jTabbedPane.setIconAt(_index, _isLock? DISABLED_ICON: S_ICON);
}
Expand All @@ -379,6 +379,11 @@ private class CloseAction extends AnAction {
_index = index;
}

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

public void actionPerformed(AnActionEvent anActionEvent) {
closeSequenceAtIndex(_index);
}
Expand Down

0 comments on commit 9c12671

Please sign in to comment.