com.intellij.openapi.actionSystem.ex.CustomComponentAction Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.ex.CustomComponentAction.
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: ActionButton.java From consulo with Apache License 2.0 | 6 votes |
private void actionPerformed(final AnActionEvent event) { if (myAction instanceof ActionGroup && !(myAction instanceof CustomComponentAction) && ((ActionGroup)myAction).isPopup() && !((ActionGroup)myAction).canBePerformed(event.getDataContext())) { final ActionManagerImpl am = (ActionManagerImpl)ActionManager.getInstance(); ActionPopupMenuImpl popupMenu = (ActionPopupMenuImpl)am.createActionPopupMenu(event.getPlace(), (ActionGroup)myAction, new MenuItemPresentationFactory() { @Override protected void processPresentation(Presentation presentation) { if (myNoIconsInPopup) { presentation.setIcon(null); presentation.setHoveredIcon(null); } } }); popupMenu.setDataContextProvider(this::getDataContext); if (event.isFromActionToolbar()) { popupMenu.getComponent().show(this, 0, getHeight()); } else { popupMenu.getComponent().show(this, getWidth(), 0); } } else { ActionUtil.performActionDumbAware(myAction, event); } }
Example #2
Source File: ActionToolbarImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private JComponent getCustomComponent(@Nonnull AnAction action) { Presentation presentation = myPresentationFactory.getPresentation(action); JComponent customComponent = presentation.getClientProperty(CustomComponentAction.COMPONENT_KEY); if (customComponent == null) { customComponent = ((CustomComponentAction)action).createCustomComponent(presentation, myPlace); presentation.putClientProperty(CustomComponentAction.COMPONENT_KEY, customComponent); UIUtil.putClientProperty(customComponent, CustomComponentAction.ACTION_KEY, action); } tweakActionComponentUI(customComponent); //AbstractButton clickable = UIUtil.findComponentOfType(customComponent, AbstractButton.class); //if (clickable != null) { // class ToolbarClicksCollectorListener extends MouseAdapter { // @Override // public void mouseClicked(MouseEvent e) { // ToolbarClicksCollector.record(action, myPlace, e, getDataContext()); // } // } // if (Arrays.stream(clickable.getMouseListeners()).noneMatch(ml -> ml instanceof ToolbarClicksCollectorListener)) { // clickable.addMouseListener(new ToolbarClicksCollectorListener()); // } //} return customComponent; }
Example #3
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 #4
Source File: AbstractGotoSEContributor.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(@Nonnull AnActionEvent e) { ScopeDescriptor selection = getSelectedScope(); String name = StringUtil.trimMiddle(selection.getDisplayName(), 30); String text = StringUtil.escapeMnemonics(name).replaceFirst("(?i)([" + TOGGLE + CHOOSE + "])", "_$1"); e.getPresentation().setText(text); e.getPresentation().setIcon(OffsetIcon.getOriginalIcon(selection.getIcon())); String shortcutText = KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(CHOOSE, MnemonicHelper.getFocusAcceleratorKeyMask(), true)); String shortcutText2 = KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(TOGGLE, MnemonicHelper.getFocusAcceleratorKeyMask(), true)); e.getPresentation().setDescription("Choose scope (" + shortcutText + ")\n" + "Toggle scope (" + shortcutText2 + ")"); JComponent button = e.getPresentation().getClientProperty(CustomComponentAction.COMPONENT_KEY); if (button != null) { button.setBackground(selection.getColor()); } }