use of com.intellij.openapi.actionSystem.DefaultActionGroup 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.DefaultActionGroup in project intellij-community by JetBrains.
the class PyStudyPluginConfigurator method getActionGroup.
@NotNull
@Override
public DefaultActionGroup getActionGroup(Project project) {
final DefaultActionGroup baseGroup = super.getActionGroup(project);
final DefaultActionGroup group = new DefaultActionGroup();
group.add(new PyStudyCheckAction());
group.addAll(baseGroup);
return group;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class CreateListenerAction method prepareActionGroup.
private DefaultActionGroup prepareActionGroup(final List<RadComponent> selection) {
final DefaultActionGroup actionGroup = new DefaultActionGroup();
final EventSetDescriptor[] eventSetDescriptors;
try {
BeanInfo beanInfo = Introspector.getBeanInfo(selection.get(0).getComponentClass());
eventSetDescriptors = beanInfo.getEventSetDescriptors();
} catch (IntrospectionException e) {
LOG.error(e);
return null;
}
EventSetDescriptor[] sortedDescriptors = new EventSetDescriptor[eventSetDescriptors.length];
System.arraycopy(eventSetDescriptors, 0, sortedDescriptors, 0, eventSetDescriptors.length);
Arrays.sort(sortedDescriptors, (o1, o2) -> o1.getListenerType().getName().compareTo(o2.getListenerType().getName()));
for (EventSetDescriptor descriptor : sortedDescriptors) {
actionGroup.add(new MyCreateListenerAction(selection, descriptor));
}
return actionGroup;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class CreateListenerAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
final DefaultActionGroup actionGroup = prepareActionGroup(selection);
final JComponent selectedComponent = selection.get(0).getDelegee();
final DataContext context = DataManager.getInstance().getDataContext(selectedComponent);
final JBPopupFactory factory = JBPopupFactory.getInstance();
final ListPopup popup = factory.createActionGroupPopup(UIDesignerBundle.message("create.listener.title"), actionGroup, context, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
FormEditingUtil.showPopupUnderComponent(popup, selection.get(0));
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class CCCreateAnswerPlaceholderPanel method createHintToolbarComponent.
private JComponent createHintToolbarComponent() {
final DefaultActionGroup addRemoveGroup = new DefaultActionGroup();
addRemoveGroup.addAll(new AddHint(), new RemoveHint(), new ShowNext(), new ShowPrevious());
return ActionManager.getInstance().createActionToolbar("Hint", addRemoveGroup, false).getComponent();
}
Aggregations