Search in sources :

Example 1 with ConsoleActionsPostProcessor

use of com.intellij.execution.actions.ConsoleActionsPostProcessor in project intellij-community by JetBrains.

the class ConsoleViewImpl method popupInvoked.

private void popupInvoked(@NotNull MouseEvent mouseEvent) {
    final ActionManager actionManager = ActionManager.getInstance();
    final HyperlinkInfo info = myHyperlinks != null ? myHyperlinks.getHyperlinkInfoByPoint(mouseEvent.getPoint()) : null;
    ActionGroup group = null;
    if (info instanceof HyperlinkWithPopupMenuInfo) {
        group = ((HyperlinkWithPopupMenuInfo) info).getPopupMenuGroup(mouseEvent);
    }
    if (group == null) {
        group = (ActionGroup) actionManager.getAction(CONSOLE_VIEW_POPUP_MENU);
    }
    final ConsoleActionsPostProcessor[] postProcessors = Extensions.getExtensions(ConsoleActionsPostProcessor.EP_NAME);
    AnAction[] result = group.getChildren(null);
    for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
        result = postProcessor.postProcessPopupActions(this, result);
    }
    final DefaultActionGroup processedGroup = new DefaultActionGroup(result);
    final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, processedGroup);
    menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}
Also used : ConsoleActionsPostProcessor(com.intellij.execution.actions.ConsoleActionsPostProcessor)

Example 2 with ConsoleActionsPostProcessor

use of com.intellij.execution.actions.ConsoleActionsPostProcessor in project intellij-community by JetBrains.

the class ConsoleViewImpl method createConsoleActions.

@Override
@NotNull
public AnAction[] createConsoleActions() {
    //Initializing prev and next occurrences actions
    final CommonActionsManager actionsManager = CommonActionsManager.getInstance();
    final AnAction prevAction = actionsManager.createPrevOccurenceAction(this);
    prevAction.getTemplatePresentation().setText(getPreviousOccurenceActionName());
    final AnAction nextAction = actionsManager.createNextOccurenceAction(this);
    nextAction.getTemplatePresentation().setText(getNextOccurenceActionName());
    final AnAction switchSoftWrapsAction = new ToggleUseSoftWrapsToolbarAction(SoftWrapAppliancePlaces.CONSOLE) {

        @Override
        protected Editor getEditor(AnActionEvent e) {
            return myEditor;
        }

        @Override
        public void setSelected(AnActionEvent e, final boolean state) {
            super.setSelected(e, state);
            if (myEditor == null) {
                return;
            }
            final String placeholder = myCommandLineFolding.getPlaceholder(0);
            final FoldingModel foldingModel = myEditor.getFoldingModel();
            final int firstLineEnd = myEditor.getDocument().getLineEndOffset(0);
            foldingModel.runBatchFoldingOperation(() -> {
                FoldRegion[] regions = foldingModel.getAllFoldRegions();
                if (regions.length > 0 && regions[0].getStartOffset() == 0 && regions[0].getEndOffset() == firstLineEnd) {
                    foldingModel.removeFoldRegion(regions[0]);
                }
                if (placeholder != null) {
                    FoldRegion foldRegion = foldingModel.addFoldRegion(0, firstLineEnd, placeholder);
                    if (foldRegion != null) {
                        foldRegion.setExpanded(false);
                    }
                }
            });
        }
    };
    final AnAction autoScrollToTheEndAction = new ScrollToTheEndToolbarAction(myEditor);
    //Initializing custom actions
    final AnAction[] consoleActions = new AnAction[6 + customActions.size()];
    consoleActions[0] = prevAction;
    consoleActions[1] = nextAction;
    consoleActions[2] = switchSoftWrapsAction;
    consoleActions[3] = autoScrollToTheEndAction;
    consoleActions[4] = ActionManager.getInstance().getAction("Print");
    consoleActions[5] = new ClearAllAction(this);
    for (int i = 0; i < customActions.size(); ++i) {
        consoleActions[i + 6] = customActions.get(i);
    }
    ConsoleActionsPostProcessor[] postProcessors = Extensions.getExtensions(ConsoleActionsPostProcessor.EP_NAME);
    AnAction[] result = consoleActions;
    for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
        result = postProcessor.postProcess(this, result);
    }
    return result;
}
Also used : ToggleUseSoftWrapsToolbarAction(com.intellij.openapi.editor.actions.ToggleUseSoftWrapsToolbarAction) RelativePoint(com.intellij.ui.awt.RelativePoint) ConsoleActionsPostProcessor(com.intellij.execution.actions.ConsoleActionsPostProcessor) ScrollToTheEndToolbarAction(com.intellij.openapi.editor.actions.ScrollToTheEndToolbarAction) CommonActionsManager(com.intellij.ide.CommonActionsManager) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ConsoleActionsPostProcessor (com.intellij.execution.actions.ConsoleActionsPostProcessor)2 CommonActionsManager (com.intellij.ide.CommonActionsManager)1 ScrollToTheEndToolbarAction (com.intellij.openapi.editor.actions.ScrollToTheEndToolbarAction)1 ToggleUseSoftWrapsToolbarAction (com.intellij.openapi.editor.actions.ToggleUseSoftWrapsToolbarAction)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 NotNull (org.jetbrains.annotations.NotNull)1