Search in sources :

Example 36 with DefaultActionGroup

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

the class NlActionsToolbar method getRhsActions.

private static ActionGroup getRhsActions(DesignSurface surface) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new SetZoomAction(surface, ZoomType.OUT));
    group.add(new ZoomLabelAction(surface));
    group.add(new SetZoomAction(surface, ZoomType.IN));
    group.add(new SetZoomAction(surface, ZoomType.FIT));
    group.add(new TogglePanningDialogAction(surface));
    group.addSeparator();
    group.add(new LintNotificationAction(surface));
    return group;
}
Also used : SetZoomAction(com.android.tools.idea.uibuilder.actions.SetZoomAction) LintNotificationAction(com.android.tools.idea.uibuilder.actions.LintNotificationAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) TogglePanningDialogAction(com.android.tools.idea.uibuilder.actions.TogglePanningDialogAction) ZoomLabelAction(com.android.tools.idea.uibuilder.actions.ZoomLabelAction)

Example 37 with DefaultActionGroup

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

the class DefaultGradleConsoleView method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    //Create runner UI layout
    RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject);
    RunnerLayoutUi layoutUi = factory.create("", "", "session", myProject);
    JComponent layoutComponent = layoutUi.getComponent();
    // Adding actions
    DefaultActionGroup group = new DefaultActionGroup();
    layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);
    Content console = layoutUi.createContent(GradleConsoleToolWindowFactory.ID, myConsoleView.getComponent(), "", null, null);
    AnAction[] consoleActions = myConsoleView.createConsoleActions();
    for (AnAction action : consoleActions) {
        if (!shouldIgnoreAction(action)) {
            group.add(action);
        }
    }
    layoutUi.addContent(console, 0, PlaceInGrid.right, false);
    myConsolePanel.add(layoutComponent, BorderLayout.CENTER);
    //noinspection ConstantConditions
    Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
    toolWindow.getContentManager().addContent(content);
}
Also used : RunnerLayoutUi(com.intellij.execution.ui.RunnerLayoutUi) Content(com.intellij.ui.content.Content) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 38 with DefaultActionGroup

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

the class ConfigurationMenuAction method createPopupActionGroup.

@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup() {
    DefaultActionGroup group = new DefaultActionGroup("Configuration", true);
    Configuration configuration = mySurface.getConfiguration();
    if (configuration == null) {
        return group;
    }
    VirtualFile virtualFile = configuration.getFile();
    if (virtualFile != null) {
        Module module = configuration.getModule();
        if (module == null) {
            return group;
        }
        Project project = module.getProject();
        List<VirtualFile> variations = ResourceHelper.getResourceVariations(virtualFile, true);
        if (variations.size() > 1) {
            for (VirtualFile file : variations) {
                String title = String.format("Switch to %1$s", file.getParent().getName());
                group.add(new SwitchToVariationAction(title, project, file, virtualFile.equals(file)));
            }
            group.addSeparator();
        }
        ResourceFolderType folderType = ResourceHelper.getFolderType(configuration.getFile());
        if (folderType == ResourceFolderType.LAYOUT) {
            boolean haveLandscape = false;
            boolean haveLarge = false;
            for (VirtualFile file : variations) {
                String name = file.getParent().getName();
                if (name.startsWith(FD_RES_LAYOUT)) {
                    FolderConfiguration config = FolderConfiguration.getConfigForFolder(name);
                    if (config != null) {
                        ScreenOrientationQualifier orientation = config.getScreenOrientationQualifier();
                        if (orientation != null && orientation.getValue() == ScreenOrientation.LANDSCAPE) {
                            haveLandscape = true;
                            if (haveLarge) {
                                break;
                            }
                        }
                        ScreenSizeQualifier size = config.getScreenSizeQualifier();
                        if (size != null && size.getValue() == ScreenSize.XLARGE) {
                            haveLarge = true;
                            if (haveLandscape) {
                                break;
                            }
                        }
                    }
                }
            }
            // Do statistics on what is needed!
            if (!haveLandscape) {
                group.add(new CreateVariationAction(mySurface, "Create Landscape Variation", "layout-land"));
            }
            if (!haveLarge) {
                group.add(new CreateVariationAction(mySurface, "Create layout-xlarge Variation", "layout-xlarge"));
            //group.add(new CreateVariationAction(mySurface, "Create layout-sw600dp Variation...", "layout-sw600dp"));
            }
            group.add(new CreateVariationAction(mySurface, "Create Other...", null));
        } else {
            group.add(new CreateVariationAction(mySurface, "Create Alternative...", null));
        }
    /* TODO: Restore multi-configuration editing
      if (mySurface.supportsPreviews()) {
        addMultiConfigActions(group);
      }
      */
    }
    return group;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) ScreenSizeQualifier(com.android.ide.common.resources.configuration.ScreenSizeQualifier) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Project(com.intellij.openapi.project.Project) ScreenOrientationQualifier(com.android.ide.common.resources.configuration.ScreenOrientationQualifier) ResourceFolderType(com.android.resources.ResourceFolderType) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with DefaultActionGroup

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

the class TargetMenuAction method createPopupActionGroup.

@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup() {
    DefaultActionGroup group = new DefaultActionGroup(null, true);
    Configuration configuration = myRenderContext.getConfiguration();
    if (configuration == null) {
        return group;
    }
    group.add(new TogglePickBestAction(configuration.getConfigurationManager()));
    group.addSeparator();
    if (myUseCompatibilityTarget && configuration.getConfigurationManager().getHighestApiTarget() != null) {
        addCompatibilityTargets(group);
    } else {
        addRealTargets(group);
    }
    return group;
}
Also used : DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with DefaultActionGroup

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

the class ModulesComboBoxAction method createPopupActionGroup.

@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
    DefaultActionGroup group = new DefaultActionGroup();
    for (PsModule module : myExtraTopModules) {
        group.add(new ModuleAction(module));
    }
    myContext.getProject().forEachModule(module -> group.add(new ModuleAction(module)));
    return group;
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

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