Search in sources :

Example 51 with AnAction

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

the class CheckoutActionGroup method computeChildren.

@NotNull
@Override
protected AnAction[] computeChildren(@NotNull ActionManager manager) {
    CheckoutProvider[] providers = CheckoutProvider.EXTENSION_POINT_NAME.getExtensions();
    if (providers.length == 0) {
        return EMPTY_ARRAY;
    }
    Arrays.sort(providers, new CheckoutProvider.CheckoutProviderComparator());
    AnAction[] children = new AnAction[providers.length];
    for (int i = 0; i < providers.length; i++) {
        CheckoutProvider provider = providers[i];
        children[i] = createAction(provider);
    }
    return children;
}
Also used : CheckoutProvider(com.intellij.openapi.vcs.CheckoutProvider) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 52 with AnAction

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

the class XEvaluateInConsoleFromEditorActionHandler method getConsoleExecuteAction.

@Nullable
public static ConsoleExecuteAction getConsoleExecuteAction(@Nullable ConsoleView consoleView) {
    if (!(consoleView instanceof LanguageConsoleView)) {
        return null;
    }
    List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView) consoleView).getConsoleEditor().getComponent());
    ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
    return action == null || !action.isEnabled() ? null : action;
}
Also used : LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) AnAction(com.intellij.openapi.actionSystem.AnAction) ConsoleExecuteAction(com.intellij.execution.console.ConsoleExecuteAction) Nullable(org.jetbrains.annotations.Nullable)

Example 53 with AnAction

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

the class AbstractLanguageInjectionSupport method createDefaultAddAction.

public static AnAction createDefaultAddAction(final Project project, final Consumer<BaseInjection> consumer, final AbstractLanguageInjectionSupport support) {
    final String supportTitle = StringUtil.capitalize(support.getId());
    Icon icon = FileTypeManager.getInstance().getFileTypeByExtension(support.getId()).getIcon();
    return new AnAction("Generic " + supportTitle, null, icon) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            final BaseInjection injection = new BaseInjection(support.getId());
            injection.setDisplayName("New " + supportTitle + " Injection");
            final BaseInjection newInjection = showDefaultInjectionUI(project, injection);
            if (newInjection != null) {
                consumer.consume(injection);
            }
        }
    };
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection)

Example 54 with AnAction

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

the class AntConfigurationImpl method updateRegisteredActions.

private void updateRegisteredActions() {
    final Project project = getProject();
    if (project.isDisposed()) {
        return;
    }
    final List<Pair<String, AnAction>> actionList = new ArrayList<>();
    for (final AntBuildFile buildFile : myBuildFiles) {
        final AntBuildModelBase model = (AntBuildModelBase) buildFile.getModel();
        String defaultTargetActionId = model.getDefaultTargetActionId();
        if (defaultTargetActionId != null) {
            final TargetAction action = new TargetAction(buildFile, TargetAction.DEFAULT_TARGET_NAME, new String[] { TargetAction.DEFAULT_TARGET_NAME }, null);
            actionList.add(new Pair<>(defaultTargetActionId, action));
        }
        collectTargetActions(model.getFilteredTargets(), actionList, buildFile);
        collectTargetActions(getMetaTargets(buildFile), actionList, buildFile);
    }
    //noinspection SynchronizeOnThis
    synchronized (this) {
        // unregister Ant actions
        ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
        final String[] oldIds = actionManager.getActionIds(AntConfiguration.getActionIdPrefix(project));
        for (String oldId : oldIds) {
            actionManager.unregisterAction(oldId);
        }
        final Set<String> registeredIds = StringSetSpinAllocator.alloc();
        try {
            for (Pair<String, AnAction> pair : actionList) {
                if (!registeredIds.contains(pair.first)) {
                    registeredIds.add(pair.first);
                    actionManager.registerAction(pair.first, pair.second);
                }
            }
        } finally {
            StringSetSpinAllocator.dispose(registeredIds);
        }
    }
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TargetAction(com.intellij.lang.ant.config.actions.TargetAction) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx) Project(com.intellij.openapi.project.Project)

Example 55 with AnAction

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

the class ImportTree method createIncludeAction.

public AnAction createIncludeAction() {
    return new AnAction(CvsBundle.message("import.wizard.include.to.import.action.name"), null, IconUtil.getAddIcon()) {

        public void update(AnActionEvent e) {
            final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
            final Presentation presentation = e.getPresentation();
            presentation.setEnabled(isAtLeastOneFileExcluded(selectedFiles));
        }

        public void actionPerformed(AnActionEvent e) {
            final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
            for (VirtualFile selectedFile : selectedFiles) {
                include(selectedFile);
            }
            myWizard.updateStep();
            myFileSystemTree.getTree().repaint();
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)184 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)62 NotNull (org.jetbrains.annotations.NotNull)31 Project (com.intellij.openapi.project.Project)24 Nullable (org.jetbrains.annotations.Nullable)22 ActionManager (com.intellij.openapi.actionSystem.ActionManager)21 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)21 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Presentation (com.intellij.openapi.actionSystem.Presentation)7 PsiFile (com.intellij.psi.PsiFile)7 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)6 Editor (com.intellij.openapi.editor.Editor)6 Keymap (com.intellij.openapi.keymap.Keymap)6 Ref (com.intellij.openapi.util.Ref)6 List (java.util.List)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5