Java 类com.intellij.openapi.editor.actionSystem.TypedAction 实例源码

项目:intellij-ce-playground    文件:EditorTestUtil.java   
public static void performTypingAction(Editor editor, char c) {
  EditorActionManager actionManager = EditorActionManager.getInstance();
  if (c == BACKSPACE_FAKE_CHAR) {
    executeAction(editor, IdeActions.ACTION_EDITOR_BACKSPACE);
  } else if (c == SMART_ENTER_FAKE_CHAR) {
    executeAction(editor, IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT);
  } else if (c == SMART_LINE_SPLIT_CHAR) {
    executeAction(editor, IdeActions.ACTION_EDITOR_SPLIT);
  }
  else if (c == '\n') {
    executeAction(editor, IdeActions.ACTION_EDITOR_ENTER);
  }
  else {
    TypedAction action = actionManager.getTypedAction();
    action.actionPerformed(editor, c, DataManager.getInstance().getDataContext(editor.getContentComponent()));
  }
}
项目:intellij-ce-playground    文件:SelectionQuotingTypedHandlerTest.java   
public void testRuby7852ErrantEditor() {
  myFixture.configureByText(FileTypes.PLAIN_TEXT, "\"aaa\"\nbbb\n\n");
  myFixture.getEditor().getCaretModel().moveToOffset(0);
  myFixture.getEditor().getSelectionModel().setSelection(0, 5);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), '\'', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.getEditor().getSelectionModel().removeSelection();
  myFixture.checkResult("'aaa'\nbbb\n\n");

  myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getLineStartOffset(3));
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), 'A', ((EditorEx)myFixture.getEditor()).getDataContext());
      typedAction.actionPerformed(myFixture.getEditor(), 'B', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.checkResult("'aaa'\nbbb\n\nAB");
}
项目:intellij-ce-playground    文件:ConsoleViewImplTest.java   
public void testTypeInEmptyConsole() throws Exception {
  final ConsoleViewImpl console = createConsole();
  try {
    console.clear();
    EditorActionManager actionManager = EditorActionManager.getInstance();
    final DataContext dataContext = DataManager.getInstance().getDataContext();
    TypedAction action = actionManager.getTypedAction();
    action.actionPerformed(console.getEditor(), 'h', dataContext);
    assertEquals(1, console.getContentSize());
  }
  catch (Exception e) {
    e.printStackTrace();
  }
  finally {
    Disposer.dispose(console);
  }
}
项目:intellij-ce-playground    文件:ConsoleViewImplTest.java   
public void testTypingAfterMultipleCR() throws Exception {
  final EditorActionManager actionManager = EditorActionManager.getInstance();
  final TypedAction typedAction = actionManager.getTypedAction();
  final TestDataProvider dataContext = new TestDataProvider(getProject());

  final ConsoleViewImpl console = createConsole();
  final Editor editor = console.getEditor();
  try {
    console.print("System output\n", ConsoleViewContentType.SYSTEM_OUTPUT);
    console.print("\r\r\r\r\r\r\r", ConsoleViewContentType.NORMAL_OUTPUT);
    console.flushDeferredText();

    typedAction.actionPerformed(editor, '1', dataContext);
    typedAction.actionPerformed(editor, '2', dataContext);

    assertEquals("System output\n12", editor.getDocument().getText());
  }
  finally {
    Disposer.dispose(console);
  }
}
项目:power-mode-intellij-plugin    文件:PowerMode.java   
@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);
        }
    });
}
项目:tools-idea    文件:SelectionQuotingTypedHandlerTest.java   
private void doTest(@NotNull final String cs, @NotNull String before, @NotNull String expected) {
  final boolean smarterSelection = Registry.is("editor.smarterSelectionQuoting");
  Registry.get("editor.smarterSelectionQuoting").setValue(true);
  try {
    myFixture.configureByText(FileTypes.PLAIN_TEXT, before);
    final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();

    performAction(myFixture.getProject(), new Runnable() {
      @Override
      public void run() {
        for (int i = 0, max = cs.length(); i < max; i++) {
          final char c = cs.charAt(i);
          typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
        }
      }
    });
    myFixture.checkResult(expected);
  } finally {
    Registry.get("editor.smarterSelectionQuoting").setValue(smarterSelection);
  }
}
项目:tools-idea    文件:SelectionQuotingTypedHandlerTest.java   
public void testRuby7852ErrantEditor() {
  myFixture.configureByText(FileTypes.PLAIN_TEXT, "\"aaa\"\nbbb\n\n");
  myFixture.getEditor().getCaretModel().moveToOffset(0);
  myFixture.getEditor().getSelectionModel().setSelection(0, 5);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), '\'', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.getEditor().getSelectionModel().removeSelection();
  myFixture.checkResult("'aaa'\nbbb\n\n");

  myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getLineStartOffset(3));
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), 'A', ((EditorEx)myFixture.getEditor()).getDataContext());
      typedAction.actionPerformed(myFixture.getEditor(), 'B', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.checkResult("'aaa'\nbbb\n\nAB");
}
项目:consulo    文件:SelectionQuotingTypedHandlerTest.java   
private void doTest(@Nonnull final String cs, @Nonnull String before, @Nonnull String expected) {
  final boolean smarterSelection = Registry.is("editor.smarterSelectionQuoting");
  Registry.get("editor.smarterSelectionQuoting").setValue(true);
  try {
    myFixture.configureByText(PlainTextFileType.INSTANCE, before);
    final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();

    performAction(myFixture.getProject(), new Runnable() {
      @Override
      public void run() {
        for (int i = 0, max = cs.length(); i < max; i++) {
          final char c = cs.charAt(i);
          typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
        }
      }
    });
    myFixture.checkResult(expected);
  } finally {
    Registry.get("editor.smarterSelectionQuoting").setValue(smarterSelection);
  }
}
项目:consulo    文件:SelectionQuotingTypedHandlerTest.java   
public void testRuby7852ErrantEditor() {
  myFixture.configureByText(PlainTextFileType.INSTANCE, "\"aaa\"\nbbb\n\n");
  myFixture.getEditor().getCaretModel().moveToOffset(0);
  myFixture.getEditor().getSelectionModel().setSelection(0, 5);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), '\'', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.getEditor().getSelectionModel().removeSelection();
  myFixture.checkResult("'aaa'\nbbb\n\n");

  myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getLineStartOffset(3));
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), 'A', ((EditorEx)myFixture.getEditor()).getDataContext());
      typedAction.actionPerformed(myFixture.getEditor(), 'B', ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.checkResult("'aaa'\nbbb\n\nAB");
}
项目:tmc-intellij    文件:StartupEvent.java   
private void setupHandlersForSpyware(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 ActivateSpywareAction(originalHandler));
}
项目:intellij-ce-playground    文件:LightPlatformCodeInsightTestCase.java   
public static void type(char c, @NotNull Editor editor, Project project) {
  if (c == '\n') {
    executeAction(IdeActions.ACTION_EDITOR_ENTER, editor,project);
  }
  else {
    EditorActionManager actionManager = EditorActionManager.getInstance();
    final DataContext dataContext = DataManager.getInstance().getDataContext();
    TypedAction action = actionManager.getTypedAction();
    action.actionPerformed(editor, c, dataContext);
  }
}
项目:intellij-ce-playground    文件:ActionMacro.java   
public void playBack(DataContext context) {
  Editor editor = CommonDataKeys.EDITOR.getData(context);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  for (final char aChar : myText.toCharArray()) {
    typedAction.actionPerformed(editor, aChar, context);
  }
}
项目:intellij-ce-playground    文件:SelectionQuotingTypedHandlerTest.java   
private void doTest(@NotNull final String cs, @NotNull String before, @NotNull String expected) {
  myFixture.configureByText(FileTypes.PLAIN_TEXT, before);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();

  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      for (int i = 0, max = cs.length(); i < max; i++) {
        final char c = cs.charAt(i);
        typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
      }
    }
  });
  myFixture.checkResult(expected);
}
项目:PhpStorm    文件:SmartyTypedActionHandlerComponent.java   
/**
 * Replace the default key handling.
 */
public void initComponent ()
{
    EditorActionManager manager = EditorActionManager.getInstance();
    TypedAction action          = manager.getTypedAction();

    typed_handler = new SmartyTypedActionHandler(action.getHandler());
    action.setupHandler(typed_handler);
}
项目:PhpStorm    文件:SmartyTypedActionHandlerComponent.java   
/**
 * Restore the default key handling.
 */
public void disposeComponent ()
{
    EditorActionManager manager = EditorActionManager.getInstance();
    TypedAction action          = manager.getTypedAction();

    action.setupHandler(typed_handler.getOriginalTypedHandler());
}
项目:tools-idea    文件:CodeInsightTestCase.java   
protected static void type(char c, Editor editor) {
  EditorActionManager actionManager = EditorActionManager.getInstance();
  DataContext dataContext = DataManager.getInstance().getDataContext();
  if (c == '\n') {
    actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, dataContext);
    return;
  }
  TypedAction action = actionManager.getTypedAction();
  action.actionPerformed(editor, c, dataContext);
}
项目:tools-idea    文件:ActionMacro.java   
public void playBack(DataContext context) {
  Editor editor = PlatformDataKeys.EDITOR.getData(context);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  for (final char aChar : myText.toCharArray()) {
    typedAction.actionPerformed(editor, aChar, context);
  }
}
项目:tools-idea    文件:SelectionQuotingTypedHandlerTest.java   
private void doTest(final char c, @NotNull String before, @NotNull String expected) {
  myFixture.configureByText(FileTypes.PLAIN_TEXT, before);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.getEditor().getSelectionModel().removeSelection();
  myFixture.checkResult(expected);
}
项目:consulo    文件:SelectionQuotingTypedHandlerTest.java   
private void doTest(final char c, @Nonnull String before, @Nonnull String expected) {
  myFixture.configureByText(PlainTextFileType.INSTANCE, before);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  performAction(myFixture.getProject(), new Runnable() {
    @Override
    public void run() {
      typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx)myFixture.getEditor()).getDataContext());
    }
  });
  myFixture.getEditor().getSelectionModel().removeSelection();
  myFixture.checkResult(expected);
}
项目:consulo    文件:ActionMacro.java   
public void playBack(DataContext context) {
  Editor editor = context.getData(PlatformDataKeys.EDITOR);
  final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
  for (final char aChar : myText.toCharArray()) {
    typedAction.actionPerformed(editor, aChar, context);
  }
}
项目:consulo-java    文件:CodeInsightTestCase.java   
protected static void type(char c, Editor editor)
{
    EditorActionManager actionManager = EditorActionManager.getInstance();
    DataContext dataContext = DataManager.getInstance().getDataContext();
    if(c == '\n')
    {
        actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, dataContext);
        return;
    }
    TypedAction action = actionManager.getTypedAction();
    action.actionPerformed(editor, c, dataContext);
}
项目:tools-idea    文件:CompletionPhase.java   
public EmptyAutoPopup(CompletionProgressIndicator indicator) {
  super(indicator);
  editor = indicator.getEditor();
  project = indicator.getProject();
  MessageBusConnection connection = project.getMessageBus().connect(this);
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
    @Override
    public void selectionChanged(@NotNull FileEditorManagerEvent event) {
      stopAutoPopup();
    }
  });

  mouseListener = new EditorMouseAdapter() {
    @Override
    public void mouseClicked(EditorMouseEvent e) {
      stopAutoPopup();
    }
  };

  caretListener = new CaretListener() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      if (!TypedAction.isTypedActionInProgress()) {
        stopAutoPopup();
      }
    }
  };
  selectionListener = new SelectionListener() {
    @Override
    public void selectionChanged(SelectionEvent e) {
      stopAutoPopup();
    }
  };

  editor.addEditorMouseListener(mouseListener);
  editor.getCaretModel().addCaretListener(caretListener);
  editor.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    public void documentChanged(DocumentEvent e) {
      if (!TypedAction.isTypedActionInProgress()) {
        stopAutoPopup();
      }
    }
  }, this);
  editor.getSelectionModel().addSelectionListener(selectionListener);
  LookupManager.getInstance(project).addPropertyChangeListener(new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      stopAutoPopup();
    }
  }, this);
}
项目:enclosing-jidea-plugin    文件:EnclosingMod.java   
public void moduleAdded() {
    EditorActionManager manager = EditorActionManager.getInstance();
    TypedAction typedAction = manager.getTypedAction();
    typedAction.setupHandler(new EncloseTypedAction(typedAction.getHandler()));
}