com.intellij.execution.ui.RunContentDescriptor Java Examples

The following examples show how to use com.intellij.execution.ui.RunContentDescriptor. 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: FlutterApp.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
public static FlutterApp firstFromProjectProcess(@NotNull Project project) {
  final List<RunContentDescriptor> runningProcesses =
    ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  for (RunContentDescriptor descriptor : runningProcesses) {
    final ProcessHandler process = descriptor.getProcessHandler();
    if (process != null) {
      final FlutterApp app = FlutterApp.fromProcess(process);
      if (app != null) {
        return app;
      }
    }
  }

  return null;
}
 
Example #2
Source File: XDebuggerManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public XDebugSession startSessionAndShowTab(@Nonnull String sessionName,
                                            Image icon,
                                            @Nullable RunContentDescriptor contentToReuse,
                                            boolean showToolWindowOnSuspendOnly,
                                            @Nonnull XDebugProcessStarter starter) throws ExecutionException {
  XDebugSessionImpl session = startSession(contentToReuse, starter, new XDebugSessionImpl(null, this, sessionName, icon, showToolWindowOnSuspendOnly, contentToReuse));

  if (!showToolWindowOnSuspendOnly) {
    session.showSessionTab();
  }
  ProcessHandler handler = session.getDebugProcess().getProcessHandler();
  handler.startNotify();
  return session;
}
 
Example #3
Source File: XDebugSessionTab.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void setSession(@Nonnull XDebugSessionImpl session, @Nullable ExecutionEnvironment environment, @Nullable Image icon) {
  myEnvironment = environment;
  mySession = session;
  mySessionData = session.getSessionData();
  myConsole = session.getConsoleView();

  AnAction[] restartActions;
  List<AnAction> restartActionsList = session.getRestartActions();
  if (ContainerUtil.isEmpty(restartActionsList)) {
    restartActions = AnAction.EMPTY_ARRAY;
  }
  else {
    restartActions = restartActionsList.toArray(new AnAction[restartActionsList.size()]);
  }

  myRunContentDescriptor =
          new RunContentDescriptor(myConsole, session.getDebugProcess().getProcessHandler(), myUi.getComponent(), session.getSessionName(), icon,
                                   myRebuildWatchesRunnable, restartActions);
  Disposer.register(myRunContentDescriptor, this);
  Disposer.register(myProject, myRunContentDescriptor);
}
 
Example #4
Source File: Unity3dTestDebuggerRunner.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
@Override
@RequiredUIAccess
protected RunContentDescriptor doExecute(@Nonnull RunProfileState state, @Nonnull ExecutionEnvironment env) throws ExecutionException
{
	UnityProcess editorProcess = UnityEditorCommunication.findEditorProcess();
	if(editorProcess == null)
	{
		throw new ExecutionException("Editor is not responding");
	}
	FileDocumentManager.getInstance().saveAllDocuments();

	ExecutionResult executionResult = state.execute(env.getExecutor(), this);
	if(executionResult == null)
	{
		return null;
	}
	return Unity3dAttachRunner.runContentDescriptor(executionResult, env, editorProcess, (ConsoleView) executionResult.getExecutionConsole(), true);
}
 
Example #5
Source File: EOFAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(e.getDataContext());
  ProcessHandler activeProcessHandler = descriptor != null ? descriptor.getProcessHandler() : null;
  if (activeProcessHandler == null || activeProcessHandler.isProcessTerminated()) return;

  try {
    OutputStream input = activeProcessHandler.getProcessInput();
    if (input != null) {
      ConsoleView console = e.getData(LangDataKeys.CONSOLE_VIEW);
      if (console != null) {
        console.print("^D\n", ConsoleViewContentType.SYSTEM_OUTPUT);
      }
      input.close();
    }
  }
  catch (IOException ignored) {
  }
}
 
Example #6
Source File: AbstractConsoleRunnerWithHistory.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void createContentDescriptorAndActions() {
  final Executor defaultExecutor = getExecutor();
  final DefaultActionGroup toolbarActions = new DefaultActionGroup();
  final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);

  // Runner creating
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
  panel.add(myConsoleView.getComponent(), BorderLayout.CENTER);

  actionToolbar.setTargetComponent(panel);

  final RunContentDescriptor contentDescriptor =
          new RunContentDescriptor(myConsoleView, myProcessHandler, panel, constructConsoleTitle(myConsoleTitle), getConsoleIcon());

  contentDescriptor.setFocusComputable(() -> getConsoleView().getConsoleEditor().getContentComponent());
  contentDescriptor.setAutoFocusContent(isAutoFocusContent());


  // tool bar actions
  final List<AnAction> actions = fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor);
  registerActionShortcuts(actions, getConsoleView().getConsoleEditor().getComponent());
  registerActionShortcuts(actions, panel);

  showConsole(defaultExecutor, contentDescriptor);
}
 
Example #7
Source File: CppBaseDebugRunner.java    From CppTools with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(Project project, RunProfileState runProfileState, RunContentDescriptor runContentDescriptor, ExecutionEnvironment env) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();

  final RunProfile runProfile = env.getRunProfile();

  final XDebugSession debugSession =
      XDebuggerManager.getInstance(project).startSession(this, env, runContentDescriptor, new XDebugProcessStarter() {
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
          return new CppDebugProcess(session, CppBaseDebugRunner.this, (BaseCppConfiguration)runProfile);
        }
      });

  return debugSession.getRunContentDescriptor();
}
 
Example #8
Source File: ExecutionManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public ProcessHandler[] getRunningProcesses() {
  if (myContentManager == null) return EMPTY_PROCESS_HANDLERS;
  List<ProcessHandler> handlers = null;
  for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
    ProcessHandler processHandler = descriptor.getProcessHandler();
    if (processHandler != null) {
      if (handlers == null) {
        handlers = new SmartList<>();
      }
      handlers.add(processHandler);
    }
  }
  return handlers == null ? EMPTY_PROCESS_HANDLERS : handlers.toArray(new ProcessHandler[handlers.size()]);
}
 
Example #9
Source File: RoboVmRunner.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    if(DEBUG_EXECUTOR.equals(environment.getExecutor().getId())) {
        RoboVmRunConfiguration runConfig = (RoboVmRunConfiguration)environment.getRunProfile();
        RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", "" + runConfig.getDebugPort(), false);
        connection.setServerMode(true);
        return attachVirtualMachine(state, environment, connection, false);
    } else {
        ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
        if (executionResult == null) {
            return null;
        }
        return new RunContentBuilder(executionResult, environment).showRunContent(environment.getContentToReuse());
    }
}
 
Example #10
Source File: FlutterApp.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
public static List<FlutterApp> allFromProjectProcess(@NotNull Project project) {
  final List<FlutterApp> allRunningApps = new ArrayList<>();
  final List<RunContentDescriptor> runningProcesses =
    ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  for (RunContentDescriptor descriptor : runningProcesses) {
    final ProcessHandler process = descriptor.getProcessHandler();
    if (process != null) {
      final FlutterApp app = FlutterApp.fromProcess(process);
      if (app != null) {
        allRunningApps.add(app);
      }
    }
  }

  return allRunningApps;
}
 
Example #11
Source File: ExecutorRegistryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Icon getInformativeIcon(Project project, final RunnerAndConfigurationSettings selectedConfiguration) {
  final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);

  List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == selectedConfiguration);
  runningDescriptors = ContainerUtil.filter(runningDescriptors, descriptor -> {
    RunContentDescriptor contentDescriptor = executionManager.getContentManager().findContentDescriptor(myExecutor, descriptor.getProcessHandler());
    return contentDescriptor != null && executionManager.getExecutors(contentDescriptor).contains(myExecutor);
  });

  if (!runningDescriptors.isEmpty() && DefaultRunExecutor.EXECUTOR_ID.equals(myExecutor.getId()) && selectedConfiguration.isSingleton()) {
    return AllIcons.Actions.Restart;
  }
  if (runningDescriptors.isEmpty()) {
    return TargetAWT.to(myExecutor.getIcon());
  }

  if (runningDescriptors.size() == 1) {
    return TargetAWT.to(ExecutionUtil.getIconWithLiveIndicator(myExecutor.getIcon()));
  }
  else {
    // FIXME [VISTALL] not supported by UI framework
    return IconUtil.addText(TargetAWT.to(myExecutor.getIcon()), String.valueOf(runningDescriptors.size()));
  }
}
 
Example #12
Source File: FlutterAppManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Return the active (front most in the UI) Flutter app.
 * <p>
 * This could return null even if there is a running Flutter app, if the front-most
 * running process (focused in the Run or Debug view) is not a Flutter app instance.
 */
@Nullable
public FlutterApp getActiveApp() {
  RunContentManager mgr = getRunContentManager();
  if (mgr == null) {
    return null;
  }
  final RunContentDescriptor descriptor = mgr.getSelectedContent();
  if (descriptor == null) {
    return null;
  }

  final ProcessHandler process = descriptor.getProcessHandler();
  if (process == null) {
    return null;
  }

  final FlutterApp app = FlutterApp.fromProcess(process);
  return app != null && app.isConnected() ? app : null;
}
 
Example #13
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
XDebugSessionTab init(@Nonnull XDebugProcess process, @Nullable RunContentDescriptor contentToReuse) {
  LOG.assertTrue(myDebugProcess == null);
  myDebugProcess = process;

  if (myDebugProcess.checkCanInitBreakpoints()) {
    initBreakpoints();
  }

  myDebugProcess.getProcessHandler().addProcessListener(new ProcessAdapter() {
    @Override
    public void processTerminated(final ProcessEvent event) {
      stopImpl();
      myDebugProcess.getProcessHandler().removeProcessListener(this);
    }
  });
  //todo[nik] make 'createConsole()' method return ConsoleView
  myConsoleView = (ConsoleView)myDebugProcess.createConsole();
  if (!myShowTabOnSuspend.get()) {
    initSessionTab(contentToReuse);
  }

  return mySessionTab;
}
 
Example #14
Source File: WeaveDebuggerRunner.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(final RunProfileState state, final @NotNull ExecutionEnvironment env)
        throws ExecutionException
{

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter()
    {
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException
        {
            WeaveRunnerCommandLine weaveRunnerCommandLine = (WeaveRunnerCommandLine) state;
            final String weaveFile = weaveRunnerCommandLine.getModel().getWeaveFile();
            final Project project = weaveRunnerCommandLine.getEnvironment().getProject();
            final VirtualFile projectFile = project.getBaseDir();
            final String path = project.getBasePath();
            final String relativePath = weaveFile.substring(path.length());
            final VirtualFile fileByRelativePath = projectFile.findFileByRelativePath(relativePath);
            final DebuggerClient localhost = new DebuggerClient(new WeaveDebuggerClientListener(session, fileByRelativePath), new TcpClientDebuggerProtocol("localhost", 6565));
            final ExecutionResult result = state.execute(env.getExecutor(), WeaveDebuggerRunner.this);
            new DebuggerConnector(localhost).start();
            return new WeaveDebugProcess(session, localhost, result);
        }
    }).getRunContentDescriptor();

}
 
Example #15
Source File: RunDashboardContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Returns node's status. Subclasses may override this method to provide custom statuses.
 * @param node dashboard node
 * @return node's status. Returned status is used for grouping nodes by status.
 */
public DashboardRunConfigurationStatus getStatus(DashboardRunConfigurationNode node) {
  RunContentDescriptor descriptor = node.getDescriptor();
  if (descriptor == null) {
    return DashboardRunConfigurationStatus.STOPPED;
  }
  ProcessHandler processHandler = descriptor.getProcessHandler();
  if (processHandler == null) {
    return DashboardRunConfigurationStatus.STOPPED;
  }
  Integer exitCode = processHandler.getExitCode();
  if (exitCode == null) {
    return DashboardRunConfigurationStatus.STARTED;
  }
  Boolean terminationRequested = processHandler.getUserData(ProcessHandler.TERMINATION_REQUESTED);
  if (exitCode == 0 || (terminationRequested != null && terminationRequested)) {
    return DashboardRunConfigurationStatus.STOPPED;
  }
  return DashboardRunConfigurationStatus.FAILED;
}
 
Example #16
Source File: JavaStatusChecker.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Stops the applications via the descriptor of configuration.  This gets called when the application finishes on the client side without maniually closing it.
 *
 * @param javaExitCode
 */
public void stopApplication(@NotNull int javaExitCode) {
    final RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(project);
    final Collection<RunnerAndConfigurationSettings> allConfigurations = runManager.getSortedConfigurations();
    List<RunContentDescriptor> allDescriptors = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
    boolean exitMsgDisplay = false;
    for (RunnerAndConfigurationSettings runConfiguration : allConfigurations) {
        if (runConfiguration.getConfiguration().getFactory().getType() instanceof EmbeddedLinuxJVMConfigurationType) {
            for (RunContentDescriptor descriptor : allDescriptors) {
                if (runConfiguration.getName().equals(descriptor.getDisplayName())) {
                    try {
                        if (!exitMsgDisplay) {
                            consoleView.print(EmbeddedLinuxJVMBundle.message("exit.code.message", javaExitCode), ConsoleViewContentType.SYSTEM_OUTPUT);
                            exitMsgDisplay = true;
                        }
                        descriptor.setProcessHandler(null);
                    } catch (Exception e) {

                    }
                }
            }

        }

    }
}
 
Example #17
Source File: BaseProgramRunner.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static RunContentDescriptor postProcess(@Nonnull ExecutionEnvironment environment, @javax.annotation.Nullable RunContentDescriptor descriptor, @Nullable Callback callback) {
  if (descriptor != null) {
    descriptor.setExecutionId(environment.getExecutionId());
  }
  if (callback != null) {
    callback.processStarted(descriptor);
  }
  return descriptor;
}
 
Example #18
Source File: CloseAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public CloseAction(Executor executor, RunContentDescriptor contentDescriptor, Project project) {
  myExecutor = executor;
  myContentDescriptor = contentDescriptor;
  myProject = project;
  copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE));
  final Presentation templatePresentation = getTemplatePresentation();
  templatePresentation.setIcon(AllIcons.Actions.Cancel);
  templatePresentation.setText(ExecutionBundle.message("close.tab.action.name"));
  templatePresentation.setDescription(null);
}
 
Example #19
Source File: ExecutionChecker.java    From droidtestrec with Apache License 2.0 5 votes vote down vote up
public void run() {
    if (this.descriptor == null) {
        ProcessHandler[] processHandlers = this.executionManager.getRunningProcesses();
        if (processHandlers.length > 0) {
            List<RunContentDescriptor> descriptors = this.executionManager.getContentManager().getAllDescriptors();
            for (RunContentDescriptor tmp : descriptors) {
                if (tmp.getDisplayName().equals(this.runConfigName)) {
                    this.descriptor = tmp;
                    this.testListener.testStarted();
                    break;
                }
            }
        }
    }
}
 
Example #20
Source File: XDebuggerManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public XDebugSession getDebugSession(@Nonnull ExecutionConsole executionConsole) {
  for (final XDebugSessionImpl debuggerSession : mySessions.values()) {
    XDebugSessionTab sessionTab = debuggerSession.getSessionTab();
    if (sessionTab != null) {
      RunContentDescriptor contentDescriptor = sessionTab.getRunContentDescriptor();
      if (contentDescriptor != null && executionConsole == contentDescriptor.getExecutionConsole()) {
        return debuggerSession;
      }
    }
  }
  return null;
}
 
Example #21
Source File: XDebuggerManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Start a new debugging session and open 'Debug' tool window
 *
 * @param sessionName                 title of 'Debug' tool window
 * @param showToolWindowOnSuspendOnly if {@code true} 'Debug' tool window won't be shown until debug process is suspended on a breakpoint
 */
@Nonnull
public XDebugSession startSessionAndShowTab(@Nonnull String sessionName,
                                            @Nullable RunContentDescriptor contentToReuse,
                                            boolean showToolWindowOnSuspendOnly,
                                            @Nonnull XDebugProcessStarter starter) throws ExecutionException {
  return startSessionAndShowTab(sessionName, contentToReuse, showToolWindowOnSuspendOnly, (consulo.xdebugger.XDebugProcessStarter)starter);
}
 
Example #22
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 #23
Source File: RunContentExecutor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ConsoleView createConsole(@Nonnull Project project) {
  TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  consoleBuilder.filters(myFilterList);
  final ConsoleView console = consoleBuilder.getConsole();

  if (myHelpId != null) {
    console.setHelpId(myHelpId);
  }
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  DefaultActionGroup actions = new DefaultActionGroup();

  final JComponent consolePanel = createConsolePanel(console, actions);
  RunContentDescriptor descriptor = new RunContentDescriptor(console, myProcess, consolePanel, myTitle);

  Disposer.register(descriptor, this);
  Disposer.register(descriptor, console);

  actions.add(new RerunAction(consolePanel));
  actions.add(new StopAction());
  actions.add(new CloseAction(executor, descriptor, myProject));

  ExecutionManager.getInstance(myProject).getContentManager().showRunContent(executor, descriptor);

  if (myActivateToolWindow) {
    activateToolWindow();
  }

  return console;
}
 
Example #24
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean isAutoTestEnabledForDescriptor(@Nonnull RunContentDescriptor descriptor) {
  Content content = descriptor.getAttachedContent();
  if (content != null) {
    ExecutionEnvironment environment = getCurrentEnvironment(content);
    return environment != null && myEnabledRunProfiles.contains(environment.getRunProfile());
  }
  return false;
}
 
Example #25
Source File: HaxeFlashDebuggingUtil.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static RunContentDescriptor getDescriptor(final Module module,
                                                 ExecutionEnvironment env,
                                                 String urlToLaunch,
                                                 String flexSdkName) throws ExecutionException {
  final Sdk flexSdk = FlexSdkUtils.findFlexOrFlexmojosSdk(flexSdkName);
  if (flexSdk == null) {
    throw new ExecutionException(HaxeBundle.message("flex.sdk.not.found", flexSdkName));
  }

  final FlexBuildConfiguration bc = new FakeFlexBuildConfiguration(flexSdk, urlToLaunch);

  final XDebugSession debugSession =
    XDebuggerManager.getInstance(module.getProject()).startSession(env, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        try {
          final FlashRunnerParameters params = new FlashRunnerParameters();
          params.setModuleName(module.getName());
          return new HaxeDebugProcess(session, bc, params);
        }
        catch (IOException e) {
          throw new ExecutionException(e.getMessage(), e);
        }
      }
    });

  return debugSession.getRunContentDescriptor();
}
 
Example #26
Source File: AsyncProgramRunner.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected static void startRunProfile(ExecutionEnvironment environment,
                                      RunProfileState state,
                                      ProgramRunner.Callback callback,
                                      @javax.annotation.Nullable RunProfileStarter starter) {

  ThrowableComputable<AsyncResult<RunContentDescriptor>, ExecutionException> func = () -> {
    AsyncResult<RunContentDescriptor> promise = starter == null ? AsyncResult.done(null) : starter.executeAsync(state, environment);
    return promise.doWhenDone(it -> BaseProgramRunner.postProcess(environment, it, callback));
  };

  ExecutionManager.getInstance(environment.getProject()).startRunProfile(runProfileStarter(func), state, environment);
}
 
Example #27
Source File: RunIdeConsoleAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void ensureOutputIsRedirected(@Nonnull IdeScriptEngine engine, @Nonnull RunContentDescriptor descriptor) {
  ConsoleWriter stdOutWriter = ObjectUtils.tryCast(engine.getStdOut(), ConsoleWriter.class);
  ConsoleWriter stdErrWriter = ObjectUtils.tryCast(engine.getStdErr(), ConsoleWriter.class);
  if (stdOutWriter != null && stdOutWriter.getDescriptor() == descriptor &&
      stdErrWriter != null && stdErrWriter.getDescriptor() == descriptor) {
    return;
  }

  WeakReference<RunContentDescriptor> ref = new WeakReference<>(descriptor);
  engine.setStdOut(new ConsoleWriter(ref, ConsoleViewContentType.NORMAL_OUTPUT));
  engine.setStdErr(new ConsoleWriter(ref, ConsoleViewContentType.ERROR_OUTPUT));
}
 
Example #28
Source File: ServerConnectionManager.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private ProcessHandler getHandler(@NotNull DataContext dataContext) {
    final RunContentDescriptor contentDescriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
    if(contentDescriptor != null) {
        // toolwindow case
        return contentDescriptor.getProcessHandler();
    } else {
        // main menu toolbar
        final Project project = CommonDataKeys.PROJECT.getData(dataContext);
        final RunContentDescriptor selectedContent =
            project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
        return selectedContent == null ? null : selectedContent.getProcessHandler();
    }
}
 
Example #29
Source File: EmbeddedLinuxJVMRunner.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Executes the Runner, This only gets called in run mode.
 * It returns null because you want to show only the PI Console
 *
 * @param profileState
 * @param environment
 * @return
 * @throws ExecutionException
 */
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState profileState, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    final RunProfile runProfileRaw = environment.getRunProfile();
    if (runProfileRaw instanceof EmbeddedLinuxJVMRunConfiguration) {
        FileDocumentManager.getInstance().saveAllDocuments();
        setupConsole(environment.getProject());
        return super.doExecute(profileState, environment);
    }
    return super.doExecute(profileState, environment);
}
 
Example #30
Source File: CloseAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final RunContentDescriptor contentDescriptor = getContentDescriptor();
  if (contentDescriptor == null) {
    return;
  }
  final boolean removedOk = ExecutionManager.getInstance(myProject).getContentManager().removeRunContent(getExecutor(), contentDescriptor);
  if (removedOk) {
    myContentDescriptor = null;
    myExecutor = null;
  }
}