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


Java CommandProcessor.executeCommand方法代码示例

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


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

示例1: getClickConsumer

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    public void consume(MouseEvent mouseEvent) {
      final Project project = getProject();
      if (project == null) return;
      final Editor editor = getEditor();
      if (editor == null) return;
      final CommandProcessor processor = CommandProcessor.getInstance();
      processor.executeCommand(
        project, new Runnable() {
          public void run() {
            final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor);
            dialog.show();
            IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
          }
        },
        UIBundle.message("go.to.line.command.name"),
        null
      );
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PositionPanel.java

示例2: actionPerformed

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
    project, new Runnable(){
      public void run() {
        final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
        if (window != null){
          final VirtualFile[] files = window.getFiles();
          for (final VirtualFile file : files) {
            window.closeFile(file);
          }
          return;
        }
        FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
        VirtualFile selectedFile = fileEditorManager.getSelectedFiles()[0];
        VirtualFile[] openFiles = fileEditorManager.getSiblings(selectedFile);
        for (final VirtualFile openFile : openFiles) {
          fileEditorManager.closeFile(openFile);
        }
      }
    }, IdeBundle.message("command.close.all.editors"), null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CloseAllEditorsAction.java

示例3: openMessagesView

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    public void run() {
      final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
      messageView.runWhenInitialized(new Runnable() {
        public void run() {
          final Content content =
            ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true);
          messageView.getContentManager().addContent(content);
          Disposer.register(content, errorTreeView);
          messageView.getContentManager().setSelectedContent(content);
          removeContents(content, tabDisplayName);

          ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null);
        }
      });
    }
  }, VcsBundle.message("command.name.open.error.message.view"), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AbstractVcsHelperImpl.java

示例4: 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

示例5: openMessagesView

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private static void openMessagesView(@NotNull final ErrorViewPanel errorTreeView,
                                     @NotNull final Project myProject,
                                     @NotNull final String tabDisplayName) {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
      final Content content = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true);
      messageView.getContentManager().addContent(content);
      Disposer.register(content, errorTreeView);
      messageView.getContentManager().setSelectedContent(content);
      removeContents(content, myProject, tabDisplayName);
    }
  }, "Open message view", null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExecutionHelper.java

示例6: actionPerformed

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
  if (editor == null || project == null) return;
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
      project, new Runnable() {
      @Override
      public void run() {
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
        FindManager findManager = FindManager.getInstance(project);
        if(!findManager.selectNextOccurrenceWasPerformed() && findManager.findNextUsageInEditor(editor)) {
          return;
        }

        FindUtil.searchAgain(project, editor, e.getDataContext());
      }
    },
    IdeBundle.message("command.find.next"),
    null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SearchAgainAction.java

示例7: actionPerformed

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
      project, new Runnable() {
      @Override
      public void run() {
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        FindManager findManager = FindManager.getInstance(project);
        if(!findManager.selectNextOccurrenceWasPerformed() && findManager.findPreviousUsageInEditor(editor)) {
          return;
        }
        FindUtil.searchBack(project, editor, e.getDataContext());
      }
    },
    IdeBundle.message("command.find.previous"),
    null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SearchBackAction.java

示例8: navigateSelectedElement

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public boolean navigateSelectedElement() {
  final Ref<Boolean> succeeded = new Ref<Boolean>();
  final CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      succeeded.set(MyCommanderPanel.super.navigateSelectedElement());
      IdeDocumentHistory.getInstance(myProject).includeCurrentCommandAsNavigation();
    }
  }, "Navigate", null);
  if (succeeded.get()) {
    close(CANCEL_EXIT_CODE);
  }
  return succeeded.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FileStructureDialog.java

示例9: openMessageView

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private void openMessageView() {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
      myProject, new Runnable() {
        @Override
        public void run() {
          MessageView messageView = MessageView.SERVICE.getInstance(myProject);
          final Content content = ContentFactory.SERVICE.getInstance().createContent(myErrorsView.getComponent(), CONTENT_NAME, true);
          content.putUserData(KEY, myErrorsView);
          messageView.getContentManager().addContent(content);
          messageView.getContentManager().setSelectedContent(content);
          messageView.getContentManager().addContentManagerListener(new CloseListener(content, messageView.getContentManager()));
          removeCompileContents(content);
          messageView.getContentManager().addContentManagerListener(new MyContentDisposer(content, messageView));
        }
      },
      XmlBundle.message("validate.xml.open.message.view.command.name"),
      null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:StdErrorReporter.java

示例10: openMessageViewImpl

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private void openMessageViewImpl() {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      MessageView messageView = MessageView.SERVICE.getInstance(myProject);
      Content content = ContentFactory.SERVICE.getInstance().createContent(myErrorsView.getComponent(), myContentName, true);
      content.putUserData(myKey, myErrorsView);
      messageView.getContentManager().addContent(content);
      messageView.getContentManager().setSelectedContent(content);
      messageView.getContentManager().addContentManagerListener(new CloseListener(content, myContentName, myErrorsView));
      removeOldContents(content);
      messageView.getContentManager().addContentManagerListener(new MyContentDisposer(content, messageView, myKey));
    }
  }, "Open Message View", null);

  ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MessageViewHelper.java

示例11: setPreviewText

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void setPreviewText(@Nonnull String text) {
    final CommandProcessor processor = CommandProcessor.getInstance();
    processor.executeCommand(null, () -> {
        final Application application = ApplicationManager.getApplication();
        application.runWriteAction(() -> {
            previewDocument.replaceString(INITIAL_OFFSET, previewDocument.getTextLength(), text);

            final int textLength = previewDocument.getTextLength();
            final CaretModel caret = previewEditor.getCaretModel();
            if (caret.getOffset() >= textLength) {
                caret.moveToOffset(textLength);
            }
        });
    }, null, null);
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:16,代码来源:SettingsPanel.java

示例12: setJson

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void setJson(@NotNull String json) {
    final CommandProcessor processor = CommandProcessor.getInstance();
    processor.executeCommand(project, () -> {
        final Application application = ApplicationManager.getApplication();
        application.runWriteAction(() -> {
            jsonDocument.replaceString(INITIAL_OFFSET, jsonDocument.getTextLength(), json);

            final int textLength = jsonDocument.getTextLength();
            final CaretModel caret = jsonEditor.getCaretModel();
            if (caret.getOffset() >= textLength) {
                caret.moveToOffset(textLength);
            }
        });
    }, null, null);
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:16,代码来源:NewClassDialog.java

示例13: actionPerformed

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
    project, new Runnable(){
      public void run() {
        final ArrayList<Pair<EditorComposite, EditorWindow>> filesToClose = getFilesToClose (e);
        for (int i = 0; i != filesToClose.size (); ++ i) {
          final Pair<EditorComposite, EditorWindow> we = filesToClose.get(i);
          we.getSecond ().closeFile (we.getFirst ().getFile ());
        }
      }
    }, IdeBundle.message("command.close.all.unmodified.editors"), null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:CloseEditorsActionBase.java

示例14: execute

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void execute(final Editor editor, DataContext dataContext) {
  CommandProcessor processor = CommandProcessor.getInstance();
  processor.executeCommand(CommonDataKeys.PROJECT.getData(dataContext), new Runnable() {
    public void run() {
      editor.getSelectionModel().setSelection(0, editor.getDocument().getTextLength());
    }
  }, IdeBundle.message("command.select.all"), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SelectAllAction.java

示例15: actionPerformed

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
  final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
  final CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
    project, new Runnable(){
      public void run() {
        final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
        manager.setCurrentWindow(manager.getPrevWindow(manager.getCurrentWindow()));
      }
    }, IdeBundle.message("command.go.to.prev.split"), null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PrevSplitAction.java


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