use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class AbstractGithubTagDownloadedProjectGenerator method createGitHubLink.
public ActionLink createGitHubLink() {
final ActionLink link = new ActionLink(getName() + " on GitHub", new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
BrowserUtil.open("https://github.com/" + getGithubUserName() + "/" + getGithubRepositoryName());
}
});
link.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
return link;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class BaseGenerateTestSupportMethodAction method createEditTemplateAction.
@Nullable
@Override
public AnAction createEditTemplateAction(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
final PsiClass targetClass = editor == null || file == null ? null : getTargetClass(editor, file);
if (targetClass != null) {
final List<TestFramework> frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass);
final TestIntegrationUtils.MethodKind methodKind = ((MyHandler) getHandler()).myMethodKind;
if (!frameworks.isEmpty()) {
return new AnAction("Edit Template") {
@Override
public void actionPerformed(AnActionEvent e) {
chooseAndPerform(editor, frameworks, framework -> {
final FileTemplateDescriptor descriptor = methodKind.getFileTemplateDescriptor(framework);
if (descriptor != null) {
final String fileName = descriptor.getFileName();
AllFileTemplatesConfigurable.editCodeTemplate(FileUtil.getNameWithoutExtension(fileName), project);
} else {
HintManager.getInstance().showErrorHint(editor, "No template found for " + framework.getName() + ":" + BaseGenerateTestSupportMethodAction.this.getTemplatePresentation().getText());
}
});
}
};
}
}
return null;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class RunLineMarkerTest method testTestClassWithMain.
public void testTestClassWithMain() throws Exception {
myFixture.addClass("package junit.framework; public class TestCase {}");
myFixture.configureByText("MainTest.java", "public class <caret>MainTest extends junit.framework.TestCase {\n" + " public static void main(String[] args) {\n" + " }\n" + " public void testFoo() {\n" + " }\n" + "}");
List<GutterMark> marks = myFixture.findGuttersAtCaret();
assertEquals(1, marks.size());
GutterIconRenderer mark = (GutterIconRenderer) marks.get(0);
ActionGroup group = mark.getPopupMenuActions();
assertNotNull(group);
TestActionEvent event = new TestActionEvent();
List<AnAction> list = ContainerUtil.findAll(group.getChildren(event), action -> {
TestActionEvent actionEvent = new TestActionEvent();
action.update(actionEvent);
String text = actionEvent.getPresentation().getText();
return text != null && text.startsWith("Run ") && text.endsWith("'");
});
assertEquals(list.toString(), 2, list.size());
list.get(0).update(event);
assertEquals("Run 'MainTest.main()'", event.getPresentation().getText());
list.get(1).update(event);
assertEquals("Run 'MainTest'", event.getPresentation().getText());
}
use of com.intellij.openapi.actionSystem.AnAction 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;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-plugins by JetBrains.
the class ShowGeneratedManifestTest method testMenuGroup.
@Test
public void testMenuGroup() {
ViewGeneratedManifestGroup group = (ViewGeneratedManifestGroup) ActionManager.getInstance().getAction("osmorc.viewGeneratedManifests");
assertNotNull(group);
@SuppressWarnings("deprecation") DataContext context = DataManager.getInstance().getDataContext();
AnActionEvent event = AnActionEvent.createFromAnAction(group, null, "", context);
AnAction[] actions = group.getChildren(event);
assertEquals(3, actions.length);
Arrays.sort(actions, (o1, o2) -> Comparing.compare(o1.getTemplatePresentation().getText(), o2.getTemplatePresentation().getText()));
assertEquals("[t0] t0.jar", actions[0].getTemplatePresentation().getText());
}
Aggregations