use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class AbstractExternalSystemRuntimeConfigurationProducer method createConfigurationByElement.
@Nullable
@Override
protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext context) {
if (!(location instanceof ExternalSystemTaskLocation)) {
return null;
}
ExternalSystemTaskLocation taskLocation = (ExternalSystemTaskLocation) location;
mySourceElement = taskLocation.getPsiElement();
RunManagerEx runManager = RunManagerEx.getInstanceEx(taskLocation.getProject());
RunnerAndConfigurationSettings settings = runManager.createConfiguration("", getConfigurationFactory());
ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) settings.getConfiguration();
ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings();
ExternalTaskExecutionInfo task = taskLocation.getTaskInfo();
taskExecutionSettings.setExternalProjectPath(task.getSettings().getExternalProjectPath());
taskExecutionSettings.setTaskNames(task.getSettings().getTaskNames());
configuration.setName(AbstractExternalSystemTaskConfigurationType.generateName(location.getProject(), taskExecutionSettings));
return settings;
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class AssignRunConfigurationShortcutAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = getProject(e);
assert project != null;
final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
if (selectedNodes == null || selectedNodes.size() != 1 || !(selectedNodes.get(0) instanceof RunConfigurationNode))
return;
RunnerAndConfigurationSettings settings = ((RunConfigurationNode) selectedNodes.get(0)).getSettings();
assert settings != null;
ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) settings.getConfiguration();
String actionIdPrefix = getActionPrefix(project, runConfiguration.getSettings().getExternalProjectPath());
String actionId = actionIdPrefix + settings.getName();
AnAction action = ActionManager.getInstance().getAction(actionId);
if (action == null) {
ExternalSystemKeymapExtension.getOrRegisterAction(project, settings);
}
new EditKeymapsDialog(project, actionId).show();
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class RunExternalSystemTaskAction method perform.
@Override
protected void perform(@NotNull Project project, @NotNull ProjectSystemId projectSystemId, @NotNull TaskData taskData, @NotNull AnActionEvent e) {
final ExternalTaskExecutionInfo taskExecutionInfo = ExternalSystemActionUtil.buildTaskInfo(taskData);
ExternalSystemUtil.runTask(taskExecutionInfo.getSettings(), taskExecutionInfo.getExecutorId(), project, projectSystemId);
final DataContext dataContext = e.getDataContext();
final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
RunnerAndConfigurationSettings configuration = context.findExisting();
RunManagerEx runManager = (RunManagerEx) context.getRunManager();
if (configuration == null) {
configuration = context.getConfiguration();
if (configuration == null) {
return;
}
runManager.setTemporaryConfiguration(configuration);
}
runManager.setSelectedConfiguration(configuration);
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class ModuleRunConfigurationManager method readExternal.
public void readExternal(@NotNull final Element element) {
LOG.debug("readExternal(" + myModule + ")");
myUnloadedElements = null;
final Set<String> existing = new HashSet<>();
for (final Element child : element.getChildren()) {
final RunnerAndConfigurationSettings configuration = myManager.loadConfiguration(child, true);
if (configuration == null && Comparing.strEqual(element.getName(), RunManagerImpl.CONFIGURATION)) {
if (myUnloadedElements == null)
myUnloadedElements = new ArrayList<>(2);
myUnloadedElements.add(element);
}
if (configuration != null) {
existing.add(configuration.getUniqueID());
}
}
for (final RunConfiguration configuration : myManager.getAllConfigurationsList()) {
if (!usesMyModule(configuration)) {
RunnerAndConfigurationSettings settings = myManager.getSettings(configuration);
if (settings != null) {
existing.add(settings.getUniqueID());
}
}
}
myManager.removeNotExistingSharedConfigurations(existing);
// IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
myManager.setOrdered(false);
myManager.getSortedConfigurations();
}
use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.
the class ProjectRunConfigurationManager method loadState.
@Override
public void loadState(Element state) {
if (myUnloadedElements != null) {
myUnloadedElements.clear();
}
Set<String> existing = new THashSet<>();
for (Iterator<Element> iterator = state.getChildren().iterator(); iterator.hasNext(); ) {
Element child = iterator.next();
RunnerAndConfigurationSettings configuration = myManager.loadConfiguration(child, true);
if (configuration != null) {
existing.add(configuration.getUniqueID());
} else if (child.getName().equals(RunManagerImpl.CONFIGURATION)) {
if (myUnloadedElements == null) {
myUnloadedElements = new SmartList<>();
}
iterator.remove();
myUnloadedElements.add(child);
}
}
myManager.removeNotExistingSharedConfigurations(existing);
if (myManager.getSelectedConfiguration() == null) {
final List<RunConfiguration> allConfigurations = myManager.getAllConfigurationsList();
for (final RunConfiguration configuration : allConfigurations) {
final RunnerAndConfigurationSettings settings = myManager.getSettings(allConfigurations.get(0));
if (!(configuration instanceof UnknownRunConfiguration)) {
myManager.setSelectedConfiguration(settings);
break;
}
}
}
// IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
myManager.setOrdered(false);
myManager.getSortedConfigurations();
}
Aggregations