Search in sources :

Example 51 with DefaultActionGroup

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

the class DeviceMenuActionTest method prettyPrintActions.

private static void prettyPrintActions(AnAction action, StringBuilder sb, int depth) {
    String text;
    if (action instanceof Separator) {
        text = "------------------------------------------------------";
    } else {
        text = action.getTemplatePresentation().getText();
        if (text != null && text.startsWith("AVD:")) {
            // build environment
            return;
        }
    }
    if (text != null) {
        for (int i = 0; i < depth; i++) {
            sb.append("    ");
        }
        sb.append(text).append("\n");
    }
    DefaultActionGroup group = action instanceof DefaultActionGroup ? (DefaultActionGroup) action : null;
    if (group != null) {
        for (AnAction child : group.getChildActionsOrStubs()) {
            prettyPrintActions(child, sb, depth + 1);
        }
    }
}
Also used : DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) Separator(com.intellij.openapi.actionSystem.Separator)

Example 52 with DefaultActionGroup

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

the class DeviceMenuActionTest method Actions.

// https://code.google.com/p/android/issues/detail?id=227931
public void Actions() {
    ConfigurationHolder holder = mock(ConfigurationHolder.class);
    Configuration configuration = mock(Configuration.class);
    when(holder.getConfiguration()).thenReturn(configuration);
    when(configuration.getConfigurationManager()).thenReturn(myFacet.getConfigurationManager());
    DefaultActionGroup actions = new DeviceMenuAction(holder).createPopupActionGroup();
    StringBuilder sb = new StringBuilder();
    prettyPrintActions(actions, sb, 0);
    String actual = sb.toString();
    String expected = "    3.7, 480 × 800, hdpi (Nexus One)\n" + "    4.0, 480 × 800, hdpi (Nexus S)\n" + "    4.7, 720 × 1280, xhdpi (Galaxy Nexus)\n" + "    4.7, 768 × 1280, xhdpi (Nexus 4)\n" + "    5.0, 1080 × 1920, xxhdpi (Nexus 5)\n" + "    ------------------------------------------------------\n" + "    5.0, 1080 × 1920, xxhdpi (Pixel)\n" + "    5.2, 1080 × 1920, 420dpi (Nexus 5X)\n" + "    5.5, 1440 × 2560, 560dpi (Pixel XL)\n" + "    5.7, 1440 × 2560, 560dpi (Nexus 6P)\n" + "    6.0, 1440 × 2560, 560dpi (Nexus 6)\n" + "    ------------------------------------------------------\n" + "    7.0, 800 × 1280, tvdpi (Nexus 7 2012)\n" + "    7.0, 1200 × 1920, xhdpi (Nexus 7)\n" + "    8.9, 2048 × 1536, xhdpi (Nexus 9)\n" + "    9.9, 2560 × 1800, xhdpi (Pixel C)\n" + "    10.1, 2560 × 1600, xhdpi (Nexus 10)\n" + "    ------------------------------------------------------\n" + "    320 × 290, tvdpi (Round Chin)\n" + "    280 × 280, hdpi (Square)\n" + "    320 × 320, hdpi (Round)\n" + "    ------------------------------------------------------\n" + "    1080p, 1920 × 1080, xhdpi (TV)\n" + "    720p, 1280 × 720, tvdpi (TV)\n" + "    ------------------------------------------------------\n" + "    Generic Phones and Tablets\n" + "        10.1\" WXGA (Tablet) (1280 × 800, mdpi)\n" + "         7.0\" WSVGA (Tablet) (1024 × 600, mdpi)\n" + "         5.4\" FWVGA (480 × 854, mdpi)\n" + "         5.1\" WVGA (480 × 800, mdpi)\n" + "         4.7\" WXGA (1280 × 720, xhdpi)\n" + "         4.65\" 720p (720 × 1280, xhdpi)\n" + "         4.0\" WVGA (480 × 800, hdpi)\n" + "         3.7\" FWVGA slider (480 × 854, hdpi)\n" + "         3.4\" WQVGA (240 × 432, ldpi)\n" + "         3.7\" WVGA (480 × 800, hdpi)\n" + "         3.3\" WQVGA (240 × 400, ldpi)\n" + "         3.2\" HVGA slider (ADP1) (320 × 480, mdpi)\n" + "         3.2\" QVGA (ADP2) (320 × 480, mdpi)\n" + "         2.7\" QVGA slider (240 × 320, ldpi)\n" + "         2.7\" QVGA (240 × 320, ldpi)\n" + "    Add Device Definition...\n";
    Truth.assertThat(actual).isEqualTo(expected);
}
Also used : DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 53 with DefaultActionGroup

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

the class KarmaServerLogComponent method getToolbarActions.

@Nullable
@Override
public ActionGroup getToolbarActions() {
    if (myActionGroup != null) {
        return myActionGroup;
    }
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new StopProcessAction("Stop Karma Server", null, myServer.getProcessHandler()));
    final AnAction[] actions = myConsole.createConsoleActions();
    for (AnAction action : actions) {
        group.add(action);
    }
    group.addSeparator();
    myActionGroup = group;
    return myActionGroup;
}
Also used : DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) StopProcessAction(com.intellij.execution.actions.StopProcessAction) Nullable(org.jetbrains.annotations.Nullable)

Example 54 with DefaultActionGroup

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

the class FilterByThemeComboBoxAction method createPopupActionGroup.

@NotNull
@Override
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new FilterByThemeAction(new ThemeFilter() {

        @Override
        public String getDisplayName() {
            return "All";
        }

        @Override
        public boolean accepts(VirtualFile file) {
            return true;
        }

        @Override
        public boolean isApplicableToProject(Project project) {
            return true;
        }
    }));
    for (ThemeFilter filter : ThemeFilter.EP_NAME.getExtensions()) {
        group.add(new FilterByThemeAction(filter));
    }
    return group;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 55 with DefaultActionGroup

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

the class GradleBuildTreeViewPanel method fillRightToolbarGroup.

@Override
protected void fillRightToolbarGroup(DefaultActionGroup group) {
    super.fillRightToolbarGroup(group);
    group.add(new DumbAwareAction("Show Console Output", null, AndroidIcons.GradleConsole) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(GradleConsoleToolWindowFactory.ID);
            if (window != null) {
                window.activate(null, false);
            }
        }

        @Override
        public void update(AnActionEvent e) {
            e.getPresentation().setEnabledAndVisible(true);
        }
    });
    DefaultActionGroup filterGroup = new DefaultActionGroup("GradleBuildMessagesFilter", true) {

        @Override
        public void update(AnActionEvent e) {
            Presentation presentation = e.getPresentation();
            presentation.setDescription("Filter messages to display");
            presentation.setIcon(AllIcons.General.Filter);
        }

        @Override
        public boolean isDumbAware() {
            return true;
        }
    };
    // We could have iterated through ErrorTreeElementKind.values() and have less code, but we want to keep this order:
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.ERROR));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.WARNING));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.INFO));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.NOTE));
    filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.GENERIC));
    group.add(filterGroup);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) 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