Search in sources :

Example 46 with DefaultActionGroup

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

the class RunLineMarkerProvider method getLineMarkerInfo.

@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
    List<RunLineMarkerContributor> contributors = RunLineMarkerContributor.EXTENSION.allForLanguage(element.getLanguage());
    Icon icon = null;
    List<Info> infos = null;
    for (RunLineMarkerContributor contributor : contributors) {
        Info info = contributor.getInfo(element);
        if (info == null) {
            continue;
        }
        if (icon == null) {
            icon = info.icon;
        }
        if (infos == null) {
            infos = new SmartList<>();
        }
        infos.add(info);
    }
    if (icon == null)
        return null;
    if (infos.size() > 1) {
        Collections.sort(infos, COMPARATOR);
        final Info first = infos.get(0);
        for (Iterator<Info> it = infos.iterator(); it.hasNext(); ) {
            Info info = it.next();
            if (info != first && first.shouldReplace(info)) {
                it.remove();
            }
        }
    }
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    for (Info info : infos) {
        for (AnAction action : info.actions) {
            actionGroup.add(new LineMarkerActionWrapper(element, action));
        }
        if (info != infos.get(infos.size() - 1)) {
            actionGroup.add(new Separator());
        }
    }
    List<Info> finalInfos = infos;
    Function<PsiElement, String> tooltipProvider = element1 -> {
        final StringBuilder tooltip = new StringBuilder();
        for (Info info : finalInfos) {
            if (info.tooltipProvider != null) {
                String string = info.tooltipProvider.apply(element1);
                if (string == null)
                    continue;
                if (tooltip.length() != 0) {
                    tooltip.append("\n");
                }
                tooltip.append(string);
            }
        }
        return tooltip.length() == 0 ? null : tooltip.toString();
    };
    return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), icon, Pass.LINE_MARKERS, tooltipProvider, null, GutterIconRenderer.Alignment.CENTER) {

        @Nullable
        @Override
        public GutterIconRenderer createGutterRenderer() {
            return new LineMarkerGutterIconRenderer<PsiElement>(this) {

                @Override
                public AnAction getClickAction() {
                    return null;
                }

                @Override
                public boolean isNavigateAction() {
                    return true;
                }

                @Nullable
                @Override
                public ActionGroup getPopupMenuActions() {
                    return actionGroup;
                }
            };
        }
    };
}
Also used : java.util(java.util) AllIcons(com.intellij.icons.AllIcons) GutterIconRenderer(com.intellij.openapi.editor.markup.GutterIconRenderer) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Pass(com.intellij.codeHighlighting.Pass) LineMarkerProviderDescriptor(com.intellij.codeInsight.daemon.LineMarkerProviderDescriptor) Nullable(org.jetbrains.annotations.Nullable) SmartList(com.intellij.util.SmartList) Function(com.intellij.util.Function) PsiElement(com.intellij.psi.PsiElement) Info(com.intellij.execution.lineMarker.RunLineMarkerContributor.Info) NotNull(org.jetbrains.annotations.NotNull) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) Separator(com.intellij.openapi.actionSystem.Separator) javax.swing(javax.swing) Info(com.intellij.execution.lineMarker.RunLineMarkerContributor.Info) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) Separator(com.intellij.openapi.actionSystem.Separator) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 47 with DefaultActionGroup

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

the class ShowAddPackagingElementPopupAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DefaultActionGroup group = new DefaultActionGroup();
    for (PackagingElementType type : PackagingElementFactory.getInstance().getAllElementTypes()) {
        group.add(new AddNewPackagingElementAction((PackagingElementType<?>) type, myArtifactEditor));
    }
    final DataContext dataContext = e.getDataContext();
    final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Add", group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
    popup.showInBestPositionFor(dataContext);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) ListPopup(com.intellij.openapi.ui.popup.ListPopup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) PackagingElementType(com.intellij.packaging.elements.PackagingElementType)

Example 48 with DefaultActionGroup

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

the class JdkListConfigurable method createAddAction.

@Override
public AbstractAddGroup createAddAction() {
    return new AbstractAddGroup(ProjectBundle.message("add.new.jdk.text")) {

        @NotNull
        @Override
        public AnAction[] getChildren(@Nullable final AnActionEvent e) {
            DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.new.jdk.text"), true);
            myJdksTreeModel.createAddActions(group, myTree, projectJdk -> addJdkNode(projectJdk, true));
            return group.getChildren(null);
        }
    };
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Nullable(org.jetbrains.annotations.Nullable)

Example 49 with DefaultActionGroup

use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-plugins by JetBrains.

the class AngularUiRouterInitializer method runActivity.

@Override
public void runActivity(@NotNull Project project) {
    if (myInitialized)
        return;
    final ActionManager actionManager = ActionManager.getInstance();
    final AnAction action = actionManager.getAction("UML.EditorGroup");
    final AnAction showUiRouter = actionManager.getAction("AngularJS.Show.Ui.Router.States.Diagram.Action");
    if (action instanceof DefaultActionGroup) {
        ((DefaultActionGroup) action).add(showUiRouter);
    }
    myInitialized = true;
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnAction(com.intellij.openapi.actionSystem.AnAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 50 with DefaultActionGroup

use of com.intellij.openapi.actionSystem.DefaultActionGroup in project android by JetBrains.

the class FloatingToolWindow method setAdditionalGearPopupActions.

private void setAdditionalGearPopupActions(@NotNull ToolWindowEx toolWindow) {
    DefaultActionGroup attachedSide = new DefaultActionGroup("Attached Side", true);
    attachedSide.add(new AttachToSideAction(Side.LEFT));
    attachedSide.add(new AttachToSideAction(Side.RIGHT));
    toolWindow.setAdditionalGearActions(new DefaultActionGroup(attachedSide));
}
Also used : DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Aggregations

DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)109 NotNull (org.jetbrains.annotations.NotNull)38 AnAction (com.intellij.openapi.actionSystem.AnAction)22 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)16 Nullable (org.jetbrains.annotations.Nullable)11 ActionManager (com.intellij.openapi.actionSystem.ActionManager)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Separator (com.intellij.openapi.actionSystem.Separator)7 ListPopup (com.intellij.openapi.ui.popup.ListPopup)7 Content (com.intellij.ui.content.Content)6 BrowserHelpAction (com.android.tools.idea.actions.BrowserHelpAction)5 Project (com.intellij.openapi.project.Project)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 List (java.util.List)5 RecordingAction (com.android.tools.idea.monitor.actions.RecordingAction)4 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)4 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4 javax.swing (javax.swing)4 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)3 CommonActionsManager (com.intellij.ide.CommonActionsManager)3