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

The following examples show how to use com.intellij.openapi.editor.actionSystem.EditorActionManager#getInstance() . 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: PowerMode.java    From power-mode-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void initComponent() {

    final EditorActionManager editorActionManager = EditorActionManager.getInstance();
    final EditorFactory editorFactory = EditorFactory.getInstance();
    particleContainerManager = new ParticleContainerManager();
    editorFactory.addEditorFactoryListener(particleContainerManager, new Disposable() {
        @Override
        public void dispose() {

        }
    });
    final TypedAction typedAction = editorActionManager.getTypedAction();
    final TypedActionHandler rawHandler = typedAction.getRawHandler();
    typedAction.setupRawHandler(new TypedActionHandler() {
        @Override
        public void execute(@NotNull final Editor editor, final char c, @NotNull final DataContext dataContext) {
            updateEditor(editor);
            rawHandler.execute(editor, c, dataContext);
        }
    });
}
 
Example 3
Source File: StartupEvent.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void setupHandlersForSnapshots(ProgressObserver observer) {
    observer.progress(0, 0.70, "Setting handlers");
    final EditorActionManager actionManager = EditorActionManager.getInstance();
    final TypedAction typedAction = actionManager.getTypedAction();
    TypedActionHandler originalHandler = actionManager.getTypedAction().getHandler();
    typedAction.setupHandler(new ActivateSnapshotsAction(originalHandler));
}
 
Example 4
Source File: LightPlatformCodeInsightTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected static void type(char c) {
  EditorActionManager actionManager = EditorActionManager.getInstance();
  final DataContext dataContext = DataManager.getInstance().getDataContext();
  if (c == '\n') {
    actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(getEditor(), dataContext);
  }
  else if (c == '\b') {
    actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE).execute(getEditor(), dataContext);
  }
  else {
    actionManager.getTypedAction().actionPerformed(getEditor(), c, dataContext);
  }
}
 
Example 5
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);
        }
    }
}
 
Example 6
Source File: EditorTestUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void performPaste(Editor editor) {
  EditorActionManager actionManager = EditorActionManager.getInstance();
  EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_PASTE);
  actionHandler.execute(editor, DataManager.getInstance().getDataContext());
}
 
Example 7
Source File: LightPlatformCodeInsightTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void caretUp() {
  EditorActionManager actionManager = EditorActionManager.getInstance();
  EditorActionHandler action = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP);
  action.execute(getEditor(), DataManager.getInstance().getDataContext());
}
 
Example 8
Source File: LightPlatformCodeInsightTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void deleteLine() {
  EditorActionManager actionManager = EditorActionManager.getInstance();
  EditorActionHandler action = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_DELETE_LINE);
  action.execute(getEditor(), DataManager.getInstance().getDataContext());
}