use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class XsltConfigImpl method initComponent.
@Override
@SuppressWarnings({ "StringEquality" })
public void initComponent() {
final Language xmlLang = StdFileTypes.XML.getLanguage();
// intentionManager.addAction(new DeleteUnusedParameterFix());
// intentionManager.addAction(new DeleteUnusedVariableFix());
final XsltFormattingModelBuilder builder = new XsltFormattingModelBuilder(LanguageFormatting.INSTANCE.forLanguage(xmlLang));
LanguageFormatting.INSTANCE.addExplicitExtension(xmlLang, builder);
try {
// TODO: put this into com.intellij.refactoring.actions.IntroduceParameterAction, just like IntroduceVariableAction
final AnAction introduceParameter = ActionManager.getInstance().getAction("IntroduceParameter");
if (introduceParameter != null) {
introduceParameter.setInjectedContext(true);
}
} catch (Exception e) {
Logger.getInstance(XsltConfigImpl.class.getName()).error(e);
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class AssignShortcutAction method getGoalActionId.
@Nullable
private static String getGoalActionId(DataContext context) {
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.size() != 1) {
return null;
}
MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null)
return null;
String goal = goals.get(0);
final MavenShortcutsManager shortcutsManager = getShortcutsManager(context);
String actionId = shortcutsManager != null ? shortcutsManager.getActionId(project.getPath(), goal) : null;
if (actionId != null) {
AnAction action = ActionManager.getInstance().getAction(actionId);
if (action == null) {
MavenKeymapExtension.getOrRegisterAction(project, actionId, goal);
}
}
return actionId;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class BoundIconRenderer method getClickAction.
@Override
@Nullable
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
List<PsiFile> formFiles = getBoundFormFiles();
if (formFiles.size() > 0) {
final VirtualFile virtualFile = formFiles.get(0).getVirtualFile();
if (virtualFile == null) {
return;
}
Project project = myElement.getProject();
FileEditor[] editors = FileEditorManager.getInstance(project).openFile(virtualFile, true);
if (myElement instanceof PsiField) {
for (FileEditor editor : editors) {
if (editor instanceof UIFormEditor) {
((UIFormEditor) editor).selectComponent(((PsiField) myElement).getName());
}
}
}
}
}
};
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class PyCharmEduInitialConfigurator method unregisterAction.
private static void unregisterAction(String actionId, String groupId) {
ActionManager actionManager = ActionManager.getInstance();
AnAction action = actionManager.getAction(actionId);
if (action != null) {
AnAction actionGroup = actionManager.getAction(groupId);
if (actionGroup != null && actionGroup instanceof DefaultActionGroup) {
((DefaultActionGroup) actionGroup).remove(action);
actionManager.unregisterAction(actionId);
}
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class PyExecuteFileLineMarkerProvider method collectSlowLineMarkers.
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
if (elements.isEmpty()) {
return;
}
Optional<PsiElement> psiElement = elements.stream().filter((element) -> element instanceof PsiFile).findFirst();
if (!psiElement.isPresent())
return;
final PsiElement file = psiElement.get();
final RunContextAction runAction = new PyStudyRunContextAction(DefaultRunExecutor.getRunExecutorInstance());
final PyExecuteFileExtensionPoint[] extensions = ApplicationManager.getApplication().getExtensions(PyExecuteFileExtensionPoint.EP_NAME);
final List<AnAction> actions = new ArrayList<>();
final DefaultActionGroup group = new DefaultActionGroup();
if (PlatformUtils.isPyCharmEducational()) {
group.add(runAction);
}
for (PyExecuteFileExtensionPoint extension : extensions) {
AnAction action = extension.getRunAction();
if (action != null && extension.accept(file.getProject())) {
actions.add(action);
group.add(action);
}
}
if (actions.isEmpty() && !PlatformUtils.isPyCharmEducational()) {
return;
}
Icon icon = PlatformUtils.isPyCharmEducational() ? AllIcons.Actions.Execute : actions.get(0).getTemplatePresentation().getIcon();
final LineMarkerInfo<PsiElement> markerInfo = new LineMarkerInfo<PsiElement>(file, file.getTextRange(), icon, Pass.LINE_MARKERS, e -> {
String text = "Execute '" + e.getContainingFile().getName() + "'";
return PlatformUtils.isPyCharmEducational() ? text : actions.get(0).getTemplatePresentation().getText();
}, null, GutterIconRenderer.Alignment.RIGHT) {
@Nullable
@Override
public GutterIconRenderer createGutterRenderer() {
return new LineMarkerGutterIconRenderer<PsiElement>(this) {
@Override
public AnAction getClickAction() {
return PlatformUtils.isPyCharmEducational() ? runAction : actions.get(0);
}
@Nullable
@Override
public ActionGroup getPopupMenuActions() {
if (!PlatformUtils.isPyCharmEducational() && actions.isEmpty()) {
return null;
}
if (actions.size() == 1) {
return null;
}
return group;
}
};
}
};
result.add(markerInfo);
}
Aggregations