Search in sources :

Example 61 with DefaultActionGroup

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

the class OrientationMenuAction method createPopupActionGroup.

@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup() {
    DefaultActionGroup group = new DefaultActionGroup(null, true);
    Configuration configuration = myRenderContext.getConfiguration();
    if (configuration != null) {
        Device device = configuration.getDevice();
        if (device != null) {
            List<State> states = device.getAllStates();
            State current = configuration.getDeviceState();
            if (states.size() > 1 && current != null) {
                State flip = configuration.getNextDeviceState(current);
                State nextSate = flip == null ? current : flip;
                String title = getPresentationDescription(nextSate);
                group.add(new SetDeviceStateAction(myRenderContext, title, nextSate, false, true));
                group.addSeparator();
            }
            for (State config : states) {
                String stateName = config.getName();
                String title = stateName;
                VirtualFile better = ConfigurationMatcher.getBetterMatch(configuration, null, stateName, null, null);
                if (better != null) {
                    title = ConfigurationAction.getBetterMatchLabel(stateName, better, configuration.getFile());
                }
                group.add(new SetDeviceStateAction(myRenderContext, title, config, config == current, false));
            }
            group.addSeparator();
        }
        group.addSeparator();
        DefaultActionGroup uiModeGroup = new DefaultActionGroup("_UI Mode", true);
        UiMode currentUiMode = configuration.getUiMode();
        for (UiMode uiMode : UiMode.values()) {
            String title = uiMode.getShortDisplayValue();
            boolean checked = uiMode == currentUiMode;
            uiModeGroup.add(new SetUiModeAction(myRenderContext, title, uiMode, checked));
        }
        group.add(uiModeGroup);
        group.addSeparator();
        DefaultActionGroup nightModeGroup = new DefaultActionGroup("_Night Mode", true);
        NightMode currentNightMode = configuration.getNightMode();
        for (NightMode nightMode : NightMode.values()) {
            String title = nightMode.getShortDisplayValue();
            boolean checked = nightMode == currentNightMode;
            nightModeGroup.add(new SetNightModeAction(myRenderContext, title, nightMode, checked));
        }
        group.add(nightModeGroup);
    }
    return group;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Device(com.android.sdklib.devices.Device) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NightMode(com.android.resources.NightMode) UiMode(com.android.resources.UiMode) State(com.android.sdklib.devices.State) NotNull(org.jetbrains.annotations.NotNull)

Example 62 with DefaultActionGroup

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

the class LocaleMenuAction method createPopupActionGroup.

@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup() {
    DefaultActionGroup group = new DefaultActionGroup(null, true);
    // TODO: Offer submenus, lazily populated, which offer languages either by code or by name.
    // However, this doesn't currently work for the JBPopup dialog we're using as part
    // of the combo action (and using the JBPopup dialog rather than a Swing menu has some
    // other advantages: fitting in with the overall IDE look and feel (e.g. dark colors),
    // allowing typing to filter, etc.
    List<Locale> locales = getRelevantLocales();
    Configuration configuration = myRenderContext.getConfiguration();
    if (configuration != null && locales.size() > 0) {
        group.add(new SetLocaleAction(myRenderContext, getLocaleLabel(Locale.ANY, false, myClassicStyle), Locale.ANY));
        group.addSeparator();
        Collections.sort(locales, Locale.LANGUAGE_CODE_COMPARATOR);
        for (Locale locale : locales) {
            String title = getLocaleLabel(locale, false, myClassicStyle);
            VirtualFile better = ConfigurationMatcher.getBetterMatch(configuration, null, null, locale, null);
            if (better != null) {
                title = ConfigurationAction.getBetterMatchLabel(getLocaleLabel(locale, true, myClassicStyle), better, configuration.getFile());
            }
            group.add(new SetLocaleAction(myRenderContext, title, locale));
        }
        group.addSeparator();
    }
    group.add(new EditTranslationAction());
    return group;
}
Also used : Locale(com.android.tools.idea.rendering.Locale) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 63 with DefaultActionGroup

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

the class ProjectProfileSelectionDialog method createTreePanel.

@NotNull
static JPanel createTreePanel(@NotNull CheckboxTreeView tree) {
    JPanel treePanel = new JPanel(new BorderLayout());
    DefaultActionGroup group = new DefaultActionGroup();
    CommonActionsManager actions = CommonActionsManager.getInstance();
    group.addAll(actions.createExpandAllAction(tree, treePanel), actions.createCollapseAllAction(tree, treePanel));
    ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar("AndroidProjectProfileSelection", group, true);
    JPanel buttonsPanel = new JPanel(new BorderLayout());
    buttonsPanel.add(actionToolBar.getComponent(), BorderLayout.CENTER);
    buttonsPanel.setBorder(new SideBorder(JBColor.border(), SideBorder.TOP | SideBorder.LEFT | SideBorder.RIGHT, 1));
    treePanel.add(buttonsPanel, BorderLayout.NORTH);
    treePanel.add(ScrollPaneFactory.createScrollPane(tree), BorderLayout.CENTER);
    return treePanel;
}
Also used : CommonActionsManager(com.intellij.ide.CommonActionsManager) ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 64 with DefaultActionGroup

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

the class DumpSysActions method create.

public static DefaultActionGroup create(@NotNull Project p, @NotNull final DeviceContext context) {
    DefaultActionGroup group = new DefaultActionGroup("System Information", true) {

        @Override
        public void update(AnActionEvent e) {
            e.getPresentation().setText("System Information");
            e.getPresentation().setIcon(AndroidIcons.Ddms.SysInfo);
            e.getPresentation().setEnabled(context.getSelectedDevice() != null);
        }

        @Override
        public boolean isDumbAware() {
            return true;
        }
    };
    group.add(new MyDumpSysAction(p, context, "activity", "Activity Manager State"));
    group.add(new MyDumpSysAction(p, context, "package", "Package Information"));
    group.add(new MyDumpSysAction(p, context, "meminfo", "Memory Usage"));
    group.add(new MyDumpProcStatsAction(p, context, "procstats", "Memory use over time"));
    group.add(new MyDumpSysAction(p, context, "gfxinfo", "Graphics State"));
    return group;
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 65 with DefaultActionGroup

use of com.intellij.openapi.actionSystem.DefaultActionGroup 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

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