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


Java CommandProcessor类代码示例

本文整理汇总了Java中com.intellij.openapi.command.CommandProcessor的典型用法代码示例。如果您正苦于以下问题:Java CommandProcessor类的具体用法?Java CommandProcessor怎么用?Java CommandProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: insertToEditor

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public void insertToEditor(Project project, SearchResultElement element) {
    CommandProcessor.getInstance().executeCommand(project, () -> getApplication().runWriteAction(() -> {
        Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
        if (editor != null) {
            int offset = editor.getCaretModel().getOffset();
            Document document = editor.getDocument();
            String key = isXmlFile ?
                    "@" + element.getTag() + "/" + element.getName()
                    : "R." + element.getTag() + "." + element.getName();
            if (key != null) {
                document.insertString(offset, key);
                editor.getCaretModel().moveToOffset(offset + key.length());
            }
        }
    }), "InsertResultToEditor", "", UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
}
 
开发者ID:hoai265,项目名称:SearchResourcePlugin,代码行数:17,代码来源:SearchResourcesAction.java

示例2: onTaskFailed

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
@Override
public void onTaskFailed(@NotNull String message) {
  super.onTaskFailed(message);
  ApplicationManager.getApplication().invokeLater(() -> {
    VirtualFile taskDir = myTask.getTaskDir(myProject);
    if (taskDir == null) return;
    for (Map.Entry<String, TaskFile> entry : myTask.getTaskFiles().entrySet()) {
      final String name = entry.getKey();
      final TaskFile taskFile = entry.getValue();
      if (taskFile.getActivePlaceholders().size() < 2) {
        continue;
      }
      final Course course = myTask.getLesson().getCourse();
      if (course != null && EduNames.STUDY.equals(course.getCourseMode())) {
        CommandProcessor.getInstance().runUndoTransparentAction(
          () -> ApplicationManager.getApplication().runWriteAction(
            () -> PyStudySmartChecker.runSmartTestProcess(taskDir, new PyStudyTestRunner(myTask, taskDir), name, taskFile, myProject)));
      }
    }
    StudyCheckUtils.navigateToFailedPlaceholder(new StudyState(StudyUtils.getSelectedStudyEditor(myProject)), myTask, taskDir, myProject);
  });
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:PyStudyTaskChecker.java

示例3: actionPerformed

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
    final PsiFile psiFile = e.getRequiredData(CommonDataKeys.PSI_FILE);
    
    CommandProcessor.getInstance().executeCommand(project, () -> {
        try {
            MultiHighlightHandler.invoke(project, editor, psiFile);
        } catch (IndexNotReadyException ex) {
            DumbService.getInstance(project)
                    .showDumbModeNotification("MultiHighlight requires indices "
                            + "and cannot be performed until they are built");
        }
    }, "MultiHighlight", null);
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:17,代码来源:MultiHighlightAction.java

示例4: invoke

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
  CommandProcessor.getInstance().executeCommand(myField.getProject(), new Runnable() {
    public void run() {
      try {
        final PsiManager manager = myField.getManager();
        myField.getTypeElement().replace(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeElement(myTypeToSet));
      }
      catch (final IncorrectOperationException e) {
        ApplicationManager.getApplication().invokeLater(new Runnable(){
          public void run() {
            Messages.showErrorDialog(myField.getProject(),
                                     QuickFixBundle.message("cannot.change.field.exception", myField.getName(), e.getLocalizedMessage()),
                                     CommonBundle.getErrorTitle());
          }
        });
      }
    }
  }, getText(), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ChangeBoundFieldTypeFix.java

示例5: startTemplateWithPrefix

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public void startTemplateWithPrefix(final Editor editor,
                                    final TemplateImpl template,
                                    final int templateStart,
                                    @Nullable final PairProcessor<String, String> processor,
                                    @Nullable final String argument) {
  final int caretOffset = editor.getCaretModel().getOffset();
  final TemplateState templateState = initTemplateState(editor);
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      editor.getDocument().deleteString(templateStart, caretOffset);
      editor.getCaretModel().moveToOffset(templateStart);
      editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
      editor.getSelectionModel().removeSelection();
      Map<String, String> predefinedVarValues = null;
      if (argument != null) {
        predefinedVarValues = new HashMap<String, String>();
        predefinedVarValues.put(TemplateImpl.ARG, argument);
      }
      templateState.start(template, processor, predefinedVarValues);
    }
  }, CodeInsightBundle.message("insert.code.template.command"), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TemplateManagerImpl.java

示例6: updateTemplateTextByVarNameChange

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
private void updateTemplateTextByVarNameChange(final Variable oldVar, final Variable newVar) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().executeCommand(null, new Runnable() {
        @Override
        public void run() {
          Document document = myEditor.getDocument();
          String templateText = document.getText();
          templateText = templateText.replaceAll("\\$" + oldVar.getName() + "\\$", "\\$" + newVar.getName() + "\\$");
          document.replaceString(0, document.getTextLength(), templateText);
        }
      }, null, null);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditVariableDialog.java

示例7: replaceString

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public static void replaceString(Project project, Document document, String newString, int offset,int length) {
    ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(document, null) {
        @Override
        public void run() {
            CommandProcessor.getInstance().executeCommand(project, new Runnable() {
                @Override
                public void run() {
                    try {
                        document.replaceString(offset, offset + length, newString);
                    } catch (Exception ignored) {
                    }
                }
            }, "", document);
        }
    });
}
 
开发者ID:zhengjunbase,项目名称:codehelper.generator,代码行数:17,代码来源:DocumentUtil.java

示例8: executeWriteAction

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
@Override
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
  CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
  CopyPasteManager.getInstance().stopKillRings();

  boolean camelMode = editor.getSettings().isCamelWords();
  if (myNegateCamelMode) {
    camelMode = !camelMode;
  }

  if (editor.getSelectionModel().hasSelection()) {
    EditorModificationUtil.deleteSelectedText(editor);
    return;
  }

  deleteToWordEnd(editor, camelMode);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DeleteToWordEndAction.java

示例9: apply

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
@Override
public void apply() throws ConfigurationException {
  CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
    @Override
    public void run() {
      try {
        ActionRunner.runInsideWriteAction(new ActionRunner.InterruptibleRunnable() {
          @Override
          public void run() throws Exception {
            myPanel.apply();
          }
        });
      }
      catch (Exception e) {
        LOG.error("Error while applying changes", e);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GenericEditor.java

示例10: canClose

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
@Override
public boolean canClose(final String inputString) {
  final String oldName = myModule.getName();
  final ModifiableModuleModel modifiableModel = renameModule(inputString);
  if (modifiableModel == null) return false;
  CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
        @Override
        public void run() {
          ApplicationManager.getApplication().runWriteAction(new Runnable() {
            @Override
            public void run() {
              modifiableModel.commit();
            }
          });
        }
      });
    }
  }, IdeBundle.message("command.renaming.module", oldName), null);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RenameModuleHandler.java

示例11: createNewFile

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public Exception createNewFile(final VirtualFile parentDirectory, final String newFileName, final FileType fileType, final String initialContent) {
  final Exception[] failReason = new Exception[] { null };
  CommandProcessor.getInstance().executeCommand(
      myProject, new Runnable() {
        public void run() {
          ApplicationManager.getApplication().runWriteAction(new Runnable() {
            public void run() {
              try {
                final String newFileNameWithExtension = newFileName.endsWith('.'+fileType.getDefaultExtension())? newFileName : newFileName+'.'+fileType.getDefaultExtension();
                final VirtualFile file = parentDirectory.createChildData(this, newFileNameWithExtension);
                VfsUtil.saveText(file, initialContent != null ? initialContent : "");
                updateTree();
                select(file, null);
              }
              catch (IOException e) {
                failReason[0] = e;
              }
            }
          });
        }
      },
      UIBundle.message("file.chooser.create.new.file.command.name"),
      null
  );
  return failReason[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FileSystemTreeImpl.java

示例12: addImport

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
private void addImport(final PsiReference ref, final PsiClass targetClass) {
  StatisticsManager.getInstance().incUseCount(JavaStatisticsManager.createInfo(null, targetClass));
  CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          DumbService.getInstance(myProject).withAlternativeResolveEnabled(new Runnable() {
            @Override
            public void run() {
              _addImport(ref, targetClass);
            }
          });
        }
      });
    }
  }, QuickFixBundle.message("add.import"), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AddImportAction.java

示例13: setText

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public void setText(final String text) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          myDocument.replaceString(0, myDocument.getTextLength(), text);
          if (myEditorField != null && myEditorField.getEditor() != null) {
            myEditorField.getCaretModel().moveToOffset(myDocument.getTextLength());
          }
        }
      }, null, myDocument);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorComboBox.java

示例14: startTemplate

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
public static void startTemplate(@NotNull final Editor editor,
                                    final Template template,
                                    @NotNull final Project project,
                                    final TemplateEditingListener listener,
                                    final String commandName) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      if (project.isDisposed() || editor.isDisposed()) return;
      CommandProcessor.getInstance().executeCommand(project, new Runnable() {
        @Override
        public void run() {
          TemplateManager.getInstance(project).startTemplate(editor, template, listener);
        }
      }, commandName, commandName);
    }
  };
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    runnable.run();
  }
  else {
    ApplicationManager.getApplication().invokeLater(runnable);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CreateFromUsageBaseFix.java

示例15: doImport

import com.intellij.openapi.command.CommandProcessor; //导入依赖的package包/类
private void doImport(final PsiMethod toImport) {
  CommandProcessor.getInstance().executeCommand(toImport.getProject(), new Runnable(){
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          try {
            PsiMethodCallExpression element = myMethodCall.getElement();
            if (element != null) {
              AddSingleMemberStaticImportAction.bindAllClassRefs(element.getContainingFile(), toImport, toImport.getName(), toImport.getContainingClass());
            }
          }
          catch (IncorrectOperationException e) {
            LOG.error(e);
          }
        }
      });

    }
  }, getText(), this);

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:StaticImportMethodFix.java


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