本文整理汇总了Java中com.intellij.openapi.editor.actionSystem.EditorActionManager类的典型用法代码示例。如果您正苦于以下问题:Java EditorActionManager类的具体用法?Java EditorActionManager怎么用?Java EditorActionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EditorActionManager类属于com.intellij.openapi.editor.actionSystem包,在下文中一共展示了EditorActionManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: drawAllAnswerPlaceholders
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
public static void drawAllAnswerPlaceholders(Editor editor, TaskFile taskFile) {
editor.getMarkupModel().removeAllHighlighters();
final Project project = editor.getProject();
if (project == null) return;
final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
final JBColor color = taskManager.getColor(answerPlaceholder);
EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, color);
}
final Document document = editor.getDocument();
EditorActionManager.getInstance()
.setReadonlyFragmentModificationHandler(document, new EduAnswerPlaceholderDeleteHandler(editor));
EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
editor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null);
}
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyUtils.java
示例2: processTail
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
@Override
public int processTail(final Editor editor, int tailOffset) {
int startOffset = tailOffset;
CharSequence seq = editor.getDocument().getCharsSequence();
int nextNonWs = CharArrayUtil.shiftForward(seq, tailOffset, " \t");
if (nextNonWs < seq.length() && seq.charAt(nextNonWs) == '{') {
tailOffset = nextNonWs + 1;
} else {
tailOffset = insertChar(editor, startOffset, '{');
}
tailOffset = reformatBrace(editor, tailOffset, startOffset);
if (EnterAfterUnmatchedBraceHandler.isAfterUnmatchedLBrace(editor, tailOffset, getFileType(editor))) {
new EnterHandler(EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER))
.executeWriteAction(editor, DataManager.getInstance().getDataContext(editor.getContentComponent()));
return editor.getCaretModel().getOffset();
}
return tailOffset;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:BracesTailType.java
示例3: performTypingAction
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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()));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:EditorTestUtil.java
示例4: executeWriteAction
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
@Override
public void executeWriteAction(@NotNull Editor editor, Caret caret, DataContext dataContext) {
final Document document = editor.getDocument();
final int caretOffset = editor.getCaretModel().getOffset();
if (caretOffset < 1) {
return;
}
final SelectionModel selectionModel = editor.getSelectionModel();
final CharSequence text = document.getCharsSequence();
final char c = text.charAt(caretOffset - 1);
if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) {
int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1;
document.deleteString(startOffset, caretOffset);
}
else {
final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
handler.execute(editor, caret, dataContext);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:HungryBackspaceAction.java
示例5: testRuby7852ErrantEditor
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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");
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SelectionQuotingTypedHandlerTest.java
示例6: testTypeInEmptyConsole
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConsoleViewImplTest.java
示例7: testTypingAfterMultipleCR
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ConsoleViewImplTest.java
示例8: addCompletionChar
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
private static void addCompletionChar(Project project,
CompletionAssertions.WatchingInsertionContext context,
LookupElement item,
Editor editor, CompletionProgressIndicator indicator, char completionChar) {
int tailOffset = context.getTailOffset();
if (tailOffset < 0) {
LOG.info("tailOffset<0 after inserting " + item + " of " + item.getClass() + "; invalidated at: " + context.invalidateTrace + "\n--------");
}
else {
editor.getCaretModel().moveToOffset(tailOffset);
}
if (context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
final Language language = PsiUtilBase.getLanguageInEditor(editor, project);
if (language != null) {
for (SmartEnterProcessor processor : SmartEnterProcessors.INSTANCE.forKey(language)) {
if (processor.processAfterCompletion(editor, indicator.getParameters().getOriginalFile())) break;
}
}
}
else if (!editor.getCaretModel().supportsMultipleCarets()) { // this will be done outside of runForEach caret context
DataContext dataContext = DataManager.getInstance().getDataContext(editor.getContentComponent());
EditorActionManager.getInstance().getTypedAction().getHandler().execute(editor, completionChar, dataContext);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CodeCompletionHandlerBase.java
示例9: replace
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
public static boolean replace(Project project, Editor editor, int offset, FindModel model, ReplaceDelegate delegate) {
Document document = editor.getDocument();
if (!FileDocumentManager.getInstance().requestWriting(document, project)) {
return false;
}
document.startGuardedBlockChecking();
boolean toPrompt = model.isPromptOnReplace();
try {
doReplace(project, editor, model, document, offset, toPrompt, delegate);
}
catch (ReadOnlyFragmentModificationException e) {
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(document).handle(e);
}
finally {
document.stopGuardedBlockChecking();
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:FindUtil.java
示例10: doIndentTest
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
private void doIndentTest(int time) {
configureByFile(getBasePath() + getTestName(false)+".xml");
doHighlighting();
myEditor.getSelectionModel().setSelection(0,myEditor.getDocument().getTextLength());
PlatformTestUtil.startPerformanceTest("Fix long indent/unindent "+time, time, new ThrowableRunnable() {
@Override
public void run() {
EditorActionManager.getInstance().getActionHandler("EditorIndentSelection").execute(myEditor, DataManager.getInstance().getDataContext());
EditorActionManager.getInstance().getActionHandler("EditorUnindentSelection").execute(myEditor, DataManager.getInstance().getDataContext());
}
}).assertTiming();
final int startOffset = myEditor.getCaretModel().getOffset();
myEditor.getSelectionModel().setSelection(startOffset,startOffset);
checkResultByFile(getBasePath() + getTestName(false)+".xml");
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XmlPerformanceTest.java
示例11: runPasteAction
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
private void runPasteAction(final String toPaste) {
final Producer<Transferable> producer = new Producer<Transferable>() {
@Nullable
@Override
public Transferable produce() {
return new StringSelection(toPaste);
}
};
EditorActionManager actionManager = EditorActionManager.getInstance();
EditorActionHandler pasteActionHandler = actionManager.getActionHandler(ACTION_EDITOR_PASTE);
final PasteHandler pasteHandler = new PasteHandler(pasteActionHandler);
new WriteCommandAction.Simple(getProject(), new PsiFile[0]) {
protected void run() throws Throwable {
Component component = myFixture.getEditor().getComponent();
DataContext dataContext = DataManager.getInstance().getDataContext(component);
pasteHandler.execute(myFixture.getEditor(), dataContext, producer);
}
}.execute();
}
开发者ID:platan,项目名称:idea-gradle-dependencies-formatter,代码行数:20,代码来源:MavenToGradleDependenciesCopyPasteProcessorTest.java
示例12: initComponent
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
@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);
}
});
}
开发者ID:baptistemesta,项目名称:power-mode-intellij-plugin,代码行数:23,代码来源:PowerMode.java
示例13: selectWordAtCaret
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
@Override
public void selectWordAtCaret(boolean honorCamelWordsSettings) {
validateContext(true);
removeSelection();
final EditorSettings settings = myEditor.getSettings();
boolean camelTemp = settings.isCamelWords();
final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings;
if (needOverrideSetting) {
settings.setCamelWords(false);
}
try {
EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(
IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
handler.execute(myEditor, myEditor.getDataContext());
}
finally {
if (needOverrideSetting) {
settings.resetCamelWords();
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:SelectionModelImpl.java
示例14: doTest
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:SelectionQuotingTypedHandlerTest.java
示例15: addCompletionChar
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
private static void addCompletionChar(Project project,
CompletionAssertions.WatchingInsertionContext context,
LookupElement item,
Editor editor, CompletionProgressIndicator indicator, char completionChar) {
int tailOffset = context.getTailOffset();
if (tailOffset < 0) {
LOG.info("tailOffset<0 after inserting " + item + " of " + item.getClass() + "; invalidated at: " + context.invalidateTrace + "\n--------");
}
else {
editor.getCaretModel().moveToOffset(tailOffset);
}
if (context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
final Language language = PsiUtilBase.getLanguageInEditor(editor, project);
final List<SmartEnterProcessor> processors = SmartEnterProcessors.INSTANCE.forKey(language);
if (processors.size() > 0) {
for (SmartEnterProcessor processor : processors) {
processor.process(project, editor, indicator.getParameters().getOriginalFile());
}
}
}
else {
DataContext dataContext = DataManager.getInstance().getDataContext(editor.getContentComponent());
EditorActionManager.getInstance().getTypedAction().getHandler().execute(editor, completionChar, dataContext);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:CodeCompletionHandlerBase.java
示例16: doTest
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:SelectionQuotingTypedHandlerTest.java
示例17: testRuby7852ErrantEditor
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
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");
}
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:SelectionQuotingTypedHandlerTest.java
示例18: executeWriteAction
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
@Override
public void executeWriteAction(@Nonnull Editor editor, Caret caret, DataContext dataContext) {
final Document document = editor.getDocument();
final int caretOffset = editor.getCaretModel().getOffset();
if (caretOffset < 1) {
return;
}
final SelectionModel selectionModel = editor.getSelectionModel();
final CharSequence text = document.getCharsSequence();
final char c = text.charAt(caretOffset - 1);
if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) {
int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1;
document.deleteString(startOffset, caretOffset);
}
else {
final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
handler.execute(editor, caret, dataContext);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:HungryBackspaceAction.java
示例19: selectWordAtCaret
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
@Override
public void selectWordAtCaret(final boolean honorCamelWordsSettings) {
validateContext(true);
myEditor.getCaretModel().doWithCaretMerging(() -> {
removeSelection();
final EditorSettings settings = myEditor.getSettings();
boolean camelTemp = settings.isCamelWords();
final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings;
if (needOverrideSetting) {
settings.setCamelWords(false);
}
try {
EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
handler.execute(myEditor, this, myEditor.getDataContext());
}
finally {
if (needOverrideSetting) {
settings.resetCamelWords();
}
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:CaretImpl.java
示例20: addCompletionChar
import com.intellij.openapi.editor.actionSystem.EditorActionManager; //导入依赖的package包/类
private static void addCompletionChar(Project project,
CompletionAssertions.WatchingInsertionContext context,
LookupElement item,
Editor editor, CompletionProgressIndicator indicator, char completionChar) {
if (!context.getOffsetMap().containsOffset(InsertionContext.TAIL_OFFSET)) {
LOG.info("tailOffset<0 after inserting " + item + " of " + item.getClass() + "; invalidated at: " + context.invalidateTrace + "\n--------");
}
else {
editor.getCaretModel().moveToOffset(context.getTailOffset());
}
if (context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
final Language language = PsiUtilBase.getLanguageInEditor(editor, project);
if (language != null) {
for (SmartEnterProcessor processor : SmartEnterProcessors.INSTANCE.forKey(language)) {
if (processor.processAfterCompletion(editor, indicator.getParameters().getOriginalFile())) break;
}
}
}
else if (!editor.getCaretModel().supportsMultipleCarets()) { // this will be done outside of runForEach caret context
DataContext dataContext = DataManager.getInstance().getDataContext(editor.getContentComponent());
EditorActionManager.getInstance().getTypedAction().getHandler().execute(editor, completionChar, dataContext);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:CodeCompletionHandlerBase.java
注:本文中的com.intellij.openapi.editor.actionSystem.EditorActionManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论