Java Code Examples for com.intellij.execution.ui.RunContentDescriptor#getComponent()

The following examples show how to use com.intellij.execution.ui.RunContentDescriptor#getComponent() . 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: XDebugSessionTab.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static XDebugSessionTab create(@Nonnull XDebugSessionImpl session,
                                      @Nullable Image icon,
                                      @Nullable ExecutionEnvironment environment,
                                      @Nullable RunContentDescriptor contentToReuse) {
  if (contentToReuse != null && SystemProperties.getBooleanProperty("xdebugger.reuse.session.tab", false)) {
    JComponent component = contentToReuse.getComponent();
    if (component != null) {
      XDebugSessionTab oldTab = DataManager.getInstance().getDataContext(component).getData(TAB_KEY);
      if (oldTab != null) {
        oldTab.setSession(session, environment, icon);
        oldTab.attachToSession(session);
        return oldTab;
      }
    }
  }
  XDebugSessionTab tab = new XDebugSessionTab(session, icon, environment);
  tab.myRunContentDescriptor.setActivateToolWindowWhenAdded(contentToReuse == null || contentToReuse.isActivateToolWindowWhenAdded());
  return tab;
}
 
Example 2
Source File: RerunFailedTestsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean getAction(@Nonnull AnActionEvent e, boolean execute) {
  Project project = e.getProject();
  if (project == null) {
    return false;
  }

  RunContentDescriptor contentDescriptor = ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
  if (contentDescriptor == null) {
    return false;
  }

  JComponent component = contentDescriptor.getComponent();
  if (component == null) {
    return false;
  }

  ExecutionEnvironment environment = DataManager.getInstance().getDataContext(component).getData(LangDataKeys.EXECUTION_ENVIRONMENT);
  if (environment == null) {
    return false;
  }

  AnAction[] actions = contentDescriptor.getRestartActions();
  if (actions.length == 0) {
    return false;
  }

  for (AnAction action : actions) {
    if (action instanceof AbstractRerunFailedTestsAction) {
      if (execute) {
        ((AbstractRerunFailedTestsAction)action).execute(e, environment);
      }
      return true;
    }
  }
  return false;
}
 
Example 3
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public XDebugSessionImpl(@Nullable ExecutionEnvironment environment,
                         @Nonnull XDebuggerManagerImpl debuggerManager,
                         @Nonnull String sessionName,
                         @Nullable Image icon,
                         boolean showTabOnSuspend,
                         @Nullable RunContentDescriptor contentToReuse) {
  myEnvironment = environment;
  mySessionName = sessionName;
  myDebuggerManager = debuggerManager;
  myShowTabOnSuspend = new AtomicBoolean(showTabOnSuspend);
  myProject = debuggerManager.getProject();
  ValueLookupManager.getInstance(myProject).startListening();
  myIcon = icon;

  XDebugSessionData oldSessionData = null;
  if (contentToReuse == null) {
    contentToReuse = environment != null ? environment.getContentToReuse() : null;
  }
  if (contentToReuse != null) {
    JComponent component = contentToReuse.getComponent();
    if (component != null) {
      oldSessionData = DataManager.getInstance().getDataContext(component).getData(XDebugSessionData.DATA_KEY);
    }
  }

  String currentConfigurationName = getConfigurationName();
  if (oldSessionData == null || !oldSessionData.getConfigurationName().equals(currentConfigurationName)) {
    oldSessionData = new XDebugSessionData(getWatchExpressions(), currentConfigurationName);
  }
  mySessionData = oldSessionData;
}
 
Example 4
Source File: FakeRerunAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected ExecutionEnvironment getEnvironment(@Nonnull AnActionEvent event) {
  ExecutionEnvironment environment = event.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
  if (environment == null) {
    Project project = event.getProject();
    RunContentDescriptor contentDescriptor = project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
    if (contentDescriptor != null) {
      JComponent component = contentDescriptor.getComponent();
      if (component != null) {
        environment = DataManager.getInstance().getDataContext(component).getData(LangDataKeys.EXECUTION_ENVIRONMENT);
      }
    }
  }
  return environment;
}