Search in sources :

Example 46 with AnActionEvent

use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.

the class QuickChangeCodeStyleSchemeAction method fillActions.

@Override
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
    final CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance(project);
    if (manager.PER_PROJECT_SETTINGS != null) {
        //noinspection HardCodedStringLiteral
        group.add(new AnAction("<project>", "", manager.USE_PER_PROJECT_SETTINGS ? ourCurrentAction : ourNotCurrentAction) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                manager.USE_PER_PROJECT_SETTINGS = true;
            }
        });
    }
    CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme();
    for (CodeStyleScheme scheme : CodeStyleSchemesImpl.getSchemeManager().getAllSchemes()) {
        addScheme(group, manager, currentScheme, scheme, false);
    }
}
Also used : CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager) CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 47 with AnActionEvent

use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.

the class ScopesChooser method fillActionGroup.

private void fillActionGroup(final DefaultActionGroup group, final List<NamedScope> scopes, final List<Descriptor> defaultDescriptors, final InspectionProfileImpl inspectionProfile, final Set<String> excludedScopeNames) {
    for (final NamedScope scope : scopes) {
        final String scopeName = scope.getName();
        if (excludedScopeNames.contains(scopeName)) {
            continue;
        }
        group.add(new DumbAwareAction(scopeName) {

            @Override
            public void actionPerformed(final AnActionEvent e) {
                for (final Descriptor defaultDescriptor : defaultDescriptors) {
                    inspectionProfile.addScope(defaultDescriptor.getToolWrapper().createCopy(), scope, defaultDescriptor.getLevel(), true, getEventProject(e));
                }
                onScopeAdded();
            }
        });
    }
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) Descriptor(com.intellij.codeInspection.ex.Descriptor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

Example 48 with AnActionEvent

use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.

the class AutoPopupController method setupListeners.

private void setupListeners() {
    ActionManagerEx.getInstanceEx().addAnActionListener(new AnActionListener() {

        @Override
        public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
            cancelAllRequest();
        }

        @Override
        public void beforeEditorTyping(char c, DataContext dataContext) {
            cancelAllRequest();
        }

        @Override
        public void afterActionPerformed(final AnAction action, final DataContext dataContext, AnActionEvent event) {
        }
    }, this);
    IdeEventQueue.getInstance().addActivityListener(() -> cancelAllRequest(), this);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) AnActionListener(com.intellij.openapi.actionSystem.ex.AnActionListener) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 49 with AnActionEvent

use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.

the class FindUIHelper method registerAction.

private void registerAction(String actionName, boolean replace, FindDialog findDialog) {
    AnAction action = ActionManager.getInstance().getAction(actionName);
    JRootPane findDialogRootComponent = ((JDialog) (findDialog.getWindow())).getRootPane();
    new AnAction() {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            myModel.setReplaceState(replace);
            findDialog.updateReplaceVisibility();
        }
    }.registerCustomShortcutSet(action.getShortcutSet(), findDialogRootComponent);
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 50 with AnActionEvent

use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.

the class ProjectSdksModel method createAddActions.

public void createAddActions(@NotNull DefaultActionGroup group, @NotNull final JComponent parent, @Nullable final Sdk selectedSdk, @NotNull final Consumer<Sdk> updateTree, @Nullable Condition<SdkTypeId> filter) {
    final SdkType[] types = SdkType.getAllTypes();
    for (final SdkType type : types) {
        if (filter != null && !filter.value(type))
            continue;
        final AnAction addAction = new DumbAwareAction(type.getPresentableName(), null, type.getIconForAddAction()) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                doAdd(parent, selectedSdk, type, updateTree);
            }
        };
        group.add(addAction);
    }
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)130 AnAction (com.intellij.openapi.actionSystem.AnAction)67 Project (com.intellij.openapi.project.Project)27 NotNull (org.jetbrains.annotations.NotNull)25 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 Nullable (org.jetbrains.annotations.Nullable)20 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)15 List (java.util.List)14 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)11 Presentation (com.intellij.openapi.actionSystem.Presentation)10 StringUtil (com.intellij.openapi.util.text.StringUtil)9 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)8 JBTable (com.intellij.ui.table.JBTable)8 DataContext (com.intellij.openapi.actionSystem.DataContext)7 Pair (com.intellij.openapi.util.Pair)7 Logger (com.intellij.openapi.diagnostic.Logger)6 Ref (com.intellij.openapi.util.Ref)6 AnActionButton (com.intellij.ui.AnActionButton)6