Package com.intellij.openapi.actionSystem

Examples of com.intellij.openapi.actionSystem.DataContext


    execute(project, executor, configuration, created);
  }

  private static DataContext createDataContext(@NotNull Editor editor, @NotNull final PsiElement element) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
    return new DataContext() {
      @Nullable
      @Override
      public Object getData(@NonNls String dataId) {
        if (Location.DATA_KEY.is(dataId)) {
          return new PsiLocation<PsiElement>(element.getProject(), element);
        }
        return dataContext.getData(dataId);
      }
    };
  }
View Full Code Here


    myHandler = handler;
  }

  @Override
  public void actionPerformed(@NotNull AnActionEvent event) {
    final DataContext dataContext = event.getDataContext();
    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project != null) {
      final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
      if (null != editor) {
        final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
View Full Code Here

  }

  @Override
  public void update(@NotNull AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final DataContext dataContext = event.getDataContext();

    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
      presentation.setEnabled(false);
      return;
View Full Code Here

    }

    public static void pressEnter(Editor editor) {
        EditorActionManager manager = EditorActionManager.getInstance();
        EditorActionHandler enterHandler = manager.getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE);
        DataContext dc = DataManager.getInstance().getDataContext(editor.getContentComponent());
        enterHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), dc);
    }
View Full Code Here

  }

  protected void performActionTest() {
    AnAction anAction = getAction();

    DataContext context = DataManager.getInstance().getDataContext();
    AnActionEvent anActionEvent = new AnActionEvent(null, context, "", anAction.getTemplatePresentation(), ActionManager.getInstance(), 0);

    anAction.actionPerformed(anActionEvent);
    FileDocumentManager.getInstance().saveAllDocuments();
  }
View Full Code Here

  private static boolean doSubmit(final IdeaLoggingEvent event,
                                  final Component parentComponent,
                                  final Consumer<SubmittedReportInfo> callback,
                                  final ErrorBean bean,
                                  final String description) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);

    bean.setDescription(description);
    bean.setMessage(event.getMessage());

    Throwable throwable = event.getThrowable();
View Full Code Here

        final Project project = e.getData(PlatformDataKeys.PROJECT);
        if (project == null) return;

        PsiDocumentManager.getInstance(project).commitAllDocuments();

        final DataContext dataContext = e.getDataContext();

        final FindManager findManager = FindManager.getInstance(project);
        final FindModel findModel = (FindModel) findManager.getFindInFileModel().clone();

View Full Code Here

    private Project getCurrentProject() throws IntelliJCoderException {
        //if project was closed
        if(!project.isInitialized()) {
            // we try to locate project by currently focused component
            @SuppressWarnings({"deprecation"})
            DataContext dataContext = DataManager.getInstance().getDataContext();
            project = DataKeys.PROJECT.getData(dataContext);
        }
        if(project == null) {
            throw new IntelliJCoderException("There is no opened project.");
View Full Code Here

    actionHandler.execute(getEditor(), DataManager.getInstance().getDataContext());
  }

  protected DataContext getCurrentEditorDataContext() {
    final DataContext defaultContext = DataManager.getInstance().getDataContext();
    DataContext dataContext = new DataContext() {
      @Nullable
      public Object getData(@NonNls String dataId) {
        if (dataId.equals(DataConstants.EDITOR)) return getEditor();
        if (dataId.equals(DataConstants.PROJECT)) return getProject();
        if (dataId.equals(DataConstants.PSI_FILE)) return getFile();
View Full Code Here

    super(text, description, icon);
  }

  public void update(AnActionEvent e) {
    super.update(e);
    DataContext dataContext = e.getDataContext();
    Project project = DataKeys.PROJECT.getData(dataContext);
    Presentation presentation = e.getPresentation();
    if (presentation.isEnabled()) {
      IdeView view = DataKeys.IDE_VIEW.getData(dataContext);
      assert view != null;
View Full Code Here

TOP

Related Classes of com.intellij.openapi.actionSystem.DataContext

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.