Search in sources :

Example 11 with ActionManager

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

the class KeymapGenerator method main.

@Override
public void main(String[] args) {
    ActionManager actionManager = ActionManager.getInstance();
    StringBuilder xml = new StringBuilder();
    xml.append("<Keymaps>\n");
    for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
        xml.append("  <Keymap name=\"").append(keymap.getPresentableName()).append("\">\n");
        for (String id : keymap.getActionIdList()) {
            String shortcuts = KeymapUtil.getShortcutsText(keymap.getShortcuts(id));
            if (!StringUtil.isEmpty(shortcuts)) {
                AnAction action = actionManager.getAction(id);
                xml.append("    <Action id=\"").append(id).append("\">\n");
                Set<String> addedShortcuts = new THashSet<>();
                for (Shortcut shortcut : keymap.getShortcuts(id)) {
                    // Different shortcuts may have equal display strings (e.g. shift+minus and shift+subtract)
                    // We don't want them do be duplicated for users
                    String shortcutText = KeymapUtil.getShortcutText(shortcut);
                    if (addedShortcuts.add(shortcutText)) {
                        xml.append("      <Shortcut>").append(shortcutText).append("</Shortcut>\n");
                    }
                }
                if (action != null) {
                    String text = action.getTemplatePresentation().getText();
                    if (text != null) {
                        xml.append("      <Text>").append(StringUtil.escapeXml(text)).append("</Text>\n");
                    }
                }
                xml.append("    </Action>\n");
            }
        }
        xml.append("  </Keymap>\n");
    }
    xml.append("</Keymaps>");
    final String path = args.length == 2 ? args[1] : PathManager.getHomePath() + File.separator + "AllKeymaps.xml";
    File out = new File(path);
    try {
        FileUtil.writeToFile(out, xml.toString());
        System.out.println("Saved to: " + out.getAbsolutePath());
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }
    System.exit(0);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) Shortcut(com.intellij.openapi.actionSystem.Shortcut) IOException(java.io.IOException) AnAction(com.intellij.openapi.actionSystem.AnAction) File(java.io.File) Keymap(com.intellij.openapi.keymap.Keymap) THashSet(gnu.trove.THashSet)

Example 12 with ActionManager

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

the class GradleDslMethodNotFoundErrorHandler method getApplyGradlePluginHyperlink.

@NotNull
private static NotificationHyperlink getApplyGradlePluginHyperlink(@NotNull final VirtualFile virtualFile, @NotNull final NotificationData notification) {
    return new NotificationHyperlink("apply.gradle.plugin", "Apply Gradle plugin") {

        @Override
        protected void execute(@NotNull Project project) {
            openFile(virtualFile, notification, project);
            ActionManager actionManager = ActionManager.getInstance();
            String actionId = AddGradleDslPluginAction.ID;
            AnAction action = actionManager.getAction(actionId);
            assert action instanceof AddGradleDslPluginAction;
            AddGradleDslPluginAction addPluginAction = (AddGradleDslPluginAction) action;
            actionManager.tryToExecute(addPluginAction, ActionCommand.getInputEvent(actionId), null, ActionPlaces.UNKNOWN, true);
        }
    };
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) Project(com.intellij.openapi.project.Project) AddGradleDslPluginAction(org.jetbrains.plugins.gradle.codeInsight.actions.AddGradleDslPluginAction) NotNull(org.jetbrains.annotations.NotNull) AnAction(com.intellij.openapi.actionSystem.AnAction) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ActionManager

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

the class GradleToolWindowPanel method initContent.

public void initContent() {
    final ActionManager actionManager = ActionManager.getInstance();
    final ActionGroup actionGroup = (ActionGroup) actionManager.getAction(TOOL_WINDOW_TOOLBAR_ID);
    ActionToolbar actionToolbar = actionManager.createActionToolbar(myPlace, actionGroup, true);
    JPanel toolbarControl = new JPanel(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.weightx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.WEST;
    toolbarControl.add(actionToolbar.getComponent(), constraints);
    for (JComponent component : getToolbarControls()) {
        component.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
        toolbarControl.add(component, constraints);
    }
    setToolbar(toolbarControl);
    final JComponent payloadControl = buildContent();
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(payloadControl);
    JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
    myContent.add(scrollPane, CONTENT_CARD_NAME);
    RichTextControlBuilder builder = new RichTextControlBuilder();
    builder.setBackgroundColor(payloadControl.getBackground());
    builder.setForegroundColor(UIUtil.getInactiveTextColor());
    builder.setFont(payloadControl.getFont());
    builder.setText(GradleBundle.message("gradle.toolwindow.text.no.linked.project"));
    final JComponent noLinkedProjectControl = builder.build();
    myContent.add(noLinkedProjectControl, NON_LINKED_CARD_NAME);
    update();
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) RichTextControlBuilder(org.jetbrains.plugins.gradle.ui.RichTextControlBuilder) ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar)

Example 14 with ActionManager

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

the class DvcsQuickListContentProvider method getVcsActions.

@Nullable
public List<AnAction> getVcsActions(@Nullable Project project, @Nullable AbstractVcs activeVcs, @Nullable DataContext dataContext) {
    if (activeVcs == null || !getVcsName().equals(activeVcs.getName())) {
        return null;
    }
    final ActionManager manager = ActionManager.getInstance();
    final List<AnAction> actions = new ArrayList<>();
    actions.add(new Separator(activeVcs.getDisplayName()));
    add("CheckinProject", manager, actions);
    add("CheckinFiles", manager, actions);
    add("ChangesView.Revert", manager, actions);
    addSeparator(actions);
    add("Vcs.ShowTabbedFileHistory", manager, actions);
    add("Annotate", manager, actions);
    add("Compare.SameVersion", manager, actions);
    addSeparator(actions);
    addVcsSpecificActions(manager, actions);
    return actions;
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ArrayList(java.util.ArrayList) AnAction(com.intellij.openapi.actionSystem.AnAction) Separator(com.intellij.openapi.actionSystem.Separator) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with ActionManager

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

the class AngularUiRouterInitializer method runActivity.

@Override
public void runActivity(@NotNull Project project) {
    if (myInitialized)
        return;
    final ActionManager actionManager = ActionManager.getInstance();
    final AnAction action = actionManager.getAction("UML.EditorGroup");
    final AnAction showUiRouter = actionManager.getAction("AngularJS.Show.Ui.Router.States.Diagram.Action");
    if (action instanceof DefaultActionGroup) {
        ((DefaultActionGroup) action).add(showUiRouter);
    }
    myInitialized = true;
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnAction(com.intellij.openapi.actionSystem.AnAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Aggregations

ActionManager (com.intellij.openapi.actionSystem.ActionManager)43 AnAction (com.intellij.openapi.actionSystem.AnAction)27 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)15 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)4 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)4 MouseEvent (java.awt.event.MouseEvent)4 Keymap (com.intellij.openapi.keymap.Keymap)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ActionPopupMenu (com.intellij.openapi.actionSystem.ActionPopupMenu)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 ActionManagerImpl (com.intellij.openapi.actionSystem.impl.ActionManagerImpl)2 Application (com.intellij.openapi.application.Application)2 ToolWindow (com.intellij.openapi.wm.ToolWindow)2 IntellijAzureActionManager (com.microsoft.azure.toolkit.intellij.common.action.IntellijAzureActionManager)2 File (java.io.File)2 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)1 CloudDebugHelpAction (com.google.cloud.tools.intellij.debugger.actions.CloudDebugHelpAction)1 DataManager (com.intellij.ide.DataManager)1