当前位置: 首页>>代码示例>>Java>>正文


Java DocumentUtil.writeInRunUndoTransparentAction方法代码示例

本文整理汇总了Java中com.intellij.util.DocumentUtil.writeInRunUndoTransparentAction方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentUtil.writeInRunUndoTransparentAction方法的具体用法?Java DocumentUtil.writeInRunUndoTransparentAction怎么用?Java DocumentUtil.writeInRunUndoTransparentAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.DocumentUtil的用法示例。


在下文中一共展示了DocumentUtil.writeInRunUndoTransparentAction方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTextElement

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
private void updateTextElement(final PsiElement elt) {
  final String newText = getNewText(elt);
  if (newText == null || Comparing.strEqual(newText, myEditor.getDocument().getText())) return;
  DocumentUtil.writeInRunUndoTransparentAction(new Runnable() {
    @Override
    public void run() {
      Document fragmentDoc = myEditor.getDocument();
      fragmentDoc.setReadOnly(false);

      fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), newText);
      fragmentDoc.setReadOnly(true);
      myEditor.getCaretModel().moveToOffset(0);
      myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ImplementationViewComponent.java

示例2: addToHistoryInner

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
@NotNull
protected String addToHistoryInner(@NotNull final TextRange textRange, @NotNull final EditorEx editor, boolean erase, final boolean preserveMarkup) {
  ApplicationManager.getApplication().assertIsDispatchThread();

  String result = addTextRangeToHistory(textRange, editor, preserveMarkup);
  if (erase) {
    DocumentUtil.writeInRunUndoTransparentAction(new Runnable() {
      @Override
      public void run() {
        editor.getDocument().deleteString(textRange.getStartOffset(), textRange.getEndOffset());
      }
    });
  }
  // always scroll to end on user input
  scrollToEnd();
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LanguageConsoleImpl.java

示例3: addPlaceholder

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
private void addPlaceholder(@NotNull CCState state) {
  Editor editor = state.getEditor();
  Project project = state.getProject();
  Document document = editor.getDocument();
  FileDocumentManager.getInstance().saveDocument(document);
  final SelectionModel model = editor.getSelectionModel();
  final int offset = model.hasSelection() ? model.getSelectionStart() : editor.getCaretModel().getOffset();
  TaskFile taskFile = state.getTaskFile();
  final Task task = state.getTaskFile().getTask();
  int subtaskIndex = task instanceof TaskWithSubtasks ? ((TaskWithSubtasks)task).getActiveSubtaskIndex() : 0;
  final AnswerPlaceholder answerPlaceholder = new AnswerPlaceholder();
  AnswerPlaceholderSubtaskInfo info = new AnswerPlaceholderSubtaskInfo();
  answerPlaceholder.getSubtaskInfos().put(subtaskIndex, info);
  int index = taskFile.getAnswerPlaceholders().size();
  answerPlaceholder.setIndex(index);
  answerPlaceholder.setTaskFile(taskFile);
  taskFile.sortAnswerPlaceholders();
  answerPlaceholder.setOffset(offset);
  answerPlaceholder.setUseLength(false);

  String defaultPlaceholderText = "type here";
  CCCreateAnswerPlaceholderDialog dlg = createDialog(project, answerPlaceholder);
  if (!dlg.showAndGet()) {
    return;
  }
  String answerPlaceholderText = dlg.getTaskText();
  answerPlaceholder.setPossibleAnswer(model.hasSelection() ? model.getSelectedText() : defaultPlaceholderText);
  answerPlaceholder.setTaskText(StringUtil.notNullize(answerPlaceholderText));
  answerPlaceholder.setLength(StringUtil.notNullize(answerPlaceholderText).length());
  answerPlaceholder.setHints(dlg.getHints());

  if (!model.hasSelection()) {
    DocumentUtil.writeInRunUndoTransparentAction(() -> document.insertString(offset, defaultPlaceholderText));
  }

  answerPlaceholder.setPossibleAnswer(model.hasSelection() ? model.getSelectedText() : defaultPlaceholderText);
  AddAction action = new AddAction(answerPlaceholder, taskFile, editor);
  EduUtils.runUndoableAction(project, "Add Answer Placeholder", action);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:40,代码来源:CCAddAnswerPlaceholder.java

示例4: setInputText

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
public void setInputText(@NotNull final String query) {
  DocumentUtil.writeInRunUndoTransparentAction(new Runnable() {
    @Override
    public void run() {
      myConsoleEditor.getDocument().setText(query);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:LanguageConsoleImpl.java

示例5: setText

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
public void setText(final String bytecode, final int offset) {
  DocumentUtil.writeInRunUndoTransparentAction(new Runnable() {
    @Override
    public void run() {
      Document fragmentDoc = myEditor.getDocument();
      fragmentDoc.setReadOnly(false);
      fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), bytecode);
      fragmentDoc.setReadOnly(true);
      myEditor.getCaretModel().moveToOffset(offset);
      myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ByteCodeViewerComponent.java

示例6: appendToDocument

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
public static void appendToDocument(@NotNull final Document document, final String text) {
  DocumentUtil.writeInRunUndoTransparentAction(new Runnable() {
    @Override
    public void run() {
      document.insertString(document.getTextLength(), text);
    }
  });
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:9,代码来源:TheRUtils.java

示例7: addToHistoryInner

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
@Nonnull
protected String addToHistoryInner(@Nonnull final TextRange textRange, @Nonnull final EditorEx editor, boolean erase, final boolean preserveMarkup) {
  ApplicationManager.getApplication().assertIsDispatchThread();

  String result = addTextRangeToHistory(textRange, editor, preserveMarkup);
  if (erase) {
    DocumentUtil.writeInRunUndoTransparentAction(() -> editor.getDocument().deleteString(textRange.getStartOffset(), textRange.getEndOffset()));
  }
  // always scroll to end on user input
  scrollToEnd();
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:LanguageConsoleImpl.java

示例8: invoke

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException {
    DocumentUtil.writeInRunUndoTransparentAction(new Runnable() {
        @Override
        public void run() {
            List<AndroidView> androidViews = AndroidUtils.getIDsFromXML(xmlFile);

            PsiStatement psiStatement = PsiTreeUtil.getParentOfType(psiElement, PsiStatement.class);
            if (psiStatement == null) {
                return;
            }

            PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiStatement.getProject());

            PsiElement[] localVariables = PsiTreeUtil.collectElements(psiStatement.getParent(), new PsiElementFilter() {
                @Override
                public boolean isAccepted(PsiElement element) {
                    return element instanceof PsiLocalVariable;
                }
            });

            Set<String> variables = new HashSet<String>();
            for (PsiElement localVariable : localVariables) {
                variables.add(((PsiLocalVariable) localVariable).getName());
            }

            for (AndroidView v : androidViews) {
                if (!variables.contains(v.getFieldName())) {
                    String sb1;

                    if (variableName != null) {
                        sb1 = String.format("%s %s = (%s) %s.findViewById(%s);", v.getName(), v.getFieldName(), v.getName(), variableName, v.getId());
                    } else {
                        sb1 = String.format("%s %s = (%s) findViewById(%s);", v.getName(), v.getFieldName(), v.getName(), v.getId());
                    }

                    PsiStatement statementFromText = elementFactory.createStatementFromText(sb1, null);
                    psiStatement.getParent().addAfter(statementFromText, psiStatement);
                }
            }

            JavaCodeStyleManager.getInstance(psiStatement.getProject()).shortenClassReferences(psiStatement.getParent());
            new ReformatAndOptimizeImportsProcessor(psiStatement.getProject(), psiStatement.getContainingFile(), true).run();

        }
    });

}
 
开发者ID:Haehnchen,项目名称:idea-android-studio-plugin,代码行数:49,代码来源:InflateLocalVariableAction.java

示例9: setInputText

import com.intellij.util.DocumentUtil; //导入方法依赖的package包/类
public void setInputText(@Nonnull final String query) {
  DocumentUtil.writeInRunUndoTransparentAction(() -> myConsoleEditor.getDocument().setText(StringUtil.convertLineSeparators(query)));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:4,代码来源:LanguageConsoleImpl.java


注:本文中的com.intellij.util.DocumentUtil.writeInRunUndoTransparentAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。