From fe6e325fad4af671a9231dab45ea998701bcb578 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Wed, 6 Aug 2014 17:26:55 +0400 Subject: [PATCH] xdebugger: reuse toolwindow activation if needed --- .../com/intellij/xdebugger/impl/XDebugSessionImpl.java | 10 +++++----- .../intellij/xdebugger/impl/XDebuggerManagerImpl.java | 7 ++++--- .../intellij/xdebugger/impl/ui/XDebugSessionTab.java | 6 +++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 762855510a1e..d7cb066507fc 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -262,7 +262,7 @@ public class XDebugSessionImpl implements XDebugSession { return myCurrentPosition; } - public XDebugSessionTab init(final XDebugProcess process, @NotNull final XDebugSessionData sessionData) { + public XDebugSessionTab init(@NotNull XDebugProcess process, @NotNull XDebugSessionData sessionData, @Nullable RunContentDescriptor contentToReuse) { LOG.assertTrue(myDebugProcess == null); myDebugProcess = process; mySessionData = sessionData; @@ -280,7 +280,7 @@ public class XDebugSessionImpl implements XDebugSession { //todo[nik] make 'createConsole()' method return ConsoleView myConsoleView = (ConsoleView)myDebugProcess.createConsole(); if (!myShowTabOnSuspend) { - initSessionTab(); + initSessionTab(contentToReuse); } return mySessionTab; @@ -319,8 +319,8 @@ public class XDebugSessionImpl implements XDebugSession { return mySessionTab.getUi(); } - private void initSessionTab() { - mySessionTab = new XDebugSessionTab(myProject, this, myIcon, myEnvironment, myRunner); + private void initSessionTab(@Nullable RunContentDescriptor contentToReuse) { + mySessionTab = new XDebugSessionTab(myProject, this, myIcon, myEnvironment, myRunner, contentToReuse); myDebugProcess.sessionInitialized(); } @@ -799,7 +799,7 @@ public class XDebugSessionImpl implements XDebugSession { public void run() { if (myShowTabOnSuspend) { myShowTabOnSuspend = false; - initSessionTab(); + initSessionTab(null); showSessionTab(); } if (myCurrentPosition != null) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index b974150d2c56..c7b8af0236f6 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -206,8 +206,9 @@ public class XDebuggerManagerImpl extends XDebuggerManager return session; } - private XDebugSessionImpl startSession(final RunContentDescriptor contentToReuse, final XDebugProcessStarter processStarter, - final XDebugSessionImpl session) throws ExecutionException { + private XDebugSessionImpl startSession(@Nullable RunContentDescriptor contentToReuse, + @NotNull XDebugProcessStarter processStarter, + @NotNull XDebugSessionImpl session) throws ExecutionException { XDebugProcess process = processStarter.start(session); myProject.getMessageBus().syncPublisher(TOPIC).processStarted(process); @@ -222,7 +223,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager ((XDebugProcessConfiguratorStarter)processStarter).configure(oldSessionData); } - session.init(process, oldSessionData); + session.init(process, oldSessionData, contentToReuse); mySessions.put(session.getDebugProcess().getProcessHandler(), session); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java index 4b6bea217c54..a41a716062cc 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java @@ -68,7 +68,8 @@ public class XDebugSessionTab extends DebuggerSessionTabBase { @NotNull XDebugSessionImpl session, @Nullable Icon icon, @Nullable ExecutionEnvironment environment, - @Nullable ProgramRunner runner) { + @Nullable ProgramRunner runner, + @Nullable RunContentDescriptor contentToReuse) { super(project, "Debug", session.getSessionName(), GlobalSearchScope.allScope(project)); if (environment != null) { setEnvironment(environment); @@ -76,6 +77,9 @@ public class XDebugSessionTab extends DebuggerSessionTabBase { myConsole = session.getConsoleView(); XDebugProcess debugProcess = session.getDebugProcess(); myRunContentDescriptor = new RunContentDescriptor(myConsole, debugProcess.getProcessHandler(), myUi.getComponent(), mySessionName, icon); + if (contentToReuse != null && contentToReuse.isReuseToolWindowActivation()) { + myRunContentDescriptor.setActivateToolWindowWhenAdded(contentToReuse.isActivateToolWindowWhenAdded()); + } attachToSession(session, runner, environment, session.getSessionData(), debugProcess); }