summaryrefslogtreecommitdiff
path: root/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java')
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java204
1 files changed, 119 insertions, 85 deletions
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..4c3766f23f5d 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -17,11 +17,8 @@ package com.intellij.xdebugger.impl.ui;
import com.intellij.debugger.ui.DebuggerContentInfo;
import com.intellij.execution.Executor;
-import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
-import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.runners.RestartAction;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
@@ -29,11 +26,11 @@ import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.execution.ui.layout.PlaceInGrid;
import com.intellij.execution.ui.layout.impl.ViewImpl;
import com.intellij.icons.AllIcons;
+import com.intellij.ide.DataManager;
import com.intellij.ide.actions.ContextHelpAction;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.AppUIUtil;
@@ -41,7 +38,7 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManagerAdapter;
import com.intellij.ui.content.ContentManagerEvent;
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
-import com.intellij.xdebugger.XDebugProcess;
+import com.intellij.util.SystemProperties;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
@@ -57,29 +54,109 @@ import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
-/**
- * @author spleaner
- */
public class XDebugSessionTab extends DebuggerSessionTabBase {
+ private static final DataKey<XDebugSessionTab> TAB_KEY = DataKey.create("XDebugSessionTab");
+
private XWatchesViewImpl myWatchesView;
private final List<XDebugView> myViews = new ArrayList<XDebugView>();
- public XDebugSessionTab(@NotNull Project project,
- @NotNull XDebugSessionImpl session,
- @Nullable Icon icon,
- @Nullable ExecutionEnvironment environment,
- @Nullable ProgramRunner runner) {
- super(project, "Debug", session.getSessionName(), GlobalSearchScope.allScope(project));
+ @Nullable
+ private XDebugSessionImpl mySession;
+ private XDebugSessionData mySessionData;
+
+ @NotNull
+ public static XDebugSessionTab create(@NotNull XDebugSessionImpl session,
+ @Nullable Icon icon,
+ @Nullable ExecutionEnvironment environment,
+ @Nullable RunContentDescriptor contentToReuse) {
+ if (contentToReuse != null && SystemProperties.getBooleanProperty("xdebugger.reuse.session.tab", false)) {
+ JComponent component = contentToReuse.getComponent();
+ if (component != null) {
+ XDebugSessionTab oldTab = TAB_KEY.getData(DataManager.getInstance().getDataContext(component));
+ if (oldTab != null) {
+ oldTab.setSession(session, environment, icon);
+ oldTab.attachToSession(session);
+ return oldTab;
+ }
+ }
+ }
+ return new XDebugSessionTab(session, icon, environment);
+ }
+
+ private XDebugSessionTab(@NotNull XDebugSessionImpl session,
+ @Nullable Icon icon,
+ @Nullable ExecutionEnvironment environment) {
+ super(session.getProject(), "Debug", session.getSessionName(), GlobalSearchScope.allScope(session.getProject()));
+
+ setSession(session, environment, icon);
+
+ myUi.addContent(createFramesContent(), 0, PlaceInGrid.left, false);
+ myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);
+ myUi.addContent(createWatchesContent(session), 0, PlaceInGrid.right, false);
+
+ for (XDebugView view : myViews) {
+ Disposer.register(this, view);
+ }
+
+ attachToSession(session);
+
+ DefaultActionGroup focus = new DefaultActionGroup();
+ focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT));
+ myUi.getOptions().setAdditionalFocusActions(focus);
+
+ myUi.addListener(new ContentManagerAdapter() {
+ @Override
+ public void selectionChanged(ContentManagerEvent event) {
+ Content content = event.getContent();
+ XDebugSessionImpl session = mySession;
+ if (session != null && content.isSelected() && DebuggerContentInfo.WATCHES_CONTENT.equals(ViewImpl.ID.get(content))) {
+ if (myWatchesView.rebuildNeeded()) {
+ myWatchesView.processSessionEvent(XDebugView.SessionEvent.SETTINGS_CHANGED);
+ }
+ }
+ }
+ }, this);
+
+ rebuildViews();
+ }
+
+ private void setSession(@NotNull XDebugSessionImpl session, @Nullable ExecutionEnvironment environment, @Nullable Icon icon) {
if (environment != null) {
setEnvironment(environment);
}
+
+ mySession = session;
+ mySessionData = session.getSessionData();
myConsole = session.getConsoleView();
- XDebugProcess debugProcess = session.getDebugProcess();
- myRunContentDescriptor = new RunContentDescriptor(myConsole, debugProcess.getProcessHandler(), myUi.getComponent(), mySessionName, icon);
- attachToSession(session, runner, environment, session.getSessionData(), debugProcess);
+ myRunContentDescriptor = new RunContentDescriptor(myConsole, session.getDebugProcess().getProcessHandler(), myUi.getComponent(), session.getSessionName(), icon);
}
- private Content createVariablesContent(final XDebugSession session) {
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (XWatchesView.DATA_KEY.is(dataId)) {
+ return myWatchesView;
+ }
+ else if (TAB_KEY.is(dataId)) {
+ return this;
+ }
+ else if (XDebugSessionData.DATA_KEY.is(dataId)) {
+ return mySessionData;
+ }
+
+ if (mySession != null) {
+ if (XDebugSession.DATA_KEY.is(dataId)) {
+ return mySession;
+ }
+ else if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
+ return mySession.getConsoleView();
+ }
+ }
+
+ return super.getData(dataId);
+ }
+
+ private Content createVariablesContent(@NotNull XDebugSessionImpl session) {
final XVariablesView variablesView = new XVariablesView(session);
myViews.add(variablesView);
Content result = myUi.createContent(DebuggerContentInfo.VARIABLES_CONTENT, variablesView.getPanel(),
@@ -89,27 +166,25 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
ActionGroup group = getCustomizedActionGroup(XDebuggerActions.VARIABLES_TREE_TOOLBAR_GROUP);
result.setActions(group, ActionPlaces.DEBUGGER_TOOLBAR, variablesView.getTree());
-
return result;
}
- private Content createWatchesContent(final XDebugSessionImpl session, final XDebugSessionData sessionData) {
+ private Content createWatchesContent(@NotNull XDebugSessionImpl session) {
myWatchesView = new XWatchesViewImpl(session);
myViews.add(myWatchesView);
Content watchesContent = myUi.createContent(DebuggerContentInfo.WATCHES_CONTENT, myWatchesView.getMainPanel(),
- XDebuggerBundle.message("debugger.session.tab.watches.title"), AllIcons.Debugger.Watches, null);
+ XDebuggerBundle.message("debugger.session.tab.watches.title"), AllIcons.Debugger.Watches, null);
watchesContent.setCloseable(false);
-
return watchesContent;
}
- private Content createFramesContent(final XDebugSession session) {
- final XFramesView framesView = new XFramesView(session);
+ @NotNull
+ private Content createFramesContent() {
+ XFramesView framesView = new XFramesView(getProject());
myViews.add(framesView);
Content framesContent = myUi.createContent(DebuggerContentInfo.FRAME_CONTENT, framesView.getMainPanel(),
XDebuggerBundle.message("debugger.session.tab.frames.title"), AllIcons.Debugger.Frame, null);
framesContent.setCloseable(false);
-
return framesContent;
}
@@ -132,34 +207,12 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
return myWatchesView;
}
- private void attachToSession(final @NotNull XDebugSessionImpl session, final @Nullable ProgramRunner runner,
- final @Nullable ExecutionEnvironment environment, final @NotNull XDebugSessionData sessionData,
- final @NotNull XDebugProcess debugProcess) {
- myUi.addContent(createFramesContent(session), 0, PlaceInGrid.left, false);
- myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);
- myUi.addContent(createWatchesContent(session, sessionData), 0, PlaceInGrid.right, false);
+ private void attachToSession(@NotNull XDebugSessionImpl session) {
for (XDebugView view : myViews) {
- Disposer.register(this, view);
- session.addSessionListener(new XDebugViewSessionListener(view, getProject()), this);
+ session.addSessionListener(new XDebugViewSessionListener(view, session), this);
}
- myUi.getContentManager().addDataProvider(new DataProvider() {
- @Nullable
- @Override
- public Object getData(@NonNls String dataId) {
- if (XWatchesView.DATA_KEY.is(dataId)) {
- return myWatchesView;
- }
- if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
- return session.getConsoleView();
- }
- if (XDebugSessionData.DATA_KEY.is(dataId)) {
- return sessionData;
- }
- return null;
- }
- });
- XDebugTabLayouter layouter = debugProcess.createTabLayouter();
+ XDebugTabLayouter layouter = session.getDebugProcess().createTabLayouter();
Content consoleContent = layouter.registerConsoleContent(myUi, myConsole);
attachNotificationTo(consoleContent);
@@ -172,18 +225,15 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
DefaultActionGroup leftToolbar = new DefaultActionGroup();
final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
- final Executor executor = environment != null ? environment.getExecutor() : debugExecutor;
- if (runner != null && environment != null) {
- RestartAction restartAction = new RestartAction(executor, runner, myRunContentDescriptor, environment);
- leftToolbar.add(restartAction);
- restartAction.registerShortcut(myUi.getComponent());
-
+ ExecutionEnvironment environment = getEnvironment();
+ if (environment != null) {
List<AnAction> additionalRestartActions = session.getRestartActions();
- leftToolbar.addAll(additionalRestartActions);
- if (!additionalRestartActions.isEmpty()) leftToolbar.addSeparator();
+ if (!additionalRestartActions.isEmpty()) {
+ leftToolbar.addAll(additionalRestartActions);
+ leftToolbar.addSeparator();
+ }
leftToolbar.addAll(session.getExtraActions());
}
-
leftToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
for (AnAction action : session.getExtraStopActions()) {
@@ -216,7 +266,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
if (commonSettings.length > 0) {
settings.addSeparator();
}
- if (!debugProcess.isValuesCustomSorted()) {
+ if (!session.getDebugProcess().isValuesCustomSorted()) {
settings.add(new ToggleSortValuesAction(commonSettings.length == 0));
}
@@ -225,41 +275,25 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
leftToolbar.addSeparator();
leftToolbar.add(PinToolwindowTabAction.getPinAction());
- leftToolbar.add(new CloseAction(executor, myRunContentDescriptor, getProject()));
+ leftToolbar.add(new CloseAction(environment != null ? environment.getExecutor() : debugExecutor, myRunContentDescriptor, getProject()));
leftToolbar.add(new ContextHelpAction(debugExecutor.getHelpId()));
DefaultActionGroup topToolbar = new DefaultActionGroup();
topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
- debugProcess.registerAdditionalActions(leftToolbar, topToolbar);
+ session.getDebugProcess().registerAdditionalActions(leftToolbar, topToolbar);
myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
if (environment != null) {
- final RunProfile runConfiguration = environment.getRunProfile();
- registerFileMatcher(runConfiguration);
- initLogConsoles(runConfiguration, myRunContentDescriptor.getProcessHandler(), myConsole);
+ initLogConsoles(environment.getRunProfile(), myRunContentDescriptor.getProcessHandler(), myConsole);
}
-
- final DefaultActionGroup focus = new DefaultActionGroup();
- focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT));
- myUi.getOptions().setAdditionalFocusActions(focus);
-
- myUi.addListener(new ContentManagerAdapter() {
- @Override
- public void selectionChanged(ContentManagerEvent event) {
- Content content = event.getContent();
- if (content.isSelected() && DebuggerContentInfo.WATCHES_CONTENT.equals(content.getUserData(ViewImpl.ID))) {
- if (myWatchesView.rebuildNeeded()) {
- myWatchesView.processSessionEvent(XDebugView.SessionEvent.SETTINGS_CHANGED);
- }
- }
- }
- }, this);
-
- rebuildViews();
}
+ public void detachFromSession() {
+ assert mySession != null;
+ mySession = null;
+ }
@Override
@Nullable
@@ -283,4 +317,4 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
}
}
}
-} \ No newline at end of file
+}