diff --git a/java/debugger/impl/src/com/intellij/debugger/DebugEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DebugEnvironment.java index 68486c82b847..af8662bfffe8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/DebugEnvironment.java +++ b/java/debugger/impl/src/com/intellij/debugger/DebugEnvironment.java @@ -15,17 +15,12 @@ */ package com.intellij.debugger; -import com.intellij.diagnostic.logging.LogFilesManager; import com.intellij.execution.ExecutionException; import com.intellij.execution.ExecutionResult; import com.intellij.execution.configurations.RemoteConnection; -import com.intellij.execution.ui.RunContentDescriptor; -import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.Nullable; -import javax.swing.*; - /** * Created by IntelliJ IDEA. * User: michael.golubev @@ -39,19 +34,9 @@ public interface DebugEnvironment { boolean isRemote(); - @Nullable - RunContentDescriptor getReuseContent(); - RemoteConnection getRemoteConnection(); boolean isPollConnection(); String getSessionName(); - - @Nullable - Icon getIcon(); - - void initContent(RunContentDescriptor content, - LogFilesManager logFilesManager, - DefaultActionGroup group); } diff --git a/java/debugger/impl/src/com/intellij/debugger/DebugUIEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DebugUIEnvironment.java new file mode 100644 index 000000000000..dbe88aa9f168 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/DebugUIEnvironment.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2012 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger; + +import com.intellij.diagnostic.logging.LogFilesManager; +import com.intellij.execution.ui.RunContentDescriptor; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +/** + * Created by IntelliJ IDEA. + * User: michael.golubev + */ +public interface DebugUIEnvironment { + + DebugEnvironment getEnvironment(); + + @Nullable + RunContentDescriptor getReuseContent(); + + @Nullable + Icon getIcon(); + + void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager); + + void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup); +} diff --git a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java index 639f1802e48e..ffb3ee380d0e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java +++ b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java @@ -15,8 +15,6 @@ */ package com.intellij.debugger; -import com.intellij.diagnostic.logging.LogFilesManager; -import com.intellij.diagnostic.logging.OutputFileUtil; import com.intellij.execution.ExecutionException; import com.intellij.execution.ExecutionResult; import com.intellij.execution.Executor; @@ -24,22 +22,11 @@ import com.intellij.execution.configurations.*; import com.intellij.execution.filters.ExceptionFilters; import com.intellij.execution.filters.Filter; import com.intellij.execution.filters.TextConsoleBuilder; -import com.intellij.execution.process.ProcessHandler; -import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.ProgramRunner; -import com.intellij.execution.runners.RestartAction; -import com.intellij.execution.ui.RunContentDescriptor; -import com.intellij.execution.ui.actions.CloseAction; -import com.intellij.ide.actions.ContextHelpAction; -import com.intellij.openapi.actionSystem.Constraints; -import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants; -import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.util.List; /** @@ -49,70 +36,24 @@ import java.util.List; public class DefaultDebugEnvironment implements DebugEnvironment { private final GlobalSearchScope mySearchScope; - private final Project myProject; private final Executor myExecutor; private final ProgramRunner myRunner; - @Nullable private final ExecutionEnvironment myEnvironment; private RunProfileState myState; - @Nullable private final RunContentDescriptor myReuseContent; private final RemoteConnection myRemoteConnection; private final boolean myPollConnection; private final RunProfile myRunProfile; - public DefaultDebugEnvironment(Project project, - Executor executor, - ProgramRunner runner, - ExecutionEnvironment environment, - RunProfileState state, - @Nullable RunContentDescriptor reuseContent, - RemoteConnection remoteConnection, - boolean pollConnection) { - this(project, - executor, - runner, - environment, - environment.getRunProfile(), - state, - reuseContent, - remoteConnection, - pollConnection); - } - public DefaultDebugEnvironment(Project project, Executor executor, ProgramRunner runner, RunProfile runProfile, RunProfileState state, - @Nullable RunContentDescriptor reuseContent, RemoteConnection remoteConnection, boolean pollConnection) { - this(project, - executor, - runner, - null, - runProfile, - state, - reuseContent, - remoteConnection, - pollConnection); - } - - private DefaultDebugEnvironment(Project project, - Executor executor, - ProgramRunner runner, - @Nullable ExecutionEnvironment environment, - RunProfile runProfile, - RunProfileState state, - @Nullable RunContentDescriptor reuseContent, - RemoteConnection remoteConnection, - boolean pollConnection) { - myProject = project; myExecutor = executor; myRunner = runner; - myEnvironment = environment; myRunProfile = runProfile; myState = state; - myReuseContent = reuseContent; myRemoteConnection = remoteConnection; myPollConnection = pollConnection; @@ -157,12 +98,6 @@ public class DefaultDebugEnvironment implements DebugEnvironment { return myState instanceof RemoteState; } - @Nullable - @Override - public RunContentDescriptor getReuseContent() { - return myReuseContent; - } - @Override public RemoteConnection getRemoteConnection() { return myRemoteConnection; @@ -177,34 +112,4 @@ public class DefaultDebugEnvironment implements DebugEnvironment { public String getSessionName() { return myRunProfile.getName(); } - - @Override - public Icon getIcon() { - return myRunProfile.getIcon(); - } - - @Override - public void initContent(RunContentDescriptor content, LogFilesManager logFilesManager, DefaultActionGroup actionGroup) { - ProcessHandler processHandler = content.getProcessHandler(); - if (myRunProfile instanceof RunConfigurationBase) { - RunConfigurationBase runConfiguration = (RunConfigurationBase)myRunProfile; - - logFilesManager.registerFileMatcher(runConfiguration); - - logFilesManager.initLogConsoles(runConfiguration, processHandler); - OutputFileUtil.attachDumpListener(runConfiguration, processHandler, content.getExecutionConsole()); - } - - RestartAction restartAction = new RestartAction(myExecutor, - myRunner, - processHandler, - XDebuggerUIConstants.DEBUG_AGAIN_ICON, - content, - myEnvironment); - actionGroup.add(restartAction, Constraints.FIRST); - restartAction.registerShortcut(content.getComponent()); - - actionGroup.add(new CloseAction(myExecutor, content, myProject)); - actionGroup.add(new ContextHelpAction(myExecutor.getHelpId())); - } } diff --git a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java new file mode 100644 index 000000000000..ccb8dc6e2dad --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java @@ -0,0 +1,121 @@ +/* + * Copyright 2000-2012 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger; + +import com.intellij.diagnostic.logging.LogFilesManager; +import com.intellij.diagnostic.logging.OutputFileUtil; +import com.intellij.execution.Executor; +import com.intellij.execution.configurations.RemoteConnection; +import com.intellij.execution.configurations.RunConfigurationBase; +import com.intellij.execution.configurations.RunProfile; +import com.intellij.execution.configurations.RunProfileState; +import com.intellij.execution.process.ProcessHandler; +import com.intellij.execution.runners.ExecutionEnvironment; +import com.intellij.execution.runners.ProgramRunner; +import com.intellij.execution.runners.RestartAction; +import com.intellij.execution.ui.RunContentDescriptor; +import com.intellij.execution.ui.actions.CloseAction; +import com.intellij.ide.actions.ContextHelpAction; +import com.intellij.openapi.actionSystem.Constraints; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.project.Project; +import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +/** + * Created by IntelliJ IDEA. + * User: michael.golubev + */ +public class DefaultDebugUIEnvironment implements DebugUIEnvironment { + + private final Project myProject; + private final Executor myExecutor; + private final ProgramRunner myRunner; + private final ExecutionEnvironment myExecutionEnvironment; + @Nullable private final RunContentDescriptor myReuseContent; + private final RunProfile myRunProfile; + private final DebugEnvironment myModelEnvironment; + + public DefaultDebugUIEnvironment(Project project, + Executor executor, + ProgramRunner runner, + ExecutionEnvironment environment, + RunProfileState state, + @Nullable RunContentDescriptor reuseContent, + RemoteConnection remoteConnection, + boolean pollConnection) { + myProject = project; + myExecutor = executor; + myRunner = runner; + myExecutionEnvironment = environment; + myRunProfile = environment.getRunProfile(); + myModelEnvironment = new DefaultDebugEnvironment(project, + executor, + runner, + myRunProfile, + state, + remoteConnection, + pollConnection); + myReuseContent = reuseContent; + } + + @Override + public DebugEnvironment getEnvironment() { + return myModelEnvironment; + } + + @Nullable + @Override + public RunContentDescriptor getReuseContent() { + return myReuseContent; + } + + @Override + public Icon getIcon() { + return myRunProfile.getIcon(); + } + + @Override + public void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager) { + ProcessHandler processHandler = content.getProcessHandler(); + if (myRunProfile instanceof RunConfigurationBase) { + RunConfigurationBase runConfiguration = (RunConfigurationBase)myRunProfile; + + logFilesManager.registerFileMatcher(runConfiguration); + + logFilesManager.initLogConsoles(runConfiguration, processHandler); + OutputFileUtil.attachDumpListener(runConfiguration, processHandler, content.getExecutionConsole()); + } + } + + @Override + public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) { + ProcessHandler processHandler = content.getProcessHandler(); + RestartAction restartAction = new RestartAction(myExecutor, + myRunner, + processHandler, + XDebuggerUIConstants.DEBUG_AGAIN_ICON, + content, + myExecutionEnvironment); + actionGroup.add(restartAction, Constraints.FIRST); + restartAction.registerShortcut(content.getComponent()); + + actionGroup.add(new CloseAction(myExecutor, content, myProject)); + actionGroup.add(new ContextHelpAction(myExecutor.getHelpId())); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index 5e6abb13560b..83f1c9dbe005 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -43,13 +43,8 @@ import com.intellij.execution.CantRunException; import com.intellij.execution.ExecutionException; import com.intellij.execution.ExecutionResult; import com.intellij.execution.Executor; -import com.intellij.execution.configurations.CommandLineState; import com.intellij.execution.configurations.RemoteConnection; -import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.configurations.RunProfileState; -import com.intellij.execution.filters.ExceptionFilters; -import com.intellij.execution.filters.Filter; -import com.intellij.execution.filters.TextConsoleBuilder; import com.intellij.execution.process.ProcessAdapter; import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessListener; @@ -1630,19 +1625,18 @@ public abstract class DebugProcessImpl implements DebugProcess { @Nullable public ExecutionResult attachVirtualMachine(final Executor executor, - final ProgramRunner runner, - final DebuggerSession session, - final RunProfileState state, - final RemoteConnection remoteConnection, - boolean pollConnection) throws ExecutionException { + final ProgramRunner runner, + final DebuggerSession session, + final RunProfileState state, + final RemoteConnection remoteConnection, + boolean pollConnection) throws ExecutionException { return attachVirtualMachine(new DefaultDebugEnvironment(myProject, - executor, - runner, - state.getRunnerSettings().getRunProfile(), - state, - null, - remoteConnection, - pollConnection), + executor, + runner, + state.getRunnerSettings().getRunProfile(), + state, + remoteConnection, + pollConnection), session); } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java index 0c70ebc4d89a..e44bb5145111 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java @@ -195,7 +195,6 @@ public class DebuggerManagerImpl extends DebuggerManagerEx { runner, profile, state, - null, remoteConnection, pollConnection)); } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java index d2b2c5898a7d..e3773a3b7865 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -41,7 +41,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; @@ -368,7 +367,6 @@ public class DebuggerSession implements AbstractDebuggerSession { runner, profile, state, - null, remoteConnection, pollConnection)); } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java index 1b49e59ecce6..9cb61ef6eaee 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java @@ -15,10 +15,7 @@ */ package com.intellij.debugger.ui; -import com.intellij.debugger.DebugEnvironment; -import com.intellij.debugger.DebuggerInvocationUtil; -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.DefaultDebugEnvironment; +import com.intellij.debugger.*; import com.intellij.debugger.engine.DebugProcessImpl; import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.impl.DebuggerContextListener; @@ -103,7 +100,7 @@ public class DebuggerPanelsManager implements ProjectComponent { RunContentDescriptor reuseContent, RemoteConnection remoteConnection, boolean pollConnection) throws ExecutionException { - return attachVirtualMachine(new DefaultDebugEnvironment(myProject, + return attachVirtualMachine(new DefaultDebugUIEnvironment(myProject, executor, runner, environment, @@ -114,8 +111,9 @@ public class DebuggerPanelsManager implements ProjectComponent { } @Nullable - public RunContentDescriptor attachVirtualMachine(DebugEnvironment environment) throws ExecutionException { - final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(myProject).attachVirtualMachine(environment); + public RunContentDescriptor attachVirtualMachine(DebugUIEnvironment environment) throws ExecutionException { + final DebugEnvironment modelEnvironment = environment.getEnvironment(); + final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(myProject).attachVirtualMachine(modelEnvironment); if (debuggerSession == null) { return null; } @@ -125,13 +123,13 @@ public class DebuggerPanelsManager implements ProjectComponent { debuggerSession.dispose(); return null; } - if (environment.isRemote()) { + if (modelEnvironment.isRemote()) { // optimization: that way BatchEvaluator will not try to lookup the class file in remote VM // which is an expensive operation when executed first time debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE); } - final DebuggerSessionTab sessionTab = new DebuggerSessionTab(myProject, environment.getSessionName(), environment.getIcon()); + final DebuggerSessionTab sessionTab = new DebuggerSessionTab(myProject, modelEnvironment.getSessionName(), environment.getIcon()); Disposer.register(myProject, sessionTab); RunContentDescriptor runContentDescriptor = sessionTab.attachToSession(debuggerSession, environment); RunContentDescriptor reuseContent = environment.getReuseContent(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java index 3c7b71981e16..2fc4c0b6caac 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java @@ -15,7 +15,7 @@ */ package com.intellij.debugger.ui; -import com.intellij.debugger.DebugEnvironment; +import com.intellij.debugger.DebugUIEnvironment; import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.actions.DebuggerActions; import com.intellij.debugger.engine.DebugProcessImpl; @@ -83,7 +83,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos private final MyDebuggerStateManager myStateManager = new MyDebuggerStateManager(); private final FramesPanel myFramesPanel; - private DebugEnvironment myEnvironment; + private DebugUIEnvironment myEnvironment; private final ThreadsPanel myThreadsPanel; private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump"; @@ -257,6 +257,8 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos } console.setActions(consoleActions, ActionPlaces.DEBUGGER_TOOLBAR, myConsole.getPreferredFocusableComponent()); + myEnvironment.initLogs(myRunContentDescriptor, getLogManager()); + DefaultActionGroup group = new DefaultActionGroup(); if (executionResult instanceof DefaultExecutionResult) { @@ -322,7 +324,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos addActionToGroup(group, PinToolwindowTabAction.ACTION_NAME); - myEnvironment.initContent(myRunContentDescriptor, getLogManager(), group); + myEnvironment.initActions(myRunContentDescriptor, group); myUi.getOptions().setLeftToolbar(group, ActionPlaces.DEBUGGER_TOOLBAR); @@ -373,7 +375,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos } public String getSessionName() { - return myEnvironment.getSessionName(); + return myEnvironment.getEnvironment().getSessionName(); } public DebuggerStateManager getContextManager() { @@ -416,7 +418,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos } } - public RunContentDescriptor attachToSession(final DebuggerSession session, DebugEnvironment environment) throws ExecutionException { + public RunContentDescriptor attachToSession(final DebuggerSession session, DebugUIEnvironment environment) throws ExecutionException { disposeSession(); myDebuggerSession = session; myEnvironment = environment;