From 41c4d586c48b40a0f871944934d5504fcf8b0dcb Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Tue, 17 Apr 2012 18:02:31 +0400 Subject: [PATCH] Fix "Make before launch" --- .../execution/impl/RunManagerImpl.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 0061cdad34f7..9d1f528231e4 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -439,7 +439,17 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, if (!(settings.getConfiguration() instanceof UnknownRunConfiguration)) { final List tasks = getBeforeRunTasks(settings.getConfiguration()); final Element methodsElement = new Element(METHOD); + Map,BeforeRunTask> templateTasks = null; + if (!settings.isTemplate()) { + List beforeRunTasks = getBeforeRunTasks(getConfigurationTemplate(settings.getFactory()).getConfiguration()); + templateTasks = new HashMap, BeforeRunTask>(); + for (BeforeRunTask task : beforeRunTasks) { + templateTasks.put(task.getProviderId(), task); + } + } for (BeforeRunTask task : tasks) { + if (templateTasks != null && task.equals(templateTasks.get(task.getProviderId()))) + continue; // not neccesary saving if the task is the same as template final Element child = new Element(OPTION); child.setAttribute(NAME_ATTR, task.getProviderId().toString()); task.writeExternal(child); @@ -859,7 +869,20 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, } public final void setBeforeRunTasks(final RunConfiguration runConfiguration, List tasks) { - myConfigurationToBeforeTasksMap.put(runConfiguration, tasks); + List templates = getBeforeRunTasks(runConfiguration);//here may be some disabled templates + Set> idsToSet = new HashSet>(); + List result = new ArrayList(tasks); + for (BeforeRunTask task : tasks) { + idsToSet.add(task.getProviderId()); + } + int i = 0; + for (BeforeRunTask template : templates) { + if (!idsToSet.contains(template.getProviderId())) { + result.add(i, template); + i++; + } + } + myConfigurationToBeforeTasksMap.put(runConfiguration, result); fireBeforeRunTasksUpdated(); }