summaryrefslogtreecommitdiff
path: root/platform/external-system-impl/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/external-system-impl/src')
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java22
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/DefaultExternalSystemExecutionConsoleManager.java6
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java8
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java5
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksTree.java2
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java135
6 files changed, 157 insertions, 21 deletions
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java
index 1345d495921b..3eb1dd6f4420 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java
@@ -109,7 +109,9 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
@NotNull
public static String generateName(@NotNull Project project, @NotNull ExternalSystemTaskExecutionSettings settings) {
- return generateName(project, settings.getExternalSystemId(), settings.getExternalProjectPath(), settings.getTaskNames());
+ return generateName(
+ project, settings.getExternalSystemId(), settings.getExternalProjectPath(), settings.getTaskNames(), settings.getExecutionName()
+ );
}
@NotNull
@@ -121,8 +123,16 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
public static String generateName(@NotNull Project project,
@NotNull ProjectSystemId externalSystemId,
@Nullable String externalProjectPath,
- @NotNull List<String> taskNames)
- {
+ @NotNull List<String> taskNames) {
+ return generateName(project, externalSystemId, externalProjectPath, taskNames, null);
+ }
+
+ @NotNull
+ public static String generateName(@NotNull Project project,
+ @NotNull ProjectSystemId externalSystemId,
+ @Nullable String externalProjectPath,
+ @NotNull List<String> taskNames,
+ @Nullable String executionName) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
assert manager != null;
AbstractExternalSystemSettings<?, ?,?> s = manager.getSettingsProvider().fun(project);
@@ -168,12 +178,16 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
}
buffer.append("[");
- if (!taskNames.isEmpty()) {
+ if (!StringUtil.isEmpty(executionName)) {
+ buffer.append(executionName);
+ }
+ else if (!taskNames.isEmpty()) {
for (String taskName : taskNames) {
buffer.append(taskName).append(" ");
}
buffer.setLength(buffer.length() - 1);
}
+
buffer.append("]");
return buffer.toString();
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/DefaultExternalSystemExecutionConsoleManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/DefaultExternalSystemExecutionConsoleManager.java
index b2a6bfd99b68..87b68e90bd69 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/DefaultExternalSystemExecutionConsoleManager.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/DefaultExternalSystemExecutionConsoleManager.java
@@ -22,6 +22,7 @@ import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ExecutionConsole;
+import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.externalSystem.execution.ExternalSystemExecutionConsoleManager;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTask;
@@ -67,4 +68,9 @@ public class DefaultExternalSystemExecutionConsoleManager implements ExternalSys
public boolean isApplicableFor(@NotNull ExternalSystemTask task) {
return true;
}
+
+ @Override
+ public AnAction[] getRestartActions() {
+ return new AnAction[0];
+ }
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java
index 4c27ae11a446..8b68dcc1ab03 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java
@@ -43,8 +43,7 @@ import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.*;
import java.util.List;
/**
@@ -236,12 +235,15 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
});
}
});
- return new DefaultExecutionResult(consoleView, processHandler);
+ DefaultExecutionResult result = new DefaultExecutionResult(consoleView, processHandler);
+ result.setRestartActions(consoleManager.getRestartActions());
+ return result;
}
}
private static class MyProcessHandler extends ProcessHandler {
private final ExternalSystemExecuteTaskTask myTask;
+ @Nullable private volatile OutputStream myOutputStream;
public MyProcessHandler(ExternalSystemExecuteTaskTask task) {
myTask = task;
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java
index b38cda93ea1a..75a227518b46 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java
@@ -133,6 +133,7 @@ public class ExternalSystemNotificationManager {
public void run() {
app.runWriteAction(new Runnable() {
public void run() {
+ if (myProject.isDisposed()) return;
ExternalSystemUtil.ensureToolWindowContentInitialized(myProject, externalSystemId);
initializedExternalSystem.add(externalSystemId);
}
@@ -305,9 +306,11 @@ public class ExternalSystemNotificationManager {
}
@NotNull
- private NewErrorTreeViewPanel prepareMessagesView(@NotNull final ProjectSystemId externalSystemId,
+ public NewErrorTreeViewPanel prepareMessagesView(@NotNull final ProjectSystemId externalSystemId,
@NotNull final NotificationSource notificationSource,
boolean activateView) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
+
final NewErrorTreeViewPanel errorTreeView;
final String contentDisplayName = getContentDisplayName(notificationSource, externalSystemId);
final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksTree.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksTree.java
index 12828629a616..76c94b061bfb 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksTree.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksTree.java
@@ -208,6 +208,8 @@ public class ExternalSystemTasksTree extends Tree implements Producer<ExternalTa
taskExecutionSettings.setExternalProjectPath(executionSettings.getExternalProjectPath());
taskExecutionSettings.setExternalSystemIdString(executionSettings.getExternalSystemIdString());
taskExecutionSettings.setVmOptions(executionSettings.getVmOptions());
+ taskExecutionSettings.setScriptParameters(executionSettings.getScriptParameters());
+ taskExecutionSettings.setExecutionName(executionSettings.getExecutionName());
executionInfo = new ExternalTaskExecutionInfo(taskExecutionSettings, taskExecutionInfo.getExecutorId());
map.put(key, executionInfo);
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
index 969c5b2c5815..786f96ffd8c2 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
@@ -19,9 +19,13 @@ import com.intellij.execution.*;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.executors.DefaultRunExecutor;
+import com.intellij.execution.process.ProcessAdapter;
+import com.intellij.execution.process.ProcessEvent;
+import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.rmi.RemoteUtil;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.application.Application;
@@ -58,6 +62,7 @@ import com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemRecentT
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
+import com.intellij.openapi.externalSystem.task.TaskCallback;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -67,7 +72,9 @@ import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -83,6 +90,7 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
+import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.ui.UIUtil;
@@ -539,23 +547,120 @@ public class ExternalSystemUtil {
@NotNull String executorId,
@NotNull Project project,
@NotNull ProjectSystemId externalSystemId) {
- runTask(taskSettings, executorId, project, externalSystemId, null);
+ runTask(taskSettings, executorId, project, externalSystemId, null, ProgressExecutionMode.IN_BACKGROUND_ASYNC);
}
- public static void runTask(@NotNull ExternalSystemTaskExecutionSettings taskSettings,
- @NotNull String executorId,
- @NotNull Project project,
- @NotNull ProjectSystemId externalSystemId,
- @Nullable ProgramRunner.Callback callback) {
+ public static void runTask(@NotNull final ExternalSystemTaskExecutionSettings taskSettings,
+ @NotNull final String executorId,
+ @NotNull final Project project,
+ @NotNull final ProjectSystemId externalSystemId,
+ @Nullable final TaskCallback callback,
+ @NotNull final ProgressExecutionMode progressExecutionMode) {
final Pair<ProgramRunner, ExecutionEnvironment> pair = createRunner(taskSettings, executorId, project, externalSystemId);
if (pair == null) return;
- try {
- pair.first.execute(pair.second, callback);
- }
- catch (ExecutionException e) {
- LOG.warn("Can't execute task " + taskSettings, e);
- }
+ final ProgramRunner runner = pair.first;
+ final ExecutionEnvironment environment = pair.second;
+
+ final TaskUnderProgress task = new TaskUnderProgress() {
+ @Override
+ public void execute(@NotNull ProgressIndicator indicator) {
+ final Semaphore targetDone = new Semaphore();
+ final Ref<Boolean> result = new Ref<Boolean>(false);
+ final Disposable disposable = Disposer.newDisposable();
+
+ project.getMessageBus().connect(disposable).subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionAdapter() {
+ public void processStartScheduled(final String executorIdLocal, final ExecutionEnvironment environmentLocal) {
+ if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) {
+ targetDone.down();
+ }
+ }
+
+ public void processNotStarted(final String executorIdLocal, @NotNull final ExecutionEnvironment environmentLocal) {
+ if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) {
+ targetDone.up();
+ }
+ }
+
+ public void processStarted(final String executorIdLocal,
+ @NotNull final ExecutionEnvironment environmentLocal,
+ @NotNull final ProcessHandler handler) {
+ if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) {
+ handler.addProcessListener(new ProcessAdapter() {
+ public void processTerminated(ProcessEvent event) {
+ result.set(event.getExitCode() == 0);
+ targetDone.up();
+ }
+ });
+ }
+ }
+ });
+
+ try {
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ runner.execute(environment);
+ }
+ catch (ExecutionException e) {
+ targetDone.up();
+ LOG.error(e);
+ }
+ }
+ }, ModalityState.NON_MODAL);
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ Disposer.dispose(disposable);
+ return;
+ }
+
+ targetDone.waitFor();
+ Disposer.dispose(disposable);
+
+ if (callback != null) {
+ if (result.get()) {
+ callback.onSuccess();
+ }
+ else {
+ callback.onFailure();
+ }
+ }
+ }
+ };
+
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ final String title = AbstractExternalSystemTaskConfigurationType.generateName(project, taskSettings);
+ switch (progressExecutionMode) {
+ case MODAL_SYNC:
+ new Task.Modal(project, title, true) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ task.execute(indicator);
+ }
+ }.queue();
+ break;
+ case IN_BACKGROUND_ASYNC:
+ new Task.Backgroundable(project, title) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ task.execute(indicator);
+ }
+ }.queue();
+ break;
+ case START_IN_FOREGROUND_ASYNC:
+ new Task.Backgroundable(project, title, true, PerformInBackgroundOption.DEAF) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ task.execute(indicator);
+ }
+ }.queue();
+ }
+ }
+ });
}
@Nullable
@@ -579,7 +684,11 @@ public class ExternalSystemUtil {
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(name, configurationType.getFactory());
ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration)settings.getConfiguration();
runConfiguration.getSettings().setExternalProjectPath(taskSettings.getExternalProjectPath());
- runConfiguration.getSettings().setTaskNames(taskSettings.getTaskNames());
+ runConfiguration.getSettings().setTaskNames(ContainerUtil.newArrayList(taskSettings.getTaskNames()));
+ runConfiguration.getSettings().setTaskDescriptions(ContainerUtil.newArrayList(taskSettings.getTaskDescriptions()));
+ runConfiguration.getSettings().setVmOptions(taskSettings.getVmOptions());
+ runConfiguration.getSettings().setScriptParameters(taskSettings.getScriptParameters());
+ runConfiguration.getSettings().setExecutionName(taskSettings.getExecutionName());
return Pair.create(runner, new ExecutionEnvironment(executor, runner, settings, project));
}