@Override public void handleEvent(Event evt) { ActionEvent event = new ActionEvent(presentation, actionManager); action.actionPerformed(event); } },
/** * Returns promise returned by PromisableAction or already resolved promise for * non-PromisableAction. */ private Promise<Void> promiseAction(final Action action, final ActionEvent event) { if (action instanceof PromisableAction) { return ((PromisableAction) action).promise(event); } else { action.actionPerformed(event); return Promises.resolve(null); } }
/** Mouse Click handler. */ @Override public void onClick(ClickEvent event) { if (!enabled) { return; } // todo handle popup group ActionEvent e = new ActionEvent(presentation, actionManager); if (action instanceof ActionGroup && !(action instanceof CustomComponentAction) && ((ActionGroup) action).isPopup()) { } else { action.actionPerformed(e); } }
@Override public void onMenuItemSelected(MenuItem menuItem) { final Object data = menuItem.getData(); if (data instanceof Tab) { final WidgetToShow widget = tabs2Widgets.get(data); if (widget != null) { activateWidget(widget); delegate.onWidgetFocused(widget.getWidget()); } } else if (data instanceof BaseAction) { ((Action) data).actionPerformed(null); } }
/** Handle Mouse Click */ private void onRowClicked(Element tr) { if (isRowDisabled(tr) || tr == subPopupAnchor) { return; } int itemIndex = Integer.parseInt(tr.getAttribute("item-index")); Action menuItem = list.get(itemIndex); if (menuItem instanceof ActionGroup && (!((ActionGroup) menuItem).canBePerformed() && Utils.hasVisibleChildren( (ActionGroup) menuItem, presentationFactory, actionManager))) { openSubPopup(tr); } else { if (actionSelectedHandler != null) { actionSelectedHandler.onActionSelected(menuItem); } ActionEvent e = new ActionEvent(presentationFactory.getPresentation(menuItem), actionManager); menuItem.actionPerformed(e); } }
@Override public void performAction(String actionId, Map<String, String> parameters) { final Action action; if (actionId != null && (action = getAction(actionId)) != null) { final Presentation presentation = presentationFactory.getPresentation(action); final ActionEvent actionEvent = new ActionEvent(presentation, this, parameters); action.update(actionEvent); if (presentation.isEnabled() && presentation.isVisible()) { action.actionPerformed(actionEvent); } } }
@Override public void onItemClicked(@NotNull EditorPaneMenuItem<Action> item) { editorPaneMenu.hide(); final Action action = item.getData(); final Presentation presentation = presentationFactory.getPresentation(action); presentation.putClientProperty(CURRENT_PANE_PROP, EditorPartStackPresenter.this); final PartPresenter activePart = getActivePart(); final TabItem tab = getTabByPart(activePart); if (tab != null) { final VirtualFile virtualFile = ((EditorTab) tab).getFile(); // pass into action file property and editor tab presentation.putClientProperty(CURRENT_TAB_PROP, tab); presentation.putClientProperty(CURRENT_FILE_PROP, virtualFile); } action.actionPerformed(new ActionEvent(presentation, actionManager, null)); }
@Override public void onActionSelected(Action action) { ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager); action.update(e); if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) { view.hide(); action.actionPerformed(e); } }
/** * Finds and runs an action cancelling original key event * * @param actionIds list containing action ids * @param keyEvent original key event */ private void runActions(List<String> actionIds, Event keyEvent) { for (String actionId : actionIds) { Action action = actionManager.getAction(actionId); if (action == null) { continue; } ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager); action.update(e); if (e.getPresentation().isEnabled()) { /** Stop handling the key event */ keyEvent.preventDefault(); keyEvent.stopPropagation(); /** Perform the action */ action.actionPerformed(e); } } }
private void handleKey(NativeEvent event) { SignalEvent signalEvent = SignalEventUtils.create((Event) event, false); CharCodeWithModifiers keyBinding = keyBindingAgent.getKeyBinding(JavaExtension.JAVA_CLASS_STRUCTURE); if (signalEvent == null || keyBinding == null) { return; } int digest = CharCodeWithModifiers.computeKeyDigest(signalEvent); if (digest == keyBinding.getKeyDigest()) { Action action = actionManager.getAction(JavaExtension.JAVA_CLASS_STRUCTURE); if (action != null) { ActionEvent e = new ActionEvent(presentationFactor.getPresentation(action), actionManager); action.update(e); if (e.getPresentation().isEnabled()) { event.preventDefault(); event.stopPropagation(); action.actionPerformed(e); } } } } }