use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class RunLineMarkerProvider method getLineMarkerInfo.
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
List<RunLineMarkerContributor> contributors = RunLineMarkerContributor.EXTENSION.allForLanguage(element.getLanguage());
Icon icon = null;
List<Info> infos = null;
for (RunLineMarkerContributor contributor : contributors) {
Info info = contributor.getInfo(element);
if (info == null) {
continue;
}
if (icon == null) {
icon = info.icon;
}
if (infos == null) {
infos = new SmartList<>();
}
infos.add(info);
}
if (icon == null)
return null;
if (infos.size() > 1) {
Collections.sort(infos, COMPARATOR);
final Info first = infos.get(0);
for (Iterator<Info> it = infos.iterator(); it.hasNext(); ) {
Info info = it.next();
if (info != first && first.shouldReplace(info)) {
it.remove();
}
}
}
final DefaultActionGroup actionGroup = new DefaultActionGroup();
for (Info info : infos) {
for (AnAction action : info.actions) {
actionGroup.add(new LineMarkerActionWrapper(element, action));
}
if (info != infos.get(infos.size() - 1)) {
actionGroup.add(new Separator());
}
}
List<Info> finalInfos = infos;
Function<PsiElement, String> tooltipProvider = element1 -> {
final StringBuilder tooltip = new StringBuilder();
for (Info info : finalInfos) {
if (info.tooltipProvider != null) {
String string = info.tooltipProvider.apply(element1);
if (string == null)
continue;
if (tooltip.length() != 0) {
tooltip.append("\n");
}
tooltip.append(string);
}
}
return tooltip.length() == 0 ? null : tooltip.toString();
};
return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), icon, Pass.LINE_MARKERS, tooltipProvider, null, GutterIconRenderer.Alignment.CENTER) {
@Nullable
@Override
public GutterIconRenderer createGutterRenderer() {
return new LineMarkerGutterIconRenderer<PsiElement>(this) {
@Override
public AnAction getClickAction() {
return null;
}
@Override
public boolean isNavigateAction() {
return true;
}
@Nullable
@Override
public ActionGroup getPopupMenuActions() {
return actionGroup;
}
};
}
};
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class ShowAddPackagingElementPopupAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DefaultActionGroup group = new DefaultActionGroup();
for (PackagingElementType type : PackagingElementFactory.getInstance().getAllElementTypes()) {
group.add(new AddNewPackagingElementAction((PackagingElementType<?>) type, myArtifactEditor));
}
final DataContext dataContext = e.getDataContext();
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Add", group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
popup.showInBestPositionFor(dataContext);
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class JdkListConfigurable method createAddAction.
@Override
public AbstractAddGroup createAddAction() {
return new AbstractAddGroup(ProjectBundle.message("add.new.jdk.text")) {
@NotNull
@Override
public AnAction[] getChildren(@Nullable final AnActionEvent e) {
DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.new.jdk.text"), true);
myJdksTreeModel.createAddActions(group, myTree, projectJdk -> addJdkNode(projectJdk, true));
return group.getChildren(null);
}
};
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-plugins by JetBrains.
the class AngularUiRouterInitializer method runActivity.
@Override
public void runActivity(@NotNull Project project) {
if (myInitialized)
return;
final ActionManager actionManager = ActionManager.getInstance();
final AnAction action = actionManager.getAction("UML.EditorGroup");
final AnAction showUiRouter = actionManager.getAction("AngularJS.Show.Ui.Router.States.Diagram.Action");
if (action instanceof DefaultActionGroup) {
((DefaultActionGroup) action).add(showUiRouter);
}
myInitialized = true;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project android by JetBrains.
the class FloatingToolWindow method setAdditionalGearPopupActions.
private void setAdditionalGearPopupActions(@NotNull ToolWindowEx toolWindow) {
DefaultActionGroup attachedSide = new DefaultActionGroup("Attached Side", true);
attachedSide.add(new AttachToSideAction(Side.LEFT));
attachedSide.add(new AttachToSideAction(Side.RIGHT));
toolWindow.setAdditionalGearActions(new DefaultActionGroup(attachedSide));
}
Aggregations