mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make usages of AnAction.update()/actionPerformed() pass not null event (in preparation of notnull it)
This commit is contained in:
+10
-10
@@ -27,9 +27,9 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
"Do not stop if called from: " +
|
||||
StringUtil.getShortName(StringUtil.substringBefore(myCaller, "(") ?: myCaller)) {
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
override fun update(e: AnActionEvent) {
|
||||
with(myBreakpoint.properties as JavaBreakpointProperties<*>) {
|
||||
e?.presentation?.setEnabled(!isCALLER_FILTERS_ENABLED || !callerExclusionFilters.contains(ClassFilter(myCaller)))
|
||||
e.presentation.setEnabled(!isCALLER_FILTERS_ENABLED || !callerExclusionFilters.contains(ClassFilter(myCaller)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
"Stop only if called from: " +
|
||||
StringUtil.getShortName(StringUtil.substringBefore(myCaller, "(") ?: myCaller)) {
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
override fun update(e: AnActionEvent) {
|
||||
with(myBreakpoint.properties as JavaBreakpointProperties<*>) {
|
||||
e?.presentation?.setEnabled(!isCALLER_FILTERS_ENABLED || !callerFilters.contains(ClassFilter(myCaller)))
|
||||
e.presentation.setEnabled(!isCALLER_FILTERS_ENABLED || !callerFilters.contains(ClassFilter(myCaller)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,9 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
internal class AddInstanceFilter(breakpoint: XBreakpoint<*>, private val myInstance: Long) :
|
||||
BreakpointIntentionAction(breakpoint, "Stop only in the current object") {
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
override fun update(e: AnActionEvent) {
|
||||
with(myBreakpoint.properties as JavaBreakpointProperties<*>) {
|
||||
e?.presentation?.setEnabled(!isINSTANCE_FILTERS_ENABLED || !instanceFilters.contains(InstanceFilter.create(myInstance)))
|
||||
e.presentation.setEnabled(!isINSTANCE_FILTERS_ENABLED || !instanceFilters.contains(InstanceFilter.create(myInstance)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
internal class AddClassFilter(breakpoint: XBreakpoint<*>, private val myClass: String) :
|
||||
BreakpointIntentionAction(breakpoint, "Stop only in the class: ${StringUtil.getShortName(myClass)}") {
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
override fun update(e: AnActionEvent) {
|
||||
with(myBreakpoint.properties as JavaBreakpointProperties<*>) {
|
||||
e?.presentation?.setEnabled(!isCLASS_FILTERS_ENABLED || !classFilters.contains(ClassFilter(myClass)))
|
||||
e.presentation.setEnabled(!isCLASS_FILTERS_ENABLED || !classFilters.contains(ClassFilter(myClass)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
internal class AddClassNotFilter(breakpoint: XBreakpoint<*>, private val myClass: String) :
|
||||
BreakpointIntentionAction(breakpoint, "Do not stop in the class: ${StringUtil.getShortName(myClass)}") {
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
override fun update(e: AnActionEvent) {
|
||||
with(myBreakpoint.properties as JavaBreakpointProperties<*>) {
|
||||
e?.presentation?.setEnabled(!isCLASS_FILTERS_ENABLED || !classExclusionFilters.contains(ClassFilter(myClass)))
|
||||
e.presentation.setEnabled(!isCLASS_FILTERS_ENABLED || !classExclusionFilters.contains(ClassFilter(myClass)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -54,7 +54,6 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FilteringIterator;
|
||||
import java.util.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -224,7 +223,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
if (popupItems.isEmpty()) {
|
||||
new AttachFilesAction(myDescriptor.getAttachFilesActionName()).actionPerformed(null);
|
||||
new AttachFilesAction(myDescriptor.getAttachFilesActionName()).perform();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -417,6 +416,10 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@Nullable AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
void perform() {
|
||||
VirtualFile toSelect = getFileToSelect();
|
||||
List<OrderRoot> roots = selectRoots(toSelect);
|
||||
if (roots.isEmpty()) return;
|
||||
|
||||
@@ -217,7 +217,7 @@ public abstract class AnAction implements PossiblyDumbAware {
|
||||
*
|
||||
* @param e Carries information on the invocation place and data available
|
||||
*/
|
||||
public void update(AnActionEvent e) {
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ public abstract class AnAction implements PossiblyDumbAware {
|
||||
*
|
||||
* @param e Carries information on the invocation place
|
||||
*/
|
||||
public abstract void actionPerformed(AnActionEvent e);
|
||||
public abstract void actionPerformed(@NotNull AnActionEvent e);
|
||||
|
||||
protected void setShortcutSet(@NotNull ShortcutSet shortcutSet) {
|
||||
if (myIsGlobal && myShortcutSet != shortcutSet) {
|
||||
|
||||
@@ -42,6 +42,10 @@ public class CloseAction extends AnAction implements DumbAware {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
final RunContentDescriptor contentDescriptor = getContentDescriptor();
|
||||
if (contentDescriptor == null) {
|
||||
return;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.execution.util;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -66,7 +66,7 @@ public abstract class ListTableWithButtons<T> extends Observable {
|
||||
int nextRow = nextColumn == 0 ? row + 1 : row;
|
||||
if (nextRow > myTableView.getRowCount() - 1) {
|
||||
if (myElements.isEmpty() || !ListTableWithButtons.this.isEmpty(myElements.get(myElements.size() - 1))) {
|
||||
ToolbarDecorator.findAddButton(myPanel).actionPerformed(null);
|
||||
ToolbarDecorator.findAddButton(myPanel).actionPerformed(AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, dataId -> null));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-2
@@ -150,7 +150,7 @@ internal class DaemonTooltipWithActionRenderer(text: String?,
|
||||
buttons.add(createKeymapHint(shortcutShowAllActionsText), gridBag.next().fillCellHorizontally().insets(0, 4, 0, 20))
|
||||
|
||||
actions.add(object : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
runFixAction.run()
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ internal class DaemonTooltipWithActionRenderer(text: String?,
|
||||
})
|
||||
|
||||
actions.add(object : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
showAllFixes.run()
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -47,6 +47,10 @@ public class WrapWithCustomTemplateAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
final Document document = myEditor.getDocument();
|
||||
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
if (file != null) {
|
||||
|
||||
@@ -62,13 +62,13 @@ public class UnwrapHandler implements CodeInsightActionHandler {
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
if (!EditorModificationUtil.checkModificationAllowed(editor)) return;
|
||||
List<AnAction> options = collectOptions(project, editor, file);
|
||||
List<MyUnwrapAction> options = collectOptions(project, editor, file);
|
||||
selectOption(options, editor, file);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<AnAction> collectOptions(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
List<AnAction> result = new ArrayList<>();
|
||||
private static List<MyUnwrapAction> collectOptions(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
List<MyUnwrapAction> result = new ArrayList<>();
|
||||
|
||||
UnwrapDescriptor descriptor = getUnwrapDescription(file);
|
||||
|
||||
@@ -88,24 +88,24 @@ public class UnwrapHandler implements CodeInsightActionHandler {
|
||||
return LanguageUnwrappers.INSTANCE.forLanguage(file.getLanguage());
|
||||
}
|
||||
|
||||
private static AnAction createUnwrapAction(@NotNull Unwrapper u, @NotNull PsiElement el, @NotNull Editor ed, @NotNull Project p) {
|
||||
private static MyUnwrapAction createUnwrapAction(@NotNull Unwrapper u, @NotNull PsiElement el, @NotNull Editor ed, @NotNull Project p) {
|
||||
return new MyUnwrapAction(p, ed, u, el);
|
||||
}
|
||||
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
protected void selectOption(List<MyUnwrapAction> options, Editor editor, PsiFile file) {
|
||||
if (options.isEmpty()) return;
|
||||
|
||||
if (!getUnwrapDescription(file).showOptionsDialog() ||
|
||||
ApplicationManager.getApplication().isUnitTestMode()
|
||||
) {
|
||||
options.get(0).actionPerformed(null);
|
||||
options.get(0).perform();
|
||||
return;
|
||||
}
|
||||
|
||||
showPopup(options, editor);
|
||||
}
|
||||
|
||||
private static void showPopup(final List<AnAction> options, Editor editor) {
|
||||
private static void showPopup(final List<? extends AnAction> options, Editor editor) {
|
||||
final ScopeHighlighter highlighter = new ScopeHighlighter(editor);
|
||||
|
||||
List<String> model = options.stream().map(a -> ((MyUnwrapAction)a).getName()).collect(Collectors.toList());
|
||||
@@ -122,7 +122,7 @@ public class UnwrapHandler implements CodeInsightActionHandler {
|
||||
.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
|
||||
.setResizable(false)
|
||||
.setRequestFocus(true)
|
||||
.setItemChosenCallback((selectedValue) -> optionByName.apply(selectedValue).actionPerformed(null))
|
||||
.setItemChosenCallback((selectedValue) -> optionByName.apply(selectedValue).perform())
|
||||
.setItemSelectedCallback(s -> {
|
||||
if (s != null) {
|
||||
MyUnwrapAction a = optionByName.apply(s);
|
||||
@@ -145,7 +145,7 @@ public class UnwrapHandler implements CodeInsightActionHandler {
|
||||
return manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
|
||||
}
|
||||
|
||||
private static class MyUnwrapAction extends AnAction {
|
||||
protected static class MyUnwrapAction extends AnAction {
|
||||
private static final Key<Integer> CARET_POS_KEY = new Key<>("UNWRAP_HANDLER_CARET_POSITION");
|
||||
|
||||
private final Project myProject;
|
||||
@@ -164,6 +164,10 @@ public class UnwrapHandler implements CodeInsightActionHandler {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
void perform() {
|
||||
final PsiFile file = myElement.getContainingFile();
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ internal class RunDashboardTypesPanel(private val myProject: Project) : JPanel(B
|
||||
val actionGroup = DefaultActionGroup(null, false)
|
||||
configurationTypes.forEach {
|
||||
actionGroup.add(object : AnAction(it.displayName, null, it.icon) {
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
listModel.add(it)
|
||||
listModel.sort(IGNORE_CASE_DISPLAY_NAME_COMPARATOR)
|
||||
list.selectedIndex = listModel.getElementIndex(it)
|
||||
@@ -109,7 +109,7 @@ internal class RunDashboardTypesPanel(private val myProject: Project) : JPanel(B
|
||||
}
|
||||
if (hiddenCount > 0) {
|
||||
actionGroup.add(object : AnAction(ExecutionBundle.message("show.irrelevant.configurations.action.name", hiddenCount)) {
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
showAddPopup(button, false)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1266,7 +1266,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
|
||||
for (AnAction action : myMinimizedViewActions.getChildren(null)) {
|
||||
Content content = ((RestoreViewAction)action).getContent();
|
||||
if (key.equals(content.getUserData(ViewImpl.ID))) {
|
||||
action.actionPerformed(null);
|
||||
action.actionPerformed(AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, dataId -> null));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,20 +25,19 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry;
|
||||
import com.intellij.util.Function;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import gnu.trove.TObjectIntProcedure;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ComputeVirtualFileNameStatAction extends AnAction implements DumbAware {
|
||||
public ComputeVirtualFileNameStatAction() {
|
||||
super("Compute VF Name Statistics");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ComputeVirtualFileNameStatAction().actionPerformed(null);
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -569,7 +569,7 @@ public abstract class PerFileConfigurableBase<T> implements SearchableConfigurab
|
||||
AnActionEvent event = AnActionEvent.createFromAnAction(changeAction, null, ActionPlaces.UNKNOWN, dataContext);
|
||||
changeAction.update(event);
|
||||
panel.revalidate();
|
||||
if (!editor) myResetRunnables.add(() -> changeAction.update(null));
|
||||
if (!editor) myResetRunnables.add(() -> changeAction.update(event));
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SystemHealthMonitor implements ApplicationComponent {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
|
||||
notification.expire();
|
||||
ActionManager.getInstance().getAction(SWITCH_JDK_ACTION).actionPerformed(null);
|
||||
ActionManager.getInstance().getAction(SWITCH_JDK_ACTION).actionPerformed(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,6 +62,10 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(@Nullable AnActionEvent e) {
|
||||
Project project = e != null ? e.getProject() : null;
|
||||
perform(project);
|
||||
}
|
||||
|
||||
public void perform(Project project) {
|
||||
new Task.Modal(project, "Looking for Available JDKs", true) {
|
||||
private JdkBundleList myBundleList;
|
||||
private File myConfigFile;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DarculaTest {
|
||||
@Override
|
||||
public void eventDispatched(AWTEvent event) {
|
||||
if (event instanceof KeyEvent && event.getID() == KeyEvent.KEY_PRESSED && ((KeyEvent)event).getKeyCode() == KeyEvent.VK_F1) {
|
||||
new ShowUIDefaultsAction().actionPerformed(null);
|
||||
new ShowUIDefaultsAction().perform(null);
|
||||
}
|
||||
}
|
||||
}, AWTEvent.KEY_EVENT_MASK);
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.awt.*;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
@@ -44,11 +43,15 @@ public class FocusDebuggerAction extends AnAction implements DumbAware {
|
||||
|
||||
public FocusDebuggerAction() {
|
||||
if (Boolean.getBoolean("idea.ui.debug.mode")) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> actionPerformed(null));
|
||||
ApplicationManager.getApplication().invokeLater(() -> perform());
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
private void perform() {
|
||||
if (myFocusDrawer == null) {
|
||||
myFocusDrawer = new FocusDrawer();
|
||||
myFocusDrawer.start();
|
||||
|
||||
+21
-16
@@ -149,7 +149,7 @@ public class RecentProjectPanel extends JPanel {
|
||||
if (cellBounds.contains(event.getPoint())) {
|
||||
Object selection = myList.getSelectedValue();
|
||||
if (Registry.is("removable.welcome.screen.projects") && rectInListCoordinatesContains(cellBounds, event.getPoint())) {
|
||||
removeRecentProjectAction.actionPerformed(null);
|
||||
removeRecentProject();
|
||||
} else if (selection != null) {
|
||||
AnAction selectedAction = (AnAction) selection;
|
||||
AnActionEvent actionEvent = AnActionEvent.createFromInputEvent(selectedAction, event, ActionPlaces.WELCOME_SCREEN);
|
||||
@@ -186,21 +186,7 @@ public class RecentProjectPanel extends JPanel {
|
||||
removeRecentProjectAction = new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Object[] selection = myList.getSelectedValues();
|
||||
|
||||
if (selection != null && selection.length > 0) {
|
||||
final int rc = Messages.showOkCancelDialog(RecentProjectPanel.this,
|
||||
"Remove '" + StringUtil.join(selection, action -> ((AnAction)action).getTemplatePresentation().getText(), "'\n'") +
|
||||
"' from recent projects list?",
|
||||
"Remove Recent Project",
|
||||
Messages.getQuestionIcon());
|
||||
if (rc == Messages.OK) {
|
||||
for (Object projectAction : selection) {
|
||||
removeRecentProjectElement(projectAction);
|
||||
}
|
||||
ListUtil.removeSelectedItems(myList);
|
||||
}
|
||||
}
|
||||
removeRecentProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,6 +230,25 @@ public class RecentProjectPanel extends JPanel {
|
||||
setBorder(new LineBorder(WelcomeScreenColors.BORDER_COLOR));
|
||||
}
|
||||
|
||||
private void removeRecentProject() {
|
||||
Object[] selection = myList.getSelectedValues();
|
||||
|
||||
if (selection != null && selection.length > 0) {
|
||||
final int rc = Messages.showOkCancelDialog(RecentProjectPanel.this,
|
||||
"Remove '" + StringUtil
|
||||
.join(selection, action -> ((AnAction)action).getTemplatePresentation().getText(), "'\n'") +
|
||||
"' from recent projects list?",
|
||||
"Remove Recent Project",
|
||||
Messages.getQuestionIcon());
|
||||
if (rc == Messages.OK) {
|
||||
for (Object projectAction : selection) {
|
||||
removeRecentProjectElement(projectAction);
|
||||
}
|
||||
ListUtil.removeSelectedItems(myList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isPathValid(String path) {
|
||||
return myChecker == null || myChecker.isValid(path);
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ import java.nio.file.Paths
|
||||
* @author traff
|
||||
*/
|
||||
class AttachProjectAction : AnAction("Attach project..."), DumbAware {
|
||||
override fun update(e: AnActionEvent?) {
|
||||
e?.presentation?.isEnabledAndVisible = ProjectAttachProcessor.canAttachToProject() &&
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = ProjectAttachProcessor.canAttachToProject() &&
|
||||
GeneralSettings.getInstance().confirmOpenNewProject != GeneralSettings.OPEN_PROJECT_ASK
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val descriptor = OpenProjectFileChooserDescriptor(true)
|
||||
val project = e?.getData(CommonDataKeys.PROJECT)
|
||||
val project = e.getData(CommonDataKeys.PROJECT)
|
||||
|
||||
|
||||
FileChooser.chooseFiles(descriptor, project, null) { files ->
|
||||
|
||||
@@ -48,6 +48,11 @@ import java.util.stream.Collectors;
|
||||
public class ShowUIDefaultsAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = getEventProject(e);
|
||||
perform(project);
|
||||
}
|
||||
|
||||
public void perform(Project project) {
|
||||
final UIDefaults defaults = UIManager.getDefaults();
|
||||
Enumeration keys = defaults.keys();
|
||||
final Object[][] data = new Object[defaults.size()][2];
|
||||
@@ -61,7 +66,6 @@ public class ShowUIDefaultsAction extends AnAction implements DumbAware {
|
||||
|
||||
Arrays.sort(data, (o1, o2) -> StringUtil.naturalCompare(o1[0 ].toString(), o2[0].toString()));
|
||||
|
||||
final Project project = getEventProject(e);
|
||||
new DialogWrapper(project) {
|
||||
{
|
||||
setTitle("Edit LaF Defaults");
|
||||
@@ -200,7 +204,7 @@ public class ShowUIDefaultsAction extends AnAction implements DumbAware {
|
||||
|
||||
private @Nullable Integer editNumber(String key, String value) {
|
||||
String newValue = Messages.showInputDialog(getRootPane(), "Enter new value for " + key, "Number Editor", null, value,
|
||||
new InputValidator() {
|
||||
new InputValidator() {
|
||||
@Override
|
||||
public boolean checkInput(String inputString) {
|
||||
try {
|
||||
|
||||
@@ -36,9 +36,9 @@ public abstract class UnwrapTestCase extends LightPlatformCodeInsightTestCase {
|
||||
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
protected void selectOption(List<UnwrapHandler.MyUnwrapAction> options, Editor editor, PsiFile file) {
|
||||
if (options.isEmpty()) return;
|
||||
options.get(option).actionPerformed(null);
|
||||
options.get(option).perform();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class UnwrapTestCase extends LightPlatformCodeInsightTestCase {
|
||||
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
protected void selectOption(List<UnwrapHandler.MyUnwrapAction> options, Editor editor, PsiFile file) {
|
||||
for (AnAction each : options) {
|
||||
actualOptions.add(each.getTemplatePresentation().getText());
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ class PerformScriptAction : AnAction(null, "Run GUI Script", AllIcons.Actions.Ex
|
||||
val LOG: Logger = Logger.getInstance(PerformScriptAction::class.java)
|
||||
}
|
||||
|
||||
override fun actionPerformed(p0: AnActionEvent?) {
|
||||
override fun actionPerformed(p0: AnActionEvent) {
|
||||
LOG.info("Compile and evaluate current script buffer")
|
||||
Notifier.updateStatus("${Notifier.LONG_OPERATION_PREFIX}Compiling and performing current script")
|
||||
val editor = GuiRecorderManager.getEditor()
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.intellij.testGuiFramework.recorder.GuiRecorderManager
|
||||
|
||||
class ShowGuiEditorWindowAction : AnAction() {
|
||||
|
||||
override fun actionPerformed(p0: AnActionEvent?) {
|
||||
override fun actionPerformed(p0: AnActionEvent) {
|
||||
val frame = GuiRecorderManager.frame
|
||||
if (!frame.isShowing) {
|
||||
StartPauseRecAction().setSelected(null, true)
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import com.intellij.testGuiFramework.recorder.ui.Notifier
|
||||
*/
|
||||
class StopRecAction : AnAction(null, "Stop Recording, Compiling, Running and Clear Buffer", AllIcons.Actions.Suspend) {
|
||||
|
||||
override fun actionPerformed(p0: AnActionEvent?) {
|
||||
override fun actionPerformed(p0: AnActionEvent) {
|
||||
GlobalActionRecorder.deactivate()
|
||||
GuiRecorderManager.cancelCurrentTask()
|
||||
Notifier.updateStatus("Stopped")
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
package com.intellij.openapi.vcs.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
|
||||
import com.intellij.ui.SearchTextField;
|
||||
@@ -44,7 +46,7 @@ public abstract class SearchFieldAction extends AnAction implements CustomCompon
|
||||
if ((KeyEvent.VK_ENTER == e.getKeyCode()) || ('\n' == e.getKeyChar())) {
|
||||
e.consume();
|
||||
addCurrentTextToHistory();
|
||||
actionPerformed(null);
|
||||
perform();
|
||||
}
|
||||
return super.preprocessEventForTextField(e);
|
||||
}
|
||||
@@ -52,12 +54,12 @@ public abstract class SearchFieldAction extends AnAction implements CustomCompon
|
||||
@Override
|
||||
protected void onFocusLost() {
|
||||
myField.addCurrentTextToHistory();
|
||||
actionPerformed(null);
|
||||
perform();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFieldCleared() {
|
||||
actionPerformed(null);
|
||||
perform();
|
||||
}
|
||||
};
|
||||
Border border = myField.getBorder();
|
||||
@@ -85,6 +87,10 @@ public abstract class SearchFieldAction extends AnAction implements CustomCompon
|
||||
myComponent.add(myField);
|
||||
}
|
||||
|
||||
private void perform() {
|
||||
actionPerformed(AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, dataId -> null));
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return myField.getText();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.ClickListener;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
@@ -49,14 +48,18 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
e.consume();
|
||||
actionPerformed(null);
|
||||
perform();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void actionPerformed(@Nullable AnActionEvent e);
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
public void perform() {}
|
||||
|
||||
@Override
|
||||
public JComponent createCustomComponent(Presentation presentation) {
|
||||
@@ -87,7 +90,7 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen
|
||||
new ClickListener() {
|
||||
@Override
|
||||
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
|
||||
actionPerformed(null);
|
||||
perform();
|
||||
return true;
|
||||
}
|
||||
}.installOn(label);
|
||||
|
||||
@@ -537,7 +537,7 @@ class PartialLocalLineStatusTracker(project: Project,
|
||||
|
||||
val moveChangesShortcutSet = ActionManager.getInstance().getAction("Vcs.MoveChangedLinesToChangelist").shortcutSet
|
||||
object : DumbAwareAction() {
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
link.linkLabel.doClick()
|
||||
}
|
||||
}.registerCustomShortcutSet(moveChangesShortcutSet, editor.component, disposable)
|
||||
|
||||
+1
-1
@@ -559,7 +559,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
|
||||
}
|
||||
}
|
||||
else {
|
||||
createDefaultEditAction(project, producer).actionPerformed(null);
|
||||
perform(project, producer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+9
-7
@@ -100,13 +100,15 @@ public abstract class AbstractLanguageInjectionSupport extends LanguageInjection
|
||||
}
|
||||
|
||||
public static AnAction createDefaultEditAction(Project project, Factory<BaseInjection> producer) {
|
||||
return DumbAwareAction.create(e -> {
|
||||
BaseInjection originalInjection = producer.create();
|
||||
BaseInjection newInjection = showDefaultInjectionUI(project, originalInjection.copy());
|
||||
if (newInjection != null) {
|
||||
originalInjection.copyFrom(newInjection);
|
||||
}
|
||||
});
|
||||
return DumbAwareAction.create(e -> perform(project, producer));
|
||||
}
|
||||
|
||||
protected static void perform(Project project, Factory<BaseInjection> producer) {
|
||||
BaseInjection originalInjection = producer.create();
|
||||
BaseInjection newInjection = showDefaultInjectionUI(project, originalInjection.copy());
|
||||
if (newInjection != null) {
|
||||
originalInjection.copyFrom(newInjection);
|
||||
}
|
||||
}
|
||||
|
||||
public static AnAction createDefaultAddAction(final Project project,
|
||||
|
||||
+1
-1
@@ -376,7 +376,7 @@ public class XmlLanguageInjectionSupport extends AbstractLanguageInjectionSuppor
|
||||
}
|
||||
}
|
||||
else {
|
||||
createDefaultEditAction(project, producer).actionPerformed(null);
|
||||
perform(project, producer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,9 +34,7 @@ import org.jetbrains.plugins.github.util.GithubUtil
|
||||
open class GithubOpenInBrowserActionGroup
|
||||
: ActionGroup("Open on GitHub", "Open corresponding link in browser", AllIcons.Vcs.Vendors.Github) {
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
if (e == null) return
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val repositories = getData(e.dataContext)?.first
|
||||
e.presentation.isEnabledAndVisible = repositories != null && repositories.isNotEmpty()
|
||||
}
|
||||
@@ -53,9 +51,7 @@ open class GithubOpenInBrowserActionGroup
|
||||
|
||||
override fun isPopup(): Boolean = true
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
if (e == null) return
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
getData(e.dataContext)?.let { GithubOpenInBrowserAction(it.first.first(), it.second) }?.actionPerformed(e)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ import org.jetbrains.plugins.github.util.GithubGitHelper
|
||||
import javax.swing.Icon
|
||||
|
||||
abstract class LegacySingleAccountActionGroup(text: String?, description: String?, icon: Icon?) : DumbAwareAction(text, description, icon) {
|
||||
override fun update(e: AnActionEvent?) {
|
||||
if (e == null) return
|
||||
override fun update(e: AnActionEvent) {
|
||||
val project = e.getData(CommonDataKeys.PROJECT)
|
||||
val file = e.getData(CommonDataKeys.VIRTUAL_FILE)
|
||||
if (project == null || project.isDefault) {
|
||||
@@ -44,8 +43,7 @@ abstract class LegacySingleAccountActionGroup(text: String?, description: String
|
||||
e.presentation.isEnabledAndVisible = true
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
if (e == null) return
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.getData(CommonDataKeys.PROJECT)
|
||||
val file = e.getData(CommonDataKeys.VIRTUAL_FILE)
|
||||
if (project == null || project.isDefault) return
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ internal class GithubAccountsPanel(private val project: Project,
|
||||
.setAddAction { addAccount() }
|
||||
.addExtraAction(object : ToolbarDecorator.ElementActionButton("Set default",
|
||||
AllIcons.Actions.Checked) {
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
if (accountList.selectedValue.projectDefault) return
|
||||
for (accountData in accountListModel.items) {
|
||||
if (accountData == accountList.selectedValue) {
|
||||
|
||||
@@ -33,13 +33,13 @@ import javax.swing.JPanel
|
||||
|
||||
class GroovyScriptingShellAction : AnAction() {
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent?) {
|
||||
val project = e?.project ?: return
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
initConsole(project)
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
e?.presentation?.isEnabledAndVisible = ApplicationManager.getApplication().isInternal
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = ApplicationManager.getApplication().isInternal
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -31,7 +32,7 @@ public abstract class MoreAction extends DumbAwareAction implements CustomCompon
|
||||
myPanel.setLayout(layout);
|
||||
myLoadMoreBtn = new JButton(name);
|
||||
myLoadMoreBtn.setMargin(JBUI.insets(2));
|
||||
myLoadMoreBtn.addActionListener(e -> this.actionPerformed(null));
|
||||
myLoadMoreBtn.addActionListener(__ -> perform());
|
||||
myPanel.add(myLoadMoreBtn);
|
||||
myLabel = new JLabel("Loading...");
|
||||
myLabel.setForeground(UIUtil.getInactiveTextColor());
|
||||
@@ -59,4 +60,11 @@ public abstract class MoreAction extends DumbAwareAction implements CustomCompon
|
||||
public void setVisible(boolean b) {
|
||||
myVisible = b;
|
||||
}
|
||||
|
||||
public abstract void perform();
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ public class ToBeMergedDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
public void perform() {
|
||||
// TODO: This setVisible() is necessary because MoreXAction shows "Loading..." text when disabled
|
||||
myMore500Action.setVisible(false);
|
||||
myMore100Action.setEnabled(false);
|
||||
|
||||
@@ -37,6 +37,10 @@ public class SelectAllAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
perform();
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
RadComponent rootComponent = myArea.getRootComponent();
|
||||
if (rootComponent != null) {
|
||||
final List<RadComponent> components = new ArrayList<>();
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.designer.componentTree;
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.designer.actions.DesignerActionPanel;
|
||||
import com.intellij.designer.actions.SelectAllAction;
|
||||
import com.intellij.designer.actions.StartInplaceEditing;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
@@ -84,7 +85,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myDesigner != null) {
|
||||
myDesigner.getActionPanel().createSelectAllAction(myDesigner.getSurfaceArea()).actionPerformed(null);
|
||||
((SelectAllAction)myDesigner.getActionPanel().createSelectAllAction(myDesigner.getSurfaceArea())).perform();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PyUnwrapperTest extends PyTestCase {
|
||||
myFixture.configureByFile(before);
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
protected void selectOption(List<UnwrapHandler.MyUnwrapAction> options, Editor editor, PsiFile file) {
|
||||
assertTrue("No available options to unwrap", !options.isEmpty());
|
||||
options.get(option).actionPerformed(null);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class PyUnwrapperTest extends PyTestCase {
|
||||
myFixture.configureByFile(before);
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
protected void selectOption(List<UnwrapHandler.MyUnwrapAction> options, Editor editor, PsiFile file) {
|
||||
assertEmpty(options);
|
||||
}
|
||||
};
|
||||
@@ -96,7 +96,7 @@ public class PyUnwrapperTest extends PyTestCase {
|
||||
myFixture.configureByFile(before);
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
protected void selectOption(List<UnwrapHandler.MyUnwrapAction> options, Editor editor, PsiFile file) {
|
||||
for (AnAction option : options) {
|
||||
assertFalse("\"" + optionName + "\" is available to unwrap ", option.toString().contains(optionName));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SurroundWithEmmetAction extends BaseCodeInsightAction {
|
||||
|
||||
ZenCodingTemplate emmetCustomTemplate = CustomLiveTemplate.EP_NAME.findExtension(ZenCodingTemplate.class);
|
||||
if (emmetCustomTemplate != null) {
|
||||
new WrapWithCustomTemplateAction(emmetCustomTemplate, editor, file, ContainerUtil.newHashSet()).actionPerformed(null);
|
||||
new WrapWithCustomTemplateAction(emmetCustomTemplate, editor, file, ContainerUtil.newHashSet()).perform();
|
||||
}
|
||||
else if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
HintManager.getInstance().showErrorHint(editor, "Cannot invoke Surround with Emmet in the current context");
|
||||
|
||||
Reference in New Issue
Block a user