use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class RunDashboardContributor method getStatus.
/**
* 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;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class ExecutionManagerImpl method restartRunProfile.
@Override
public void restartRunProfile(@NotNull Project project, @NotNull Executor executor, @NotNull ExecutionTarget target, @Nullable RunnerAndConfigurationSettings configuration, @Nullable ProcessHandler processHandler) {
ExecutionEnvironmentBuilder builder = createEnvironmentBuilder(project, executor, configuration);
if (processHandler != null) {
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
if (descriptor.getProcessHandler() == processHandler) {
builder.contentToReuse(descriptor);
break;
}
}
}
restartRunProfile(builder.target(target).build());
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class ExecutionManagerImpl method userApprovesStopForIncompatibleConfigurations.
private static boolean userApprovesStopForIncompatibleConfigurations(Project project, String configName, List<RunContentDescriptor> runningIncompatibleDescriptors) {
RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
final RunManagerConfig config = runManager.getConfig();
if (!config.isStopIncompatibleRequiresConfirmation())
return true;
DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
@Override
public boolean isToBeShown() {
return config.isStopIncompatibleRequiresConfirmation();
}
@Override
public void setToBeShown(boolean value, int exitCode) {
config.setStopIncompatibleRequiresConfirmation(value);
}
@Override
public boolean canBeHidden() {
return true;
}
@Override
public boolean shouldSaveOptionsOnCancel() {
return false;
}
@NotNull
@Override
public String getDoNotShowMessage() {
return CommonBundle.message("dialog.options.do.not.show");
}
};
final StringBuilder names = new StringBuilder();
for (final RunContentDescriptor descriptor : runningIncompatibleDescriptors) {
String name = descriptor.getDisplayName();
if (names.length() > 0) {
names.append(", ");
}
names.append(StringUtil.isEmpty(name) ? ExecutionBundle.message("run.configuration.no.name") : String.format("'%s'", name));
}
//noinspection DialogTitleCapitalization
return Messages.showOkCancelDialog(project, ExecutionBundle.message("stop.incompatible.confirmation.message", configName, names.toString(), runningIncompatibleDescriptors.size()), ExecutionBundle.message("incompatible.configuration.is.running.dialog.title", runningIncompatibleDescriptors.size()), ExecutionBundle.message("stop.incompatible.confirmation.button.text"), CommonBundle.message("button.cancel"), Messages.getQuestionIcon(), option) == Messages.OK;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class ExecutionManagerImpl method startRunProfile.
@Override
public void startRunProfile(@NotNull final RunProfileStarter starter, @NotNull final RunProfileState state, @NotNull final ExecutionEnvironment environment) {
final Project project = environment.getProject();
RunContentDescriptor reuseContent = getContentManager().getReuseContent(environment);
if (reuseContent != null) {
reuseContent.setExecutionId(environment.getExecutionId());
environment.setContentToReuse(reuseContent);
}
final Executor executor = environment.getExecutor();
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStartScheduled(executor.getId(), environment);
Runnable startRunnable;
startRunnable = () -> {
if (project.isDisposed()) {
return;
}
RunProfile profile = environment.getRunProfile();
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarting(executor.getId(), environment);
starter.executeAsync(state, environment).done(descriptor -> {
AppUIUtil.invokeOnEdt(() -> {
if (descriptor != null) {
final Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity = Trinity.create(descriptor, environment.getRunnerAndConfigurationSettings(), executor);
myRunningConfigurations.add(trinity);
Disposer.register(descriptor, () -> myRunningConfigurations.remove(trinity));
getContentManager().showRunContent(executor, descriptor, environment.getContentToReuse());
final ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
if (!processHandler.isStartNotified()) {
processHandler.startNotify();
}
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarted(executor.getId(), environment, processHandler);
ProcessExecutionListener listener = new ProcessExecutionListener(project, executor.getId(), environment, processHandler, descriptor);
processHandler.addProcessListener(listener);
boolean terminating = processHandler.isProcessTerminating();
boolean terminated = processHandler.isProcessTerminated();
if (terminating || terminated) {
listener.processWillTerminate(new ProcessEvent(processHandler), false);
if (terminated) {
int exitCode = processHandler.isStartNotified() ? processHandler.getExitCode() : -1;
listener.processTerminated(new ProcessEvent(processHandler, exitCode));
}
}
}
environment.setContentToReuse(descriptor);
} else {
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), environment);
}
}, o -> project.isDisposed());
}).rejected(e -> {
if (!(e instanceof ProcessCanceledException)) {
ExecutionException error = e instanceof ExecutionException ? (ExecutionException) e : new ExecutionException(e);
ExecutionUtil.handleExecutionError(project, ExecutionManager.getInstance(project).getContentManager().getToolWindowIdByEnvironment(environment), profile, error);
}
LOG.info(e);
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), environment);
});
};
if (ApplicationManager.getApplication().isUnitTestMode() && !myForceCompilationInTests) {
startRunnable.run();
} else {
compileAndRun(() -> TransactionGuard.submitTransaction(project, startRunnable), environment, state, () -> {
if (!project.isDisposed()) {
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), environment);
}
});
}
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class AbstractConsoleRunnerWithHistory method createContentDescriptorAndActions.
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);
}
Aggregations