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);
}
}
} };
}
Aggregations