Package com.intellij.openapi.command

Examples of com.intellij.openapi.command.WriteCommandAction


    }

    final Pass<OccurrencesChooser.ReplaceChoice> callback = new Pass<OccurrencesChooser.ReplaceChoice>() {
      @Override
      public void pass(final OccurrencesChooser.ReplaceChoice choice) {
        new WriteCommandAction(project, REFACTORING_NAME, file) {
          @Override
          protected void run(com.intellij.openapi.application.Result result) throws Throwable {
            buildTemplateAndRun(project, editor, bnfFile, occurrencesMap.get(choice), tokenName, tokenText, tokenMap);
          }
        }.execute();
View Full Code Here


                            final String title,
                            final Consumer<PsiClass> consumer) {
    final Project project = targetDirectory.getProject();
    final Ref<PsiClass> resultRef = Ref.create();

    new WriteCommandAction(project, title) {
      @Override
      protected void run(Result result) throws Throwable {
        IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();

        PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
View Full Code Here

    final PsiClass psiClass = getStepDefClass();
    final PsiFile psiFile = psiClass.getContainingFile();

    final Ref<String> createdMethodName = new Ref<String>();

    new WriteCommandAction(getProject(), psiFile) {
      @Override
      protected void run(final Result result) throws Throwable {
        final PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
        final PsiMethod method = factory.createMethodFromText(stepDef, psiClass);
        psiClass.add(method);
View Full Code Here

  private void deleteStepDefinition(@NotNull final String stepDefName) {
    final PsiClass psiClass = getStepDefClass();
    final PsiFile psiFile = psiClass.getContainingFile();

    new WriteCommandAction(getProject(), psiFile) {
      @Override
      protected void run(Result result) throws Throwable {

        for (PsiMethod method : psiClass.getAllMethods()) {
          if (method.getName().equals(stepDefName)) {
View Full Code Here

      final ObrMavenResult mavenResult =
        ObrSearchDialog.queryForMavenArtifact(project, dependency.getArtifactId().toString());
      if (mavenResult != null) {

        final PsiFile psiFile = problemDescriptor.getPsiElement().getContainingFile();
        new WriteCommandAction(project, psiFile) {
          protected void run(Result result) throws Throwable

          {
            MavenDomProjectModel model =
              MavenDomUtil.getMavenDomProjectModel(getProject(), psiFile.getVirtualFile());
View Full Code Here

  private void applyFixInner(final Project project) {
    final PsiFile psiFile = myClass.getContainingFile();
    final Editor editor = CodeInsightUtil.positionCursor(project, psiFile, myClass.getLBrace());
    if (editor != null) {
      new WriteCommandAction(project, psiFile) {
        protected void run(@NotNull Result result) throws Throwable {

          final PsiElementFactory psiElementFactory = JavaPsiFacade.getInstance(myClass.getProject()).getElementFactory();
          final PsiField psiField = psiElementFactory.createField(myName, myType);
View Full Code Here

  private void applyFixInner(final Project project) {
    final PsiFile file = myAnnotation.getContainingFile();
    final Editor editor = CodeInsightUtil.positionCursor(project, file, myAnnotation);
    if (editor != null) {
      new WriteCommandAction(project, file) {
        protected void run(@NotNull Result result) throws Throwable {
          final PsiNameValuePair valuePair = selectAnnotationAttribute();

          if (null != valuePair) {
            // delete this parameter
View Full Code Here

    public static void replaceElementWithText(final Document document, PsiElement element, final String text) {
        final int start = element.getTextOffset();
        final int end = start + element.getTextLength();

        WriteCommandAction writeCommandAction = new WriteCommandAction(element.getContainingFile().getProject()) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                document.replaceString(start, end, text);
            }
        };
        writeCommandAction.execute();
    }
View Full Code Here

    public static void reformatPositions(@NotNull final PsiFile file, final int start, final int end) {
        if (start >= end) {
            return;
        }

        WriteCommandAction writeCommandAction = new WriteCommandAction(file.getProject(), file) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                CodeStyleManager.getInstance(file.getProject()).reformatText(file, start, end);
            }
        };
        writeCommandAction.execute();
    }
View Full Code Here

    public static void runTemplate(Editor editor, TextRange textRange, List<String> stringList, TemplateImpl template) {
        final Document document = editor.getDocument();
        final RangeMarker range = document.createRangeMarker(textRange.getStartOffset(), textRange.getEndOffset());
        setTemplateVariableValues(template, stringList);
        WriteCommandAction writeCommandAction = new WriteCommandAction(editor.getProject()) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                document.deleteString(range.getStartOffset(), range.getEndOffset());
            }
        };
        writeCommandAction.execute();
        TemplateManager.getInstance(editor.getProject()).startTemplate(editor, "", template);
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.command.WriteCommandAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.