use of com.intellij.openapi.actionSystem.ActionGroup 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);
}
use of com.intellij.openapi.actionSystem.ActionGroup in project intellij-community by JetBrains.
the class SmartPopupActionGroup method getChildrenCountRecursive.
private static int getChildrenCountRecursive(ActionGroup group) {
AnAction[] children;
if (group instanceof DefaultActionGroup) {
children = ((DefaultActionGroup) group).getChildActionsOrStubs();
} else {
children = group.getChildren(null);
}
int count = 0;
for (AnAction child : children) {
if (child instanceof ActionGroup) {
count += getChildrenCountRecursive((ActionGroup) child);
} else {
count++;
}
}
return count;
}
use of com.intellij.openapi.actionSystem.ActionGroup in project intellij-community by JetBrains.
the class TabInfo method setActions.
public TabInfo setActions(ActionGroup group, String place) {
ActionGroup old = myGroup;
myGroup = group;
myPlace = place;
myChangeSupport.firePropertyChange(ACTION_GROUP, old, myGroup);
return this;
}
use of com.intellij.openapi.actionSystem.ActionGroup in project intellij-community by JetBrains.
the class MaintenanceAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("MaintenanceGroup");
JBPopupFactory.getInstance().createActionGroupPopup("Maintenance", group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, true).showInFocusCenter();
}
use of com.intellij.openapi.actionSystem.ActionGroup in project intellij-community by JetBrains.
the class CustomActionsSchema method isCorrectActionGroup.
public boolean isCorrectActionGroup(ActionGroup group, String defaultGroupName) {
if (myActions.isEmpty()) {
return false;
}
final String text = group.getTemplatePresentation().getText();
if (!StringUtil.isEmpty(text)) {
for (ActionUrl url : myActions) {
if (url.getGroupPath().contains(text) || url.getGroupPath().contains(defaultGroupName)) {
return true;
}
if (url.getComponent() instanceof Group) {
final Group urlGroup = (Group) url.getComponent();
String id = urlGroup.getName() != null ? urlGroup.getName() : urlGroup.getId();
if (id == null || id.equals(text) || id.equals(defaultGroupName)) {
return true;
}
}
}
return false;
}
return true;
}
Aggregations