Java Code Examples for com.intellij.openapi.actionSystem.impl.SimpleDataContext#getProjectContext()

The following examples show how to use com.intellij.openapi.actionSystem.impl.SimpleDataContext#getProjectContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BranchActionGroupPopup.java    From consulo with Apache License 2.0 6 votes vote down vote up
public BranchActionGroupPopup(@Nonnull String title, @Nonnull Project project, @Nonnull Condition<AnAction> preselectActionCondition, @Nonnull ActionGroup actions, @Nullable String dimensionKey) {
  super(title, createBranchSpeedSearchActionGroup(actions), SimpleDataContext.getProjectContext(project), preselectActionCondition, true);
  myProject = project;
  DataManager.registerDataProvider(getList(), dataId -> POPUP_MODEL == dataId ? getListModel() : null);
  myKey = dimensionKey;
  if (myKey != null) {
    Dimension storedSize = WindowStateService.getInstance(myProject).getSizeFor(myProject, myKey);
    if (storedSize != null) {
      //set forced size before component is shown
      setSize(storedSize);
      myUserSizeChanged = true;
    }
    createTitlePanelToolbar(myKey);
  }
  myMeanRowHeight = getList().getCellBounds(0, 0).height + UIUtil.getListCellVPadding() * 2;
}
 
Example 2
Source File: ExecutionManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void compileAndRun(@Nonnull UIAccess uiAccess, @Nonnull Runnable startRunnable, @Nonnull ExecutionEnvironment environment, @Nullable Runnable onCancelRunnable) {
  long id = environment.getExecutionId();
  if (id == 0) {
    id = environment.assignNewExecutionId();
  }

  RunProfile profile = environment.getRunProfile();
  if (!(profile instanceof RunConfiguration)) {
    startRunnable.run();
    return;
  }

  final RunConfiguration runConfiguration = (RunConfiguration)profile;
  final List<BeforeRunTask> beforeRunTasks = RunManagerEx.getInstanceEx(myProject).getBeforeRunTasks(runConfiguration);
  if (beforeRunTasks.isEmpty()) {
    startRunnable.run();
  }
  else {
    DataContext context = environment.getDataContext();
    final DataContext projectContext = context != null ? context : SimpleDataContext.getProjectContext(myProject);

    AsyncResult<Void> result = AsyncResult.undefined();

    runBeforeTask(beforeRunTasks, 0, id, environment, uiAccess, projectContext, runConfiguration, result);

    if (onCancelRunnable != null) {
      result.doWhenRejected(() -> uiAccess.give(onCancelRunnable));
    }

    result.doWhenDone(() -> {
      // important! Do not use DumbService.smartInvokeLater here because it depends on modality state
      // and execution of startRunnable could be skipped if modality state check fails
      uiAccess.give(() -> {
        if (!myProject.isDisposed()) {
          DumbService.getInstance(myProject).runWhenSmart(startRunnable);
        }
      });
    });
  }
}
 
Example 3
Source File: StatusActionGroupPopup.java    From GitToolBox with Apache License 2.0 4 votes vote down vote up
public StatusActionGroupPopup(String title, @NotNull RootActions actionGroup, @NotNull Project project,
                              Condition<AnAction> preselectActionCondition) {
  super(title, actionGroup, SimpleDataContext.getProjectContext(project),
      false, false, true, false,
      null, -1, preselectActionCondition, null);
}
 
Example 4
Source File: SymfonyProfilerWidget.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@Nullable
@Override
public ListPopup getPopupStep() {
    ActionGroup popupGroup = getActions();
    return new PopupFactoryImpl.ActionGroupPopup("Symfony Profiler", popupGroup, SimpleDataContext.getProjectContext(getProject()), false, false, false, true, null, -1, null, null);
}