mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-13074 Cannot Rerun Nailgun Server in the Run tool window
This commit is contained in:
@@ -52,13 +52,13 @@ public abstract class ExecutionManager {
|
||||
public abstract void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@NotNull RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@Nullable ProcessHandler processHandler);
|
||||
|
||||
//currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
|
||||
public abstract void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@NotNull RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunContentDescriptor currentDescriptor);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public final class ExecutionEnvironmentBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExecutionEnvironment build() {
|
||||
ExecutionEnvironment environment =
|
||||
new ExecutionEnvironment(myRunProfile, myTarget, myProject, myRunnerSettings, myConfigurationSettings, myContentToReuse,
|
||||
|
||||
@@ -261,7 +261,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
public void restartRunProfile(@NotNull final Project project,
|
||||
@NotNull final Executor executor,
|
||||
@NotNull final ExecutionTarget target,
|
||||
@NotNull final RunnerAndConfigurationSettings configuration,
|
||||
@Nullable final RunnerAndConfigurationSettings configuration,
|
||||
@Nullable final ProcessHandler processHandler) {
|
||||
if (processHandler != null) {
|
||||
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
|
||||
@@ -279,13 +279,18 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
public void restartRunProfile(@NotNull final Project project,
|
||||
@NotNull final Executor executor,
|
||||
@NotNull final ExecutionTarget target,
|
||||
@NotNull final RunnerAndConfigurationSettings configuration,
|
||||
@Nullable final RunnerAndConfigurationSettings configuration,
|
||||
@Nullable final RunContentDescriptor currentDescriptor) {
|
||||
if (ProgramRunnerUtil.getRunner(executor.getId(), configuration) == null) {
|
||||
if (configuration != null && ProgramRunnerUtil.getRunner(executor.getId(), configuration) == null) {
|
||||
LOG.error("Cannot find runner for " + configuration.getName());
|
||||
return;
|
||||
}
|
||||
if (configuration == null && (currentDescriptor == null || currentDescriptor.getRestarter() == null)) {
|
||||
LOG.error("Nothing to restart");
|
||||
return;
|
||||
}
|
||||
final List<RunContentDescriptor> descriptorsToStop = new ArrayList<RunContentDescriptor>();
|
||||
if (configuration.isSingleton()) {
|
||||
if (configuration != null && configuration.isSingleton()) {
|
||||
descriptorsToStop.addAll(getRunningDescriptors(configuration));
|
||||
}
|
||||
else if (currentDescriptor != null) {
|
||||
@@ -293,7 +298,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
}
|
||||
|
||||
if (!descriptorsToStop.isEmpty()) {
|
||||
if ((descriptorsToStop.size() > 1 || currentDescriptor == null || descriptorsToStop.get(0) != currentDescriptor) &&
|
||||
if (configuration != null && (descriptorsToStop.size() > 1 || currentDescriptor == null || descriptorsToStop.get(0) != currentDescriptor) &&
|
||||
!userApprovesStop(project, configuration.getName(), descriptorsToStop.size())) {
|
||||
return;
|
||||
}
|
||||
@@ -302,7 +307,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
}
|
||||
}
|
||||
else {
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor, target, currentDescriptor, true);
|
||||
start(project, configuration, executor, target, currentDescriptor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -316,12 +321,26 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
return;
|
||||
}
|
||||
}
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor, target, currentDescriptor, true);
|
||||
start(project, configuration, executor, target, currentDescriptor);
|
||||
}
|
||||
};
|
||||
awaitingTerminationAlarm.addRequest(runnable, 100);
|
||||
}
|
||||
|
||||
private static void start(@NotNull Project project,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunContentDescriptor descriptor) {
|
||||
Runnable restarter = descriptor != null ? descriptor.getRestarter() : null;
|
||||
if (configuration != null) {
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor, target, descriptor, true);
|
||||
}
|
||||
else if (restarter != null) {
|
||||
restarter.run();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean userApprovesStop(Project project, String configName, int instancesCount) {
|
||||
RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
|
||||
final RunManagerConfig config = runManager.getConfig();
|
||||
@@ -376,7 +395,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
}
|
||||
|
||||
|
||||
private void stop(RunContentDescriptor runContentDescriptor) {
|
||||
private static void stop(RunContentDescriptor runContentDescriptor) {
|
||||
ProcessHandler processHandler = runContentDescriptor != null ? runContentDescriptor.getProcessHandler() : null;
|
||||
if (processHandler == null) {
|
||||
return;
|
||||
|
||||
@@ -108,31 +108,24 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
Project project = myEnvironment.getProject();
|
||||
RunnerAndConfigurationSettings settings = myEnvironment.getRunnerAndConfigurationSettings();
|
||||
if (project == null)
|
||||
return;
|
||||
if (settings != null) {
|
||||
if (myProcessHandler != null) {
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project,
|
||||
myExecutor,
|
||||
myEnvironment.getExecutionTarget(),
|
||||
settings,
|
||||
myEnvironment.getRunnerAndConfigurationSettings(),
|
||||
myProcessHandler);
|
||||
}
|
||||
else {
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project,
|
||||
myExecutor,
|
||||
myEnvironment.getExecutionTarget(),
|
||||
settings,
|
||||
myEnvironment.getRunnerAndConfigurationSettings(),
|
||||
myDescriptor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
|
||||
//Should be used by android framework only
|
||||
public void restart() {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myDescriptor.getComponent()));
|
||||
if (ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId())) {
|
||||
|
||||
Reference in New Issue
Block a user