summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/execution/actions
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/execution/actions')
-rw-r--r--platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java57
-rw-r--r--platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java20
-rw-r--r--platform/lang-impl/src/com/intellij/execution/actions/StopAction.java72
3 files changed, 67 insertions, 82 deletions
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
index 1a0235ac9d46..a4764dae0036 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
@@ -22,8 +22,8 @@ import com.intellij.execution.configurations.UnknownConfigurationType;
import com.intellij.execution.impl.EditConfigurationsDialog;
import com.intellij.execution.impl.RunDialog;
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
+import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.ide.util.PropertiesComponent;
@@ -193,10 +193,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
private void updatePresentation() {
- final Executor executor = getExecutor();
- if (executor != null) {
- myPopup.setCaption(executor.getActionName());
- }
+ myPopup.setCaption(getExecutor().getActionName());
}
static void execute(final ItemWrapper itemWrapper, final Executor executor) {
@@ -218,12 +215,10 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
void editConfiguration(@NotNull final Project project, @NotNull final RunnerAndConfigurationSettings configuration) {
final Executor executor = getExecutor();
- assert executor != null;
-
PropertiesComponent.getInstance().setValue("run.configuration.edit.ad", Boolean.toString(true));
if (RunDialog.editConfiguration(project, configuration, "Edit configuration settings", executor)) {
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(configuration);
- doRunConfiguration(configuration, executor, project);
+ ExecutionUtil.runConfiguration(configuration, executor);
}
}
@@ -379,7 +374,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
public void perform(@NotNull Project project, @NotNull Executor executor, @NotNull DataContext context) {
RunnerAndConfigurationSettings config = getValue();
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(config);
- doRunConfiguration(config, executor, project);
+ ExecutionUtil.runConfiguration(config, executor);
}
@Override
@@ -404,7 +399,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public boolean available(Executor executor) {
- return null != ProgramRunnerUtil.getRunner(executor.getId(), getValue());
+ return ProgramRunnerUtil.getRunner(executor.getId(), getValue()) != null;
}
@Override
@@ -462,7 +457,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
final List<ItemWrapper> configurations = getValues();
final int index = configurations.indexOf(value);
if (index > 0 && index <= configurations.size() - 1) {
- final ItemWrapper aboveConfiguration = index == 0 ? null : configurations.get(index - 1);
+ final ItemWrapper aboveConfiguration = configurations.get(index - 1);
if (aboveConfiguration != null && aboveConfiguration.isDynamic() != value.isDynamic()) {
return new ListSeparator();
@@ -508,18 +503,15 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
}
- final Executor executor = myAction.getExecutor();
- assert executor != null;
-
- if (finalChoice && wrapper.available(executor)) {
+ if (finalChoice && wrapper.available(myAction.getExecutor())) {
return doFinalStep(new Runnable() {
@Override
public void run() {
- if (executor == myAction.myAlternativeExecutor) {
+ if (myAction.getExecutor() == myAction.myAlternativeExecutor) {
PropertiesComponent.getInstance().setValue(myAction.myAddKey, Boolean.toString(true));
}
- wrapper.perform(myProject, executor, DataManager.getInstance().getDataContext());
+ wrapper.perform(myProject, myAction.getExecutor(), DataManager.getInstance().getDataContext());
}
});
}
@@ -545,14 +537,6 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
}
- private static void doRunConfiguration(RunnerAndConfigurationSettings configuration, Executor executor, Project project) {
- ExecutionManager.getInstance(project).restartRunProfile(project,
- executor,
- ExecutionTargetManager.getActiveTarget(project),
- configuration,
- (RunContentDescriptor)null);
- }
-
private static final class ConfigurationActionsStep extends BaseListPopupStep<ActionWrapper> {
@NotNull private final RunnerAndConfigurationSettings mySettings;
@@ -600,11 +584,13 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public void perform() {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
- if (dynamic) manager.setTemporaryConfiguration(settings);
+ if (dynamic) {
+ manager.setTemporaryConfiguration(settings);
+ }
manager.setSelectedConfiguration(settings);
ExecutionTargetManager.setActiveTarget(project, eachTarget);
- doRunConfiguration(settings, action.getExecutor(), project);
+ ExecutionUtil.runConfiguration(settings, action.getExecutor());
}
});
}
@@ -617,9 +603,11 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public void perform() {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
- if (dynamic) manager.setTemporaryConfiguration(settings);
+ if (dynamic) {
+ manager.setTemporaryConfiguration(settings);
+ }
manager.setSelectedConfiguration(settings);
- doRunConfiguration(settings, executor, project);
+ ExecutionUtil.runConfiguration(settings, executor);
}
});
isFirst = false;
@@ -857,7 +845,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
RunnerAndConfigurationSettings selectedConfiguration = RunManagerEx.getInstanceEx(project).getSelectedConfiguration();
if (myConfigurations.contains(selectedConfiguration)) {
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(selectedConfiguration);
- doRunConfiguration(selectedConfiguration, myExecutorProvider.getExecutor(), project);
+ ExecutionUtil.runConfiguration(selectedConfiguration, myExecutorProvider.getExecutor());
}
}
@@ -906,8 +894,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
public void run() {
RunnerAndConfigurationSettings settings = selectedValue.getSettings();
RunManagerEx.getInstanceEx(myProject).setSelectedConfiguration(settings);
- doRunConfiguration(settings, myExecutorProvider.getExecutor(), myProject);
-
+ ExecutionUtil.runConfiguration(settings, myExecutorProvider.getExecutor());
}
});
} else {
@@ -961,7 +948,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
ExecutionTargetManager.setActiveTarget(project, eachTarget);
- doRunConfiguration(selectedConfiguration, executor, project);
+ ExecutionUtil.runConfiguration(selectedConfiguration, executor);
}
@Override
@@ -1035,7 +1022,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- doRunConfiguration(RunManager.getInstance(project).getSelectedConfiguration(), executor, project);
+ ExecutionUtil.runConfiguration(RunManager.getInstance(project).getSelectedConfiguration(), executor);
}
});
}
@@ -1116,7 +1103,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
public void perform(@NotNull Project project, @NotNull Executor executor, @NotNull DataContext context) {
manager.setTemporaryConfiguration(configuration);
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(configuration);
- doRunConfiguration(configuration, executor, project);
+ ExecutionUtil.runConfiguration(configuration, executor);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java b/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
index f5741242089d..0a467c7cec23 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
@@ -18,10 +18,9 @@ package com.intellij.execution.actions;
import com.intellij.execution.*;
import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.actionSystem.Presentation;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -47,12 +46,8 @@ public class RunContextAction extends BaseRunConfigurationAction {
runManager.setTemporaryConfiguration(configuration);
}
runManager.setSelectedConfiguration(configuration);
- Project project = context.getProject();
- ExecutionManager.getInstance(project).restartRunProfile(project,
- myExecutor,
- ExecutionTargetManager.getActiveTarget(project),
- configuration,
- (RunContentDescriptor)null);
+
+ ExecutionUtil.runConfiguration(configuration, myExecutor);
}
@Override
@@ -81,11 +76,10 @@ public class RunContextAction extends BaseRunConfigurationAction {
configuration = context.getConfiguration();
}
- if (configuration == null) return Pair.create(false, false);
-
- final ProgramRunner runner = getRunner(configuration.getConfiguration());
- if (runner == null) return Pair.create(false, false);
-
+ ProgramRunner runner = configuration == null ? null : getRunner(configuration.getConfiguration());
+ if (runner == null) {
+ return Pair.create(false, false);
+ }
return Pair.create(!ExecutorRegistry.getInstance().isStarting(context.getProject(), myExecutor.getId(), runner.getRunnerId()), true);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java b/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java
index 618a4b1c65c5..75466528ae2f 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.actions;
+import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.KillableProcess;
+import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -29,7 +29,7 @@ import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
@@ -49,19 +49,20 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
+class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
@Override
public void update(final AnActionEvent e) {
boolean enable = false;
Icon icon = getTemplatePresentation().getIcon();
String description = getTemplatePresentation().getDescription();
- final Presentation presentation = e.getPresentation();
-
+ Presentation presentation = e.getPresentation();
if (ActionPlaces.MAIN_MENU.equals(e.getPlace())) {
enable = !getCancellableProcesses(e.getProject()).isEmpty() || !getActiveDescriptors(e.getDataContext()).isEmpty();
+ presentation.setText(getTemplatePresentation().getText());
}
else {
- final ProcessHandler processHandler = getHandler(e.getDataContext());
+ RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminated()) {
if (!processHandler.isProcessTerminating()) {
enable = true;
@@ -72,6 +73,14 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
description = "Kill process";
}
}
+
+ RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE);
+ if (runProfile == null && contentDescriptor == null) {
+ presentation.setText(getTemplatePresentation().getText());
+ }
+ else {
+ presentation.setText(ExecutionBundle.message("stop.configuration.action.name", runProfile == null ? contentDescriptor.getDisplayName() : runProfile.getName()));
+ }
}
presentation.setEnabled(enable);
@@ -84,7 +93,8 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
final DataContext dataContext = e.getDataContext();
ProcessHandler activeProcessHandler = getHandler(dataContext);
- List<Pair<TaskInfo, ProgressIndicator>> backgroundTasks = getCancellableProcesses(e.getProject());
+ Project project = e.getProject();
+ List<Pair<TaskInfo, ProgressIndicator>> backgroundTasks = getCancellableProcesses(project);
if (ActionPlaces.MAIN_MENU.equals(e.getPlace())) {
if (activeProcessHandler != null && !activeProcessHandler.isProcessTerminating() && !activeProcessHandler.isProcessTerminated()
&& backgroundTasks.isEmpty()) {
@@ -94,12 +104,14 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
Pair<List<HandlerItem>, HandlerItem>
handlerItems = getItemsList(backgroundTasks, getActiveDescriptors(dataContext), activeProcessHandler);
- if (handlerItems.first.isEmpty()) return;
+ if (handlerItems == null || handlerItems.first.isEmpty()) {
+ return;
+ }
final JBList list = new JBList(handlerItems.first);
if (handlerItems.second != null) list.setSelectedValue(handlerItems.second, true);
- list.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor() {
+ list.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter() {
@Nullable
@Override
public String getTextFor(Object value) {
@@ -108,12 +120,6 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
@Nullable
@Override
- public String getTooltipFor(Object value) {
- return null;
- }
-
- @Nullable
- @Override
public Icon getIconFor(Object value) {
return value instanceof HandlerItem ? ((HandlerItem)value).icon : null;
}
@@ -122,12 +128,6 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
public boolean hasSeparatorAboveOf(Object value) {
return value instanceof HandlerItem && ((HandlerItem)value).hasSeparator;
}
-
- @Nullable
- @Override
- public String getCaptionAboveOf(Object value) {
- return null;
- }
}));
final PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
@@ -148,7 +148,8 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
}
}).setRequestFocus(true).createPopup();
- popup.showCenteredInCurrentWindow(e.getProject());
+ assert project != null;
+ popup.showCenteredInCurrentWindow(project);
}
else {
if (activeProcessHandler != null) {
@@ -171,12 +172,15 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
});
}
+ @Nullable
private static Pair<List<HandlerItem>, HandlerItem> getItemsList(List<Pair<TaskInfo, ProgressIndicator>> tasks,
List<RunContentDescriptor> descriptors,
ProcessHandler activeProcessHandler) {
- if (tasks.isEmpty() && descriptors.isEmpty()) return Pair.create(Collections.<HandlerItem>emptyList(), null);
+ if (tasks.isEmpty() && descriptors.isEmpty()) {
+ return null;
+ }
- ArrayList<HandlerItem> items = new ArrayList<HandlerItem>(tasks.size() + descriptors.size());
+ List<HandlerItem> items = new ArrayList<HandlerItem>(tasks.size() + descriptors.size());
HandlerItem selected = null;
for (RunContentDescriptor descriptor : descriptors) {
final ProcessHandler handler = descriptor.getProcessHandler();
@@ -188,7 +192,9 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
}
};
items.add(item);
- if (handler == activeProcessHandler) selected = item;
+ if (handler == activeProcessHandler) {
+ selected = item;
+ }
}
}
@@ -202,7 +208,7 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
});
hasSeparator = false;
}
- return Pair.<List<HandlerItem>, HandlerItem>create(items, selected);
+ return Pair.create(items, selected);
}
private static void stopProcess(ProcessHandler processHandler) {
@@ -220,21 +226,19 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
}
@Nullable
- static ProcessHandler getHandler(final DataContext dataContext) {
- final RunContentDescriptor contentDescriptor = RunContentManager.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
- final ProcessHandler processHandler;
+ static ProcessHandler getHandler(@NotNull DataContext dataContext) {
+ final RunContentDescriptor contentDescriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
if (contentDescriptor != null) {
// toolwindow case
- processHandler = contentDescriptor.getProcessHandler();
+ 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();
- processHandler = selectedContent == null ? null : selectedContent.getProcessHandler();
+ return selectedContent == null ? null : selectedContent.getProcessHandler();
}
- return processHandler;
}
@NotNull