Search in sources :

Example 26 with DefaultActionGroup

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

the class SmartPopupActionGroup method getChildrenCountRecursive.

private static int getChildrenCountRecursive(ActionGroup group) {
    AnAction[] children;
    if (group instanceof DefaultActionGroup) {
        children = ((DefaultActionGroup) group).getChildActionsOrStubs();
    } else {
        children = group.getChildren(null);
    }
    int count = 0;
    for (AnAction child : children) {
        if (child instanceof ActionGroup) {
            count += getChildrenCountRecursive((ActionGroup) child);
        } else {
            count++;
        }
    }
    return count;
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 27 with DefaultActionGroup

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

the class ShowQuickActionPopupAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    QuickActionProvider provider = e.getRequiredData(QuickActionProvider.KEY);
    List<AnAction> actions = provider.getActions(true);
    DefaultActionGroup group = new DefaultActionGroup(actions);
    group.addSeparator();
    JComponent component = provider.getComponent();
    if (component != null && !provider.isCycleRoot()) {
        Component eachParent = component.getParent();
        while (eachParent != null) {
            QuickActionProvider parentProvider = ObjectUtils.tryCast(eachParent, QuickActionProvider.class);
            if (parentProvider != null) {
                List<AnAction> parentActions = parentProvider.getActions(false);
                if (!parentActions.isEmpty()) {
                    String name = StringUtil.notNullize(parentProvider.getName(), "");
                    DefaultActionGroup parentGroup = new DefaultActionGroup(name, parentActions);
                    if (!StringUtil.isEmpty(name)) {
                        parentGroup.setPopup(true);
                    } else {
                        group.add(Separator.getInstance());
                    }
                    group.add(parentGroup);
                }
                if (parentProvider.isCycleRoot())
                    break;
            }
            eachParent = eachParent.getParent();
        }
    }
    JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), ALPHA_NUMBERING, true).showInBestPositionFor(e.getDataContext());
}
Also used : AnAction(com.intellij.openapi.actionSystem.AnAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 28 with DefaultActionGroup

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

the class XFramesView method createToolbar.

private ActionToolbarImpl createToolbar() {
    final DefaultActionGroup framesGroup = new DefaultActionGroup();
    CommonActionsManager actionsManager = CommonActionsManager.getInstance();
    framesGroup.add(actionsManager.createPrevOccurenceAction(myFramesList));
    framesGroup.add(actionsManager.createNextOccurenceAction(myFramesList));
    framesGroup.addAll(ActionManager.getInstance().getAction(XDebuggerActions.FRAMES_TOP_TOOLBAR_GROUP));
    final ActionToolbarImpl toolbar = (ActionToolbarImpl) ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true);
    toolbar.setReservePlaceAutoPopupIcon(false);
    toolbar.setAddSeparatorFirst(true);
    toolbar.getComponent().setBorder(new EmptyBorder(1, 0, 0, 0));
    return toolbar;
}
Also used : ActionToolbarImpl(com.intellij.openapi.actionSystem.impl.ActionToolbarImpl) CommonActionsManager(com.intellij.ide.CommonActionsManager) EmptyBorder(javax.swing.border.EmptyBorder) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 29 with DefaultActionGroup

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

the class AbstractVcsHelperImpl method openCommittedChangesTab.

public void openCommittedChangesTab(final CommittedChangesProvider provider, final RepositoryLocation location, final ChangeBrowserSettings settings, final int maxCount, String title) {
    DefaultActionGroup extraActions = new DefaultActionGroup();
    CommittedChangesPanel panel = new CommittedChangesPanel(myProject, provider, settings, location, extraActions);
    panel.setMaxCount(maxCount);
    panel.refreshChanges(false);
    final ContentFactory factory = ContentFactory.SERVICE.getInstance();
    if (title == null && location != null) {
        title = VcsBundle.message("browse.changes.content.title", location.toPresentableString());
    }
    final Content content = factory.createContent(panel, title, false);
    final ChangesViewContentI contentManager = ChangesViewContentManager.getInstance(myProject);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
    extraActions.add(new CloseTabToolbarAction() {

        public void actionPerformed(final AnActionEvent e) {
            contentManager.removeContent(content);
        }
    });
    ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
    if (!window.isVisible()) {
        window.activate(null);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) CloseTabToolbarAction(com.intellij.ide.actions.CloseTabToolbarAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ContentFactory(com.intellij.ui.content.ContentFactory)

Example 30 with DefaultActionGroup

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

the class DateFilterPopupComponent method createActionGroup.

@Override
protected ActionGroup createActionGroup() {
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DAY_OF_YEAR, -1);
    Date oneDayBefore = cal.getTime();
    cal.add(Calendar.DAY_OF_YEAR, -6);
    Date oneWeekBefore = cal.getTime();
    return new DefaultActionGroup(createAllAction(), new SelectAction(), new DateAction(oneDayBefore, "Last 24 hours"), new DateAction(oneWeekBefore, "Last 7 days"));
}
Also used : Calendar(java.util.Calendar) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Date(java.util.Date)

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