mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Record more informative statistics for actions created with DumbAwareAction.create()
GitOrigin-RevId: b2ee40e5868597b36ce05f52e12c2a3f8c687568
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d5be2396f1
commit
9098989ca2
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionWithDelegate;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -33,22 +34,12 @@ public abstract class DumbAwareAction extends AnAction implements DumbAware {
|
||||
|
||||
@NotNull
|
||||
public static DumbAwareAction create(@NotNull Consumer<? super AnActionEvent> actionPerformed) {
|
||||
return new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
actionPerformed.consume(e);
|
||||
}
|
||||
};
|
||||
return new SimpleDumbAwareAction(actionPerformed);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static DumbAwareAction create(@Nullable String text, @NotNull Consumer<? super AnActionEvent> actionPerformed) {
|
||||
return new DumbAwareAction(text) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
actionPerformed.consume(e);
|
||||
}
|
||||
};
|
||||
return new SimpleDumbAwareAction(text, actionPerformed);
|
||||
}
|
||||
|
||||
protected DumbAwareAction() {
|
||||
@@ -61,4 +52,28 @@ public abstract class DumbAwareAction extends AnAction implements DumbAware {
|
||||
protected DumbAwareAction(@Nullable String text, @Nullable String description, @Nullable Icon icon) {
|
||||
super(text, description, icon);
|
||||
}
|
||||
|
||||
private static class SimpleDumbAwareAction extends DumbAwareAction implements ActionWithDelegate<Consumer<? super AnActionEvent>> {
|
||||
private final Consumer<? super AnActionEvent> myActionPerformed;
|
||||
|
||||
private SimpleDumbAwareAction(Consumer<? super AnActionEvent> actionPerformed) {
|
||||
myActionPerformed = actionPerformed;
|
||||
}
|
||||
|
||||
private SimpleDumbAwareAction(String text, Consumer<? super AnActionEvent> actionPerformed) {
|
||||
super(text);
|
||||
myActionPerformed = actionPerformed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
myActionPerformed.consume(e);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Consumer<? super AnActionEvent> getDelegate() {
|
||||
return myActionPerformed;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user