use of com.intellij.execution.RunManagerEx in project intellij-community by JetBrains.
the class CopyConfigurationAction method doActionPerformed.
@Override
@SuppressWarnings("unchecked")
protected void doActionPerformed(DashboardRunConfigurationNode node) {
RunManagerEx runManager = RunManagerEx.getInstanceEx(node.getProject());
RunnerAndConfigurationSettings settings = node.getConfigurationSettings();
RunnerAndConfigurationSettings copiedSettings = ((RunnerAndConfigurationSettingsImpl) settings).clone();
runManager.setUniqueNameIfNeed(copiedSettings);
copiedSettings.setFolderName(settings.getFolderName());
final ConfigurationFactory factory = settings.getFactory();
if (factory instanceof ConfigurationFactoryEx) {
((ConfigurationFactoryEx) factory).onConfigurationCopied(settings.getConfiguration());
}
if (RunDialog.editConfiguration(node.getProject(), copiedSettings, ExecutionBundle.message("run.dashboard.edit.configuration.dialog.title"))) {
runManager.addConfiguration(copiedSettings, runManager.isConfigurationShared(settings), runManager.getBeforeRunTasks(settings.getConfiguration()), false);
}
}
use of com.intellij.execution.RunManagerEx in project intellij-community by JetBrains.
the class ContextConfigurationTest method testReusingConfiguration.
public void testReusingConfiguration() {
RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
ConfigurationContext context = createContext(psiClass);
assertEquals(null, context.findExisting());
RunnerAndConfigurationSettings testClass = context.getConfiguration();
runManager.addConfiguration(testClass, false);
context = createContext(psiClass);
assertSame(testClass, context.findExisting());
runManager.setSelectedConfiguration(testClass);
context = createContext(psiPackage);
assertEquals(null, context.findExisting());
RunnerAndConfigurationSettings testPackage = context.getConfiguration();
runManager.addConfiguration(testPackage, false);
context = createContext(psiPackage);
assertSame(testPackage, context.findExisting());
assertSame(testClass, runManager.getSelectedConfiguration());
runManager.setSelectedConfiguration(context.findExisting());
assertSame(testPackage, runManager.getSelectedConfiguration());
}
use of com.intellij.execution.RunManagerEx in project intellij-community by JetBrains.
the class RemoveExternalSystemRunConfigurationAction 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;
int res = Messages.showYesNoDialog(project, "Delete \"" + settings.getName() + "\"?", "Confirmation", Messages.getQuestionIcon());
if (res == Messages.YES) {
((RunManagerEx) RunManager.getInstance(project)).removeConfiguration(settings);
}
}
use of com.intellij.execution.RunManagerEx in project intellij-community by JetBrains.
the class AntTargetNodeDescriptor method update.
public boolean update() {
final CompositeAppearance oldText = myHighlightedText;
final boolean isMeta = myTarget instanceof MetaTarget;
setIcon(isMeta ? AntIcons.MetaTarget : AntIcons.Target);
myHighlightedText = new CompositeAppearance();
final AntBuildFile buildFile = isMeta ? ((MetaTarget) myTarget).getBuildFile() : myTarget.getModel().getBuildFile();
final Color color = buildFile.isTargetVisible(myTarget) ? UIUtil.getLabelForeground() : UIUtil.getLabelDisabledForeground();
TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, myTarget.isDefault() ? Font.BOLD : Font.PLAIN);
myHighlightedText.getEnding().addText(myTarget.getDisplayName(), nameAttributes);
AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject);
final ArrayList<String> addedNames = new ArrayList<>(4);
for (final ExecutionEvent event : antConfiguration.getEventsForTarget(myTarget)) {
final String presentableName;
if ((event instanceof ExecuteCompositeTargetEvent)) {
presentableName = ((ExecuteCompositeTargetEvent) event).getMetaTargetName();
if (presentableName.equals(myTarget.getName())) {
continue;
}
} else {
presentableName = event.getPresentableName();
}
if (!addedNames.contains(presentableName)) {
addedNames.add(presentableName);
myHighlightedText.getEnding().addText(" (" + presentableName + ')', ourPostfixAttributes);
}
}
final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
final VirtualFile vFile = buildFile.getVirtualFile();
if (vFile != null) {
for (AntBeforeRunTask task : runManager.getBeforeRunTasks(AntBeforeRunTaskProvider.ID)) {
if (task.isRunningTarget(myTarget)) {
myHighlightedText.getEnding().addText(" (Before Run/Debug)", ourPostfixAttributes);
break;
}
}
}
myName = myHighlightedText.getText();
final AntBuildTargetBase target = getTarget();
if (!addShortcutText(target.getActionId())) {
if (target.isDefault()) {
addShortcutText(((AntBuildModelBase) target.getModel()).getDefaultTargetActionId());
}
}
return !Comparing.equal(myHighlightedText, oldText);
}
use of com.intellij.execution.RunManagerEx in project intellij-community by JetBrains.
the class GradleExecuteTaskAction method actionPerformed.
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
ExecuteGradleTaskHistoryService historyService = ExecuteGradleTaskHistoryService.getInstance(project);
GradleRunTaskDialog dialog = new GradleRunTaskDialog(project, historyService.getHistory());
String lastWorkingDirectory = historyService.getWorkDirectory();
if (lastWorkingDirectory.length() == 0) {
lastWorkingDirectory = obtainAppropriateWorkingDirectory(e);
}
dialog.setWorkDirectory(lastWorkingDirectory);
if (StringUtil.isEmptyOrSpaces(historyService.getCanceledCommand())) {
if (historyService.getHistory().size() > 0) {
dialog.setCommandLine(historyService.getHistory().get(0));
}
} else {
dialog.setCommandLine(historyService.getCanceledCommand());
}
if (!dialog.showAndGet()) {
historyService.setCanceledCommand(dialog.getCommandLine());
return;
}
historyService.setCanceledCommand(null);
String fullCommandLine = dialog.getCommandLine();
fullCommandLine = fullCommandLine.trim();
String workDirectory = dialog.getWorkDirectory();
historyService.addCommand(fullCommandLine, workDirectory);
final ExternalTaskExecutionInfo taskExecutionInfo;
try {
taskExecutionInfo = buildTaskInfo(workDirectory, fullCommandLine);
} catch (CommandLineArgumentException ex) {
final NotificationData notificationData = new NotificationData("<b>Command-line arguments cannot be parsed</b>", "<i>" + fullCommandLine + "</i> \n" + ex.getMessage(), NotificationCategory.WARNING, NotificationSource.TASK_EXECUTION);
notificationData.setBalloonNotification(true);
ExternalSystemNotificationManager.getInstance(project).showNotification(GradleConstants.SYSTEM_ID, notificationData);
return;
}
RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
ExternalSystemUtil.runTask(taskExecutionInfo.getSettings(), taskExecutionInfo.getExecutorId(), project, GradleConstants.SYSTEM_ID);
RunnerAndConfigurationSettings configuration = ExternalSystemUtil.createExternalSystemRunnerAndConfigurationSettings(taskExecutionInfo.getSettings(), project, GradleConstants.SYSTEM_ID);
if (configuration == null)
return;
final RunnerAndConfigurationSettings existingConfiguration = runManager.findConfigurationByName(configuration.getName());
if (existingConfiguration == null) {
runManager.setTemporaryConfiguration(configuration);
} else {
runManager.setSelectedConfiguration(existingConfiguration);
}
}
Aggregations