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())); } }
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"); }
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); } }
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); } }
@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); } }); }
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); } }
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); } }
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"); }
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)); }
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); } }
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); } }
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); }
/** * 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); }
/** * Restore the default key handling. */ public void disposeComponent () { EditorActionManager manager = EditorActionManager.getInstance(); TypedAction action = manager.getTypedAction(); action.setupHandler(typed_handler.getOriginalTypedHandler()); }
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); }
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); } }
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); }
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); }
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); } }
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); }
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); }
public void moduleAdded() { EditorActionManager manager = EditorActionManager.getInstance(); TypedAction typedAction = manager.getTypedAction(); typedAction.setupHandler(new EncloseTypedAction(typedAction.getHandler())); }