Search in sources :

Example 96 with AnAction

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

the class OpenAndroidSdkManagerHyperlink method execute.

@Override
protected void execute(@NotNull Project project) {
    ActionManager actionManager = ActionManager.getInstance();
    AnAction sdkManagerAction = actionManager.getAction("Android.RunAndroidSdkManager");
    sdkManagerAction.actionPerformed(null);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 97 with AnAction

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

the class AnalysisResultsManager method createActions.

@NotNull
@Override
protected AnAction[] createActions() {
    return new AnAction[] { new ToggleAction(AndroidBundle.message("android.captures.analysis.results.manager.run.name"), AndroidBundle.message("android.captures.analysis.results.manager.run.description"), AllIcons.Toolwindows.ToolWindowRun) {

        @Override
        public boolean isSelected(AnActionEvent e) {
            AnalysisResultsContent analysisResultsContent = getContentFromDesigner();
            return analysisResultsContent != null && !analysisResultsContent.canRunAnalysis();
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            if (state) {
                AnalysisResultsContent analysisResultsContent = getContentFromDesigner();
                if (analysisResultsContent != null && analysisResultsContent.canRunAnalysis()) {
                    analysisResultsContent.performAnalysis();
                }
            }
        }

        @Override
        public void update(@NotNull AnActionEvent e) {
            super.update(e);
            Presentation presentation = e.getPresentation();
            if (isSelected(e)) {
                presentation.setText(AndroidBundle.message("android.captures.analysis.results.manager.run.disabled.name"));
                presentation.setDescription(AndroidBundle.message("android.captures.analysis.results.manager.run.disabled.description"));
                presentation.setIcon(AllIcons.Process.DisabledRun);
            } else {
                presentation.setText(AndroidBundle.message("android.captures.analysis.results.manager.run.enabled.name"));
                presentation.setDescription(AndroidBundle.message("android.captures.analysis.results.manager.run.enabled.description"));
                presentation.setIcon(AllIcons.Toolwindows.ToolWindowRun);
            }
        }
    } };
}
Also used : ToggleAction(com.intellij.openapi.actionSystem.ToggleAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 98 with AnAction

use of com.intellij.openapi.actionSystem.AnAction 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 99 with AnAction

use of com.intellij.openapi.actionSystem.AnAction 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 100 with AnAction

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

the class OptionsButton method addResetPreferencesActionTo.

private void addResetPreferencesActionTo(DefaultActionGroup actionGroup) {
    myResetSettingsAction = new AnAction("Reset to default settings") {

        public void actionPerformed(AnActionEvent e) {
            try {
                Preferences preferences = Preferences.userRoot().node("jetbrains.communicator");
                preferences.removeNode();
                preferences.flush();
            } catch (BackingStoreException e1) {
                LOG.error(e1.getMessage(), e1);
            }
        }
    };
    actionGroup.add(myResetSettingsAction);
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Preferences(java.util.prefs.Preferences) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)184 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)62 NotNull (org.jetbrains.annotations.NotNull)31 Project (com.intellij.openapi.project.Project)24 Nullable (org.jetbrains.annotations.Nullable)22 ActionManager (com.intellij.openapi.actionSystem.ActionManager)21 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)21 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Presentation (com.intellij.openapi.actionSystem.Presentation)7 PsiFile (com.intellij.psi.PsiFile)7 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)6 Editor (com.intellij.openapi.editor.Editor)6 Keymap (com.intellij.openapi.keymap.Keymap)6 Ref (com.intellij.openapi.util.Ref)6 List (java.util.List)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5