Search in sources :

Example 1 with ToggleAction

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

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ToggleAction (com.intellij.openapi.actionSystem.ToggleAction)1 NotNull (org.jetbrains.annotations.NotNull)1