Search in sources :

Example 11 with ActionGroup

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

the class GridCellImpl method createTabInfoFor.

private TabInfo createTabInfoFor(Content content) {
    final TabInfo tabInfo = updatePresentation(new TabInfo(new ProviderWrapper(content, myContext)), content).setObject(content).setPreferredFocusableComponent(content.getPreferredFocusableComponent()).setActionsContextComponent(content.getActionsContextComponent());
    myContents.remove(content);
    myContents.put(content, tabInfo);
    ActionGroup group = (ActionGroup) myContext.getActionManager().getAction(RunnerContentUi.VIEW_TOOLBAR);
    tabInfo.setTabLabelActions(group, ViewContext.CELL_TOOLBAR_PLACE);
    tabInfo.setDragOutDelegate(((RunnerContentUi) myContext).myDragOutDelegate);
    return tabInfo;
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) TabInfo(com.intellij.ui.tabs.TabInfo)

Example 12 with ActionGroup

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

the class RunLineMarkerTest method testTestClassWithMain.

public void testTestClassWithMain() throws Exception {
    myFixture.addClass("package junit.framework; public class TestCase {}");
    myFixture.configureByText("MainTest.java", "public class <caret>MainTest extends junit.framework.TestCase {\n" + "    public static void main(String[] args) {\n" + "    }\n" + "    public void testFoo() {\n" + "    }\n" + "}");
    List<GutterMark> marks = myFixture.findGuttersAtCaret();
    assertEquals(1, marks.size());
    GutterIconRenderer mark = (GutterIconRenderer) marks.get(0);
    ActionGroup group = mark.getPopupMenuActions();
    assertNotNull(group);
    TestActionEvent event = new TestActionEvent();
    List<AnAction> list = ContainerUtil.findAll(group.getChildren(event), action -> {
        TestActionEvent actionEvent = new TestActionEvent();
        action.update(actionEvent);
        String text = actionEvent.getPresentation().getText();
        return text != null && text.startsWith("Run ") && text.endsWith("'");
    });
    assertEquals(list.toString(), 2, list.size());
    list.get(0).update(event);
    assertEquals("Run 'MainTest.main()'", event.getPresentation().getText());
    list.get(1).update(event);
    assertEquals("Run 'MainTest'", event.getPresentation().getText());
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) GutterMark(com.intellij.codeInsight.daemon.GutterMark) GutterIconRenderer(com.intellij.openapi.editor.markup.GutterIconRenderer) AnAction(com.intellij.openapi.actionSystem.AnAction) TestActionEvent(com.intellij.testFramework.TestActionEvent)

Example 13 with ActionGroup

use of com.intellij.openapi.actionSystem.ActionGroup in project kotlin by JetBrains.

the class KotlinCallHierarchyBrowser method createTrees.

@Override
protected void createTrees(@NotNull Map<String, JTree> type2TreeMap) {
    ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction(IdeActions.GROUP_CALL_HIERARCHY_POPUP);
    JTree tree1 = createTree(false);
    PopupHandler.installPopupHandler(tree1, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance());
    BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction();
    baseOnThisMethodAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree1);
    type2TreeMap.put(CALLEE_TYPE, tree1);
    JTree tree2 = createTree(false);
    PopupHandler.installPopupHandler(tree2, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance());
    baseOnThisMethodAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree2);
    type2TreeMap.put(CALLER_TYPE, tree2);
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup)

Example 14 with ActionGroup

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

the class BaseEditorPopup method getChildren.

@NotNull
public AnAction[] getChildren(AnActionEvent e) {
    if (e == null)
        return EMPTY_ARRAY;
    final Editor editor = getEditor(e);
    final VirtualFile file = getFile(e);
    if (file == null || editor == null)
        return EMPTY_ARRAY;
    List<AnAction> result = new ArrayList<>();
    final UserModel userModel = getUserModel();
    String[] groups = userModel.getGroups();
    List<String> groupsWithUsers = new ArrayList<>();
    for (String group : groups) {
        if (userModel.getUsers(group).length > 0) {
            groupsWithUsers.add(group);
        }
    }
    if (groupsWithUsers.size() == 1) {
        User[] users = userModel.getUsers(groupsWithUsers.get(0));
        fillWithUserActions(users, result, file, editor);
    } else {
        for (String groupsWithUser : groupsWithUsers) {
            ActionGroup actionGroup = createGroupWithUsersActionGroup(groupsWithUser, userModel, file, editor);
            result.add(actionGroup);
        }
    }
    return result.toArray(new AnAction[result.size()]);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) UserModel(jetbrains.communicator.core.users.UserModel) User(jetbrains.communicator.core.users.User) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) ArrayList(java.util.ArrayList) Editor(com.intellij.openapi.editor.Editor) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with ActionGroup

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

the class IDEtalkToolWindow method createToolWindowComponent.

@Override
protected void createToolWindowComponent() {
    StartupManager.getInstance(myProject).registerPostStartupActivity(() -> initializeTransports(myProject.getName()));
    StatusToolbar statusToolbar = ((StatusToolbar) myContainer.getComponentInstanceOfType(StatusToolbar.class));
    DefaultActionGroup toolbarActions = new DefaultActionGroup();
    ActionGroup actions = (ActionGroup) myActionManager.getAction("IDEtalk");
    if (actions != null) {
        toolbarActions.addAll(actions);
    }
    toolbarActions.add(new ContextHelpAction("reference.toolWindows.idetalk"));
    ActionGroup treeActions = (ActionGroup) myActionManager.getAction("IDEtalk_Tree");
    JPanel toolbarPanel = new JPanel();
    toolbarPanel.setLayout(new BoxLayout(toolbarPanel, BoxLayout.X_AXIS));
    toolbarPanel.add(DropDownButton.wrap(new DropDownButton(new FindUsersAction(), IconUtil.getAddIcon())));
    toolbarPanel.add(createToolbar(toolbarActions).getComponent());
    toolbarPanel.add(Box.createHorizontalStrut(10));
    toolbarPanel.add(new SeparatorComponent(JBColor.LIGHT_GRAY, SeparatorOrientation.VERTICAL));
    toolbarPanel.add(Box.createHorizontalStrut(3));
    toolbarPanel.add(DropDownButton.wrap(new OptionsButton()));
    toolbarPanel.add(statusToolbar.createComponent());
    toolbarPanel.add(new JPanel() {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(Short.MAX_VALUE, 10);
        }
    });
    if (treeActions != null) {
        JComponent component = createToolbar(treeActions).getComponent();
        component.setMinimumSize(component.getPreferredSize());
        toolbarPanel.add(component);
    }
    toolbarPanel.setAlignmentX(0);
    myTopPanel.add(toolbarPanel);
    myPanel.add(myTopPanel, BorderLayout.NORTH);
    myPanel.add(ScrollPaneFactory.createScrollPane(myUserListComponent.getComponent()));
    ActionGroup group = (ActionGroup) myActionManager.getAction("IDEtalkPopup");
    if (group != null) {
        IDEAFacade.installPopupMenu(group, myUserListComponent.getTree(), myActionManager);
    }
}
Also used : DropDownButton(jetbrains.communicator.idea.actions.DropDownButton) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ContextHelpAction(com.intellij.ide.actions.ContextHelpAction) StatusToolbar(jetbrains.communicator.ide.StatusToolbar) SeparatorComponent(com.intellij.ui.SeparatorComponent) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) OptionsButton(jetbrains.communicator.idea.actions.OptionsButton) FindUsersAction(jetbrains.communicator.idea.actions.FindUsersAction)

Aggregations

ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)30 AnAction (com.intellij.openapi.actionSystem.AnAction)8 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)8 NotNull (org.jetbrains.annotations.NotNull)6 ActionManager (com.intellij.openapi.actionSystem.ActionManager)4 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)4 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)3 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 Pass (com.intellij.codeHighlighting.Pass)2 LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)2 BranchActionGroup (com.intellij.dvcs.ui.BranchActionGroup)2 BranchActionGroupPopup.wrapWithMoreActionIfNeeded (com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded)2 FAVORITE_BRANCH_COMPARATOR (com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR)2 BranchActionUtil.getNumOfTopShownBranches (com.intellij.dvcs.ui.BranchActionUtil.getNumOfTopShownBranches)2 AllIcons (com.intellij.icons.AllIcons)2 Group (com.intellij.openapi.keymap.impl.ui.Group)2 Project (com.intellij.openapi.project.Project)2 PsiElement (com.intellij.psi.PsiElement)2 ArrayList (java.util.ArrayList)2