Java Code Examples for com.intellij.ui.popup.PopupFactoryImpl#ActionItem
The following examples show how to use
com.intellij.ui.popup.PopupFactoryImpl#ActionItem .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RunAnythingChooseContextAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { Project project = e.getProject(); if (project == null) { return; } JComponent component = e.getPresentation().getClientProperty(CustomComponentAction.COMPONENT_KEY); if (component == null) { return; } Runnable updateToolbar = () -> { ActionToolbar toolbar = UIUtil.uiParents(component, true).filter(ActionToolbar.class).first(); toolbar.updateActionsImmediately(); }; DataContext dataContext = e.getDataContext(); List<PopupFactoryImpl.ActionItem> actionItems = ActionPopupStep.createActionItems(new DefaultActionGroup(createItems()), dataContext, false, false, true, true, ActionPlaces.POPUP, null); ChooseContextPopup popup = new ChooseContextPopup(new ChooseContextPopupStep(actionItems, dataContext, updateToolbar), dataContext); popup.setSize(new Dimension(300, 300)); popup.setRequestFocus(false); popup.showUnderneathOf(component); }
Example 2
Source File: FlatSpeedSearchPopup.java From consulo with Apache License 2.0 | 5 votes |
protected static <T> T getSpecificAction(Object value, @Nonnull Class<T> clazz) { if (value instanceof PopupFactoryImpl.ActionItem) { AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction(); if (clazz.isInstance(action)) { return clazz.cast(action); } else if (action instanceof EmptyAction.MyDelegatingActionGroup) { ActionGroup group = ((EmptyAction.MyDelegatingActionGroup)action).getDelegate(); return clazz.isInstance(group) ? clazz.cast(group) : null; } } return null; }
Example 3
Source File: RunAnythingChooseContextAction.java From consulo with Apache License 2.0 | 5 votes |
@Override protected ListCellRenderer getListElementRenderer() { return new PopupListElementRenderer<PopupFactoryImpl.ActionItem>(this) { private JLabel myInfoLabel; @Override protected JComponent createItemComponent() { myTextLabel = new ErrorLabel(); myInfoLabel = new JLabel(); myTextLabel.setBorder(JBUI.Borders.empty(10)); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.add(myTextLabel, BorderLayout.WEST); textPanel.add(myInfoLabel, BorderLayout.CENTER); return layoutComponent(textPanel); } @Override protected void customizeComponent(JList<? extends PopupFactoryImpl.ActionItem> list, PopupFactoryImpl.ActionItem actionItem, boolean isSelected) { AnActionEvent event = ActionUtil.createEmptyEvent(); ActionUtil.performDumbAwareUpdate(true, actionItem.getAction(), event, false); String description = event.getPresentation().getDescription(); if (description != null) { myInfoLabel.setText(description); } myTextLabel.setText(event.getPresentation().getText()); myInfoLabel.setForeground(isSelected ? UIUtil.getListSelectionForeground(true) : UIUtil.getInactiveTextColor()); } }; }
Example 4
Source File: RunAnythingChooseContextAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public ListSeparator getSeparatorAbove(PopupFactoryImpl.ActionItem value) { AnAction action = value.getAction(); if (action instanceof BrowseDirectoryItem) { return new ListSeparator(IdeBundle.message("run.anything.context.separator.directories")); } else if (action instanceof ModuleItem && action == ContainerUtil.filter(myActions, it -> it.getAction() instanceof ModuleItem).get(0).getAction()) { return new ListSeparator(IdeBundle.message("run.anything.context.separator.modules")); } return super.getSeparatorAbove(value); }
Example 5
Source File: FlatSpeedSearchPopup.java From consulo with Apache License 2.0 | 4 votes |
@Override public final boolean shouldBeShowing(Object value) { if (!super.shouldBeShowing(value)) return false; if (!(value instanceof PopupFactoryImpl.ActionItem)) return true; return shouldBeShowing(((PopupFactoryImpl.ActionItem)value).getAction()); }
Example 6
Source File: RunAnythingChooseContextAction.java From consulo with Apache License 2.0 | 4 votes |
public ChooseContextPopupStep(List<PopupFactoryImpl.ActionItem> actions, DataContext dataContext, Runnable updateToolbar) { super(actions, IdeBundle.message("run.anything.context.title.working.directory"), () -> dataContext, null, true, Conditions.alwaysFalse(), false, true, null); myActions = actions; myUpdateToolbar = updateToolbar; }