List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_EDITOR_BACKSPACE
String ACTION_EDITOR_BACKSPACE
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_EDITOR_BACKSPACE.
Click Source Link
From source file:com.intellij.codeInsight.CodeInsightTestCase.java
License:Apache License
protected void backspace(final Editor editor) { CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override//from www.ja v a2 s. c o m public void run() { EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager .getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } }, "backspace", editor.getDocument()); }
From source file:com.intellij.codeInsight.navigation.IncrementalSearchHandler.java
License:Apache License
public void invoke(Project project, final Editor editor) { if (!ourActionsRegistered) { ourActionsRegistered = true;//from w w w . j a va 2 s.com EditorActionManager actionManager = EditorActionManager.getInstance(); TypedAction typedAction = actionManager.getTypedAction(); typedAction.setupHandler(new MyTypedHandler(typedAction.getHandler())); actionManager.setActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE, new BackSpaceHandler(actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE))); actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP, new UpHandler(actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP))); actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN, new DownHandler(actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN))); } FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.incremental.search"); String selection = editor.getSelectionModel().getSelectedText(); JLabel label2 = new MyLabel(selection == null ? "" : selection); PerEditorSearchData data = editor.getUserData(SEARCH_DATA_IN_EDITOR_VIEW_KEY); if (data == null) { data = new PerEditorSearchData(); } else { if (data.hint != null) { if (data.lastSearch != null) { PerHintSearchData hintData = data.hint.getUserData(SEARCH_DATA_IN_HINT_KEY); //The user has not started typing if ("".equals(hintData.label.getText())) { label2 = new MyLabel(data.lastSearch); } } data.hint.hide(); } } JLabel label1 = new MyLabel(" " + CodeInsightBundle.message("incremental.search.tooltip.prefix")); label1.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); JPanel panel = new MyPanel(label1); panel.add(label1, BorderLayout.WEST); panel.add(label2, BorderLayout.CENTER); panel.setBorder(BorderFactory.createLineBorder(Color.black)); final DocumentListener[] documentListener = new DocumentListener[1]; final CaretListener[] caretListener = new CaretListener[1]; final Document document = editor.getDocument(); final LightweightHint hint = new LightweightHint(panel) { @Override public void hide() { PerHintSearchData data = getUserData(SEARCH_DATA_IN_HINT_KEY); LOG.assertTrue(data != null); String prefix = data.label.getText(); super.hide(); if (data.segmentHighlighter != null) { data.segmentHighlighter.dispose(); } PerEditorSearchData editorData = editor.getUserData(SEARCH_DATA_IN_EDITOR_VIEW_KEY); editorData.hint = null; editorData.lastSearch = prefix; if (documentListener[0] != null) { document.removeDocumentListener(documentListener[0]); } if (caretListener[0] != null) { CaretListener listener = caretListener[0]; editor.getCaretModel().removeCaretListener(listener); } } }; documentListener[0] = new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { if (!hint.isVisible()) return; hint.hide(); } }; document.addDocumentListener(documentListener[0]); caretListener[0] = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { PerHintSearchData data = hint.getUserData(SEARCH_DATA_IN_HINT_KEY); if (data != null && data.ignoreCaretMove) return; if (!hint.isVisible()) return; hint.hide(); } }; CaretListener listener = caretListener[0]; editor.getCaretModel().addCaretListener(listener); final JComponent component = editor.getComponent(); int x = SwingUtilities.convertPoint(component, 0, 0, component).x; int y = -hint.getComponent().getPreferredSize().height; Point p = SwingUtilities.convertPoint(component, x, y, component.getRootPane().getLayeredPane()); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, HintManagerImpl.HIDE_BY_ESCAPE | HintManagerImpl.HIDE_BY_TEXT_CHANGE, 0, false, new HintHint(editor, p).setAwtTooltip(false)); PerHintSearchData hintData = new PerHintSearchData(project, label2); hintData.searchStart = editor.getCaretModel().getOffset(); hint.putUserData(SEARCH_DATA_IN_HINT_KEY, hintData); data.hint = hint; editor.putUserData(SEARCH_DATA_IN_EDITOR_VIEW_KEY, data); if (hintData.label.getText().length() > 0) { updatePosition(editor, hintData, true, false); } }
From source file:com.intellij.execution.impl.ConsoleViewImpl.java
License:Apache License
private void registerConsoleEditorActions() { HyperlinkNavigationAction hyperlinkNavigationAction = new HyperlinkNavigationAction(); hyperlinkNavigationAction.registerCustomShortcutSet(CommonShortcuts.ENTER, myEditor.getContentComponent()); registerActionHandler(myEditor, IdeActions.ACTION_GOTO_DECLARATION, hyperlinkNavigationAction); if (!myIsViewer) { new EnterHandler().registerCustomShortcutSet(CommonShortcuts.ENTER, myEditor.getContentComponent()); registerActionHandler(myEditor, IdeActions.ACTION_EDITOR_PASTE, new PasteHandler()); registerActionHandler(myEditor, IdeActions.ACTION_EDITOR_BACKSPACE, new BackSpaceHandler()); registerActionHandler(myEditor, IdeActions.ACTION_EDITOR_DELETE, new DeleteHandler()); registerActionHandler(myEditor, EOFAction.ACTION_ID, ActionManager.getInstance().getAction(EOFAction.ACTION_ID)); }// www . j a v a2 s .c om }
From source file:com.intellij.testFramework.EditorTestUtil.java
License:Apache License
public static void performTypingAction(Editor editor, char c) { EditorActionManager actionManager = EditorActionManager.getInstance(); if (c == BACKSPACE_FAKE_CHAR) { EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else if (c == SMART_ENTER_FAKE_CHAR) { EditorActionHandler actionHandler = actionManager .getActionHandler(IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else if (c == SMART_LINE_SPLIT_CHAR) { EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_SPLIT); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else if (c == '\n') { EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else {/*from w ww . ja v a 2s . c o m*/ TypedAction action = actionManager.getTypedAction(); action.actionPerformed(editor, c, DataManager.getInstance().getDataContext()); } }
From source file:com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.java
License:Apache License
@Override public void type(final char c) { assertInitialized();/*w ww . java 2 s . c o m*/ UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { final EditorActionManager actionManager = EditorActionManager.getInstance(); if (c == '\b') { performEditorAction(IdeActions.ACTION_EDITOR_BACKSPACE); return; } if (c == '\n') { if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM)) { return; } performEditorAction(IdeActions.ACTION_EDITOR_ENTER); return; } if (c == '\t') { if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE)) { return; } if (_performEditorAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB)) { return; } if (_performEditorAction(IdeActions.ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE)) { return; } if (_performEditorAction(IdeActions.ACTION_EDITOR_TAB)) { return; } } if (c == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) { if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)) { return; } } CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override public void run() { CommandProcessor.getInstance().setCurrentCommandGroupId(myEditor.getDocument()); ActionManagerEx.getInstanceEx().fireBeforeEditorTyping(c, getEditorDataContext()); actionManager.getTypedAction().actionPerformed(getEditor(), c, getEditorDataContext()); } }, null, DocCommandGroupId.noneGroupId(myEditor.getDocument())); } }); }
From source file:com.intellij.testFramework.LightPlatformCodeInsightTestCase.java
License:Apache License
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 {/*ww w .j a v a 2 s . c o m*/ actionManager.getTypedAction().actionPerformed(getEditor(), c, dataContext); } }
From source file:com.intellij.testFramework.LightPlatformCodeInsightTestCase.java
License:Apache License
protected static void backspace() { executeAction(IdeActions.ACTION_EDITOR_BACKSPACE); }
From source file:org.jetbrains.plugins.ruby.ruby.actions.editor.RubyEditorActionsManager.java
License:Apache License
/** * Registers new <code>RubyBackspaceHandler</code> in manager * * @param manager IDEA`s editor action manager * @return RubyBackspace Handler/* w w w. j ava 2 s . c o m*/ * @see RubyBackspaceHandler RubyBackspaceHandler for more details */ public static EditorActionHandler registerRubyBackspaceActionHandler(EditorActionManager manager) { EditorActionHandler myHandler = new RubyBackspaceHandler( manager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE)); manager.setActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE, myHandler); assert (myHandler == manager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE)); return myHandler; }