Java Code Examples for com.intellij.openapi.editor.actionSystem.EditorActionManager#setActionHandler()

The following examples show how to use com.intellij.openapi.editor.actionSystem.EditorActionManager#setActionHandler() . 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: JumpHandler.java    From KJump with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void stop() {
    if (isStart) {
        isStart = false;
        EditorActionManager manager = EditorActionManager.getInstance();
        manager.getTypedAction().setupRawHandler(mOldTypedHandler);
        if (mOldEscActionHandler != null) {
            manager.setActionHandler(IdeActions.ACTION_EDITOR_ESCAPE, mOldEscActionHandler);
        }

        Container parent = mMarksCanvas.getParent();
        if (parent != null) {
            parent.remove(mMarksCanvas);
            parent.repaint();
        }

        isCanvasAdded = false;
    }
}
 
Example 2
Source File: JumpHandler.java    From KJump with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * start search mode
 *
 * @param mode mode enum, see {@link #MODE_CHAR1} {@link #MODE_CHAR2} etc
 */
public final void start(@NotNull Editor e, int mode) {
    if (!isStart) {
        isStart = true;
        EditorActionManager manager = EditorActionManager.getInstance();
        TypedAction typedAction = manager.getTypedAction();

        mOldTypedHandler = typedAction.getRawHandler();
        typedAction.setupRawHandler(this);

        mOldEscActionHandler = manager.getActionHandler(IdeActions.ACTION_EDITOR_ESCAPE);
        manager.setActionHandler(IdeActions.ACTION_EDITOR_ESCAPE, escActionHandler);

        switch (mode) {
            case MODE_CHAR1:
                finder = new Char1Finder();
                break;
            case MODE_CHAR2:
                finder = new Char2Finder();
                break;
            case MODE_WORD0:
                finder = new Word0Finder();
                break;
            case MODE_WORD1:
                finder = new Word1Finder();
                break;
            case MODE_LINE:
                finder = new LineFinder();
                break;
            default:
                throw new RuntimeException("Invalid start mode: " + mode);
        }

        TextRange visibleBorderOffset = EditorUtils.getVisibleRangeOffset(e);
        String visibleString = e.getDocument().getText(visibleBorderOffset);
        List<MarksCanvas.Mark> marks = finder.start(e, visibleString, visibleBorderOffset);
        if (marks != null) {
            lastMarks = marks;
            this.jumpOrShowCanvas(e, lastMarks);
        }
    }
}