diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/execution/runners/RunTab.java')
-rw-r--r-- | platform/lang-impl/src/com/intellij/execution/runners/RunTab.java | 74 |
1 files changed, 54 insertions, 20 deletions
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java b/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java index 2edc2098ce15..6628c78f1851 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java @@ -25,6 +25,8 @@ import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ExecutionConsole; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.ui.RunnerLayoutUi; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.project.Project; @@ -33,12 +35,20 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public abstract class RunTab extends LogConsoleManagerBase implements DataProvider { +import javax.swing.*; + +public abstract class RunTab implements DataProvider, Disposable { @NotNull protected final RunnerLayoutUi myUi; - protected final LogFilesManager myManager; + private LogFilesManager myManager; protected RunContentDescriptor myRunContentDescriptor; + protected ExecutionEnvironment myEnvironment; + protected final Project myProject; + private final GlobalSearchScope mySearchScope; + + private LogConsoleManagerBase logConsoleManager; + protected RunTab(@NotNull ExecutionEnvironment environment, @NotNull String runnerType) { this(environment.getProject(), SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile()), @@ -46,15 +56,21 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid environment.getExecutor().getId(), environment.getRunProfile().getName()); - setEnvironment(environment); + myEnvironment = environment; } - protected RunTab(@NotNull Project project, @NotNull GlobalSearchScope searchScope, @NotNull String runnerType, @NotNull String runnerTitle, @NotNull String sessionName) { - super(project, searchScope); + @Override + public void dispose() { + myRunContentDescriptor = null; + myEnvironment = null; + logConsoleManager = null; + } - myManager = new LogFilesManager(project, this, this); + protected RunTab(@NotNull Project project, @NotNull GlobalSearchScope searchScope, @NotNull String runnerType, @NotNull String runnerTitle, @NotNull String sessionName) { + myProject = project; + mySearchScope = searchScope; - myUi = RunnerLayoutUi.Factory.getInstance(getProject()).create(runnerType, runnerTitle, sessionName, this); + myUi = RunnerLayoutUi.Factory.getInstance(project).create(runnerType, runnerTitle, sessionName, this); myUi.getContentManager().addDataProvider(this); } @@ -62,11 +78,10 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid @Override public Object getData(@NonNls String dataId) { if (LangDataKeys.RUN_PROFILE.is(dataId)) { - ExecutionEnvironment environment = getEnvironment(); - return environment == null ? null : environment.getRunProfile(); + return myEnvironment == null ? null : myEnvironment.getRunProfile(); } else if (LangDataKeys.EXECUTION_ENVIRONMENT.is(dataId)) { - return getEnvironment(); + return myEnvironment; } else if (LangDataKeys.RUN_CONTENT_DESCRIPTOR.is(dataId)) { return myRunContentDescriptor; @@ -74,21 +89,40 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid return null; } - @Override - public final void setEnvironment(@NotNull ExecutionEnvironment environment) { - super.setEnvironment(environment); + @NotNull + public LogConsoleManagerBase getLogConsoleManager() { + if (logConsoleManager == null) { + logConsoleManager = new LogConsoleManagerBase(myProject, mySearchScope) { + @Override + protected Icon getDefaultIcon() { + return AllIcons.Debugger.Console; + } + + @Override + protected RunnerLayoutUi getUi() { + return myUi; + } - RunProfile profile = environment.getRunProfile(); - if (profile instanceof RunConfigurationBase) { - myManager.registerFileMatcher((RunConfigurationBase)profile); + @Override + public ProcessHandler getProcessHandler() { + return myRunContentDescriptor == null ? null : myRunContentDescriptor.getProcessHandler(); + } + }; } + return logConsoleManager; } - protected final void initLogConsoles(@NotNull RunProfile runConfiguration, @Nullable ProcessHandler processHandler, @Nullable ExecutionConsole console) { - if (runConfiguration instanceof RunConfigurationBase && processHandler != null) { + protected final void initLogConsoles(@NotNull RunProfile runConfiguration, @NotNull RunContentDescriptor contentDescriptor, @Nullable ExecutionConsole console) { + ProcessHandler processHandler = contentDescriptor.getProcessHandler(); + if (runConfiguration instanceof RunConfigurationBase) { RunConfigurationBase configuration = (RunConfigurationBase)runConfiguration; - myManager.initLogConsoles(configuration, processHandler); - OutputFileUtil.attachDumpListener(configuration, processHandler, console); + if (myManager == null) { + myManager = new LogFilesManager(getLogConsoleManager()); + } + myManager.addLogConsoles(configuration, processHandler); + if (processHandler != null) { + OutputFileUtil.attachDumpListener(configuration, processHandler, console); + } } } } |