use of com.intellij.openapi.actionSystem.AnAction in project buck by facebook.
the class BuckBuildManager method showNoTargetMessage.
/**
* Print "no selected target" error message to console window.
* Also provide a hyperlink which can directly jump to "Choose Target" GUI window.
*/
public void showNoTargetMessage(Project project) {
BuckModule buckModule = project.getComponent(BuckModule.class);
buckModule.getBuckEventsConsumer().consumeConsoleEvent("Please choose a build target!");
BuckToolWindowFactory.outputConsoleMessage(project, "Please ", ConsoleViewContentType.ERROR_OUTPUT);
BuckToolWindowFactory.outputConsoleHyperlink(project, "choose a build target!\n", new HyperlinkInfo() {
@Override
public void navigate(Project project) {
JComponent frame = WindowManager.getInstance().getIdeFrame(project).getComponent();
AnAction action = ActionManager.getInstance().getAction("buck.ChooseTarget");
action.actionPerformed(new AnActionEvent(null, DataManager.getInstance().getDataContext(frame), ActionPlaces.UNKNOWN, action.getTemplatePresentation(), ActionManager.getInstance(), 0));
}
});
}
use of com.intellij.openapi.actionSystem.AnAction in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoGenerateTestMethodActionGroup method getChildren.
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
if (e == null) {
return AnAction.EMPTY_ARRAY;
}
Project project = e.getProject();
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (project == null || editor == null)
return AnAction.EMPTY_ARRAY;
PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
ArrayList<AnAction> children = ContainerUtil.newArrayList();
for (GoTestFramework framework : GoTestFramework.all()) {
if (framework.isAvailableOnFile(file)) {
children.addAll(framework.getGenerateMethodActions());
}
}
return !children.isEmpty() ? children.toArray(new AnAction[children.size()]) : AnAction.EMPTY_ARRAY;
}
use of com.intellij.openapi.actionSystem.AnAction in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoSurrounderTestBase method doTest.
protected void doTest(@NotNull String codeBefore, @NotNull String expectedCodeAfter, @NotNull String surrounderDescription, boolean apply) {
PsiFile file = myFixture.configureByText("a.go", normalizeCode(codeBefore));
List<AnAction> applicable = SurroundWithHandler.buildSurroundActions(myFixture.getProject(), myFixture.getEditor(), file, null);
if (applicable == null) {
assertFalse(apply);
return;
}
String suffix = ". " + surrounderDescription;
for (AnAction action : applicable) {
String actionPresentation = action.getTemplatePresentation().getText();
if (actionPresentation != null && StringUtil.endsWith(actionPresentation, suffix)) {
assertTrue(apply);
myFixture.testAction(action);
return;
}
}
if (apply) {
myFixture.checkResult(normalizeCode(expectedCodeAfter), true);
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-plugins by StepicOrg.
the class StudyProjectComponent method registerShortcuts.
private void registerShortcuts() {
StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
if (window != null) {
List<AnAction> actionsOnToolbar = window.getActions(true);
if (actionsOnToolbar != null) {
actionsOnToolbar.stream().filter(action -> action instanceof StudyActionWithShortcut).map(action -> (StudyActionWithShortcut) action).forEach(action -> {
String id = action.getActionId();
String[] shortcuts = action.getShortcuts();
if (shortcuts != null) {
addShortcut(id, shortcuts);
}
});
} else {
logger.warn("Actions on toolbar are nulls");
}
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class MavenRunConfigurationMenu method update.
@Override
public void update(AnActionEvent e) {
for (AnAction action : getChildActionsOrStubs()) {
if (action instanceof ExecuteMavenRunConfigurationAction) {
remove(action);
}
}
final Project project = e.getProject();
final RunnerAndConfigurationSettings settings = MavenDataKeys.RUN_CONFIGURATION.getData(e.getDataContext());
if (settings == null || project == null)
return;
Executor[] executors = ExecutorRegistry.getInstance().getRegisteredExecutors();
for (int i = executors.length; --i >= 0; ) {
final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executors[i].getId(), settings.getConfiguration());
AnAction action = new ExecuteMavenRunConfigurationAction(executors[i], runner != null, project, settings);
addAction(action, Constraints.FIRST);
}
super.update(e);
}
Aggregations