allow to change watches when debugging is finished (IDEA-62216, WI-1691, WI-3255)

This commit is contained in:
nik
2011-03-16 14:34:17 +03:00
parent 77b4d82904
commit f0bf0224f9
9 changed files with 32 additions and 42 deletions
@@ -226,6 +226,10 @@ public class XDebugSessionImpl implements XDebugSession {
myDebugProcess.sessionInitialized();
}
public XDebugSessionData getSessionData() {
return mySessionData;
}
private void disableSlaveBreakpoints(final XDependentBreakpointManager dependentBreakpointManager) {
Set<XBreakpoint<?>> slaveBreakpoints = dependentBreakpointManager.getAllSlaveBreakpoints();
Set<XBreakpointType<?, ?>> breakpointTypes = new HashSet<XBreakpointType<?, ?>>();
@@ -62,7 +62,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
@NonNls public static final String COMPONENT_NAME = "XDebuggerManager";
private final Project myProject;
private final XBreakpointManagerImpl myBreakpointManager;
private final Map<ProcessHandler, XDebugSessionData> mySessionData;
private final Map<RunContentDescriptor, XDebugSessionData> mySessionData;
private final Map<ProcessHandler, XDebugSessionImpl> mySessions;
private final ExecutionPointHighlighter myExecutionPointHighlighter;
private XDebugSessionImpl myActiveSession;
@@ -70,7 +70,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
public XDebuggerManagerImpl(final Project project, final StartupManager startupManager, MessageBus messageBus) {
myProject = project;
myBreakpointManager = new XBreakpointManagerImpl(project, this, startupManager);
mySessionData = new LinkedHashMap<ProcessHandler, XDebugSessionData>();
mySessionData = new HashMap<RunContentDescriptor, XDebugSessionData>();
mySessions = new LinkedHashMap<ProcessHandler, XDebugSessionImpl>();
myExecutionPointHighlighter = new ExecutionPointHighlighter(project);
messageBus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@@ -99,6 +99,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
@Override
public void contentRemoved(RunContentDescriptor descriptor, @NotNull Executor executor) {
if (executor.equals(DefaultDebugExecutor.getDebugExecutorInstance())) {
mySessionData.remove(descriptor);
XDebugSessionImpl session = mySessions.remove(descriptor.getProcessHandler());
if (session != null) {
Disposer.dispose(session.getSessionTab());
@@ -172,7 +173,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
final XDebugSessionImpl session) throws ExecutionException {
XDebugProcess process = processStarter.start(session);
XDebugSessionData oldSessionData = contentToReuse != null ? mySessionData.remove(contentToReuse.getProcessHandler()) : null;
XDebugSessionData oldSessionData = contentToReuse != null ? mySessionData.get(contentToReuse) : null;
if (oldSessionData == null) {
oldSessionData = new XDebugSessionData();
}
@@ -184,10 +185,9 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
public void removeSession(@NotNull XDebugSessionImpl session) {
XDebugSessionTab sessionTab = session.getSessionTab();
mySessions.remove(session);
mySessions.remove(session.getDebugProcess().getProcessHandler());
if (sessionTab != null) {
XDebugSessionData data = sessionTab.saveData();
mySessionData.put(session.getDebugProcess().getProcessHandler(), data);
mySessionData.put(sessionTab.getRunContentDescriptor(), session.getSessionData());
}
if (myActiveSession == session) {
myActiveSession = null;
@@ -21,6 +21,7 @@ import com.intellij.ide.dnd.DnDNativeTarget;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
@@ -53,9 +54,11 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
private XDebuggerTreeState myTreeState;
private XDebuggerTreeRestorer myTreeRestorer;
private final WatchesRootNode myRootNode;
private final XDebugSessionData mySessionData;
public XWatchesView(final XDebugSession session, final Disposable parentDisposable, final XDebugSessionData sessionData) {
super(session, parentDisposable);
mySessionData = sessionData;
myTreePanel = new XDebuggerTreePanel(session, session.getDebugProcess().getEditorsProvider(), this, null,
XDebuggerActions.WATCHES_TREE_POPUP_GROUP);
@@ -86,6 +89,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
evaluator = stackFrame.getEvaluator();
}
myRootNode.addWatchExpression(evaluator, expression, index);
updateSessionData();
}
protected void rebuildView(final SessionEvent event) {
@@ -147,9 +151,10 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
WatchNode node = minIndex < newChildren.size() ? newChildren.get(minIndex) : newChildren.get(newChildren.size() - 1);
TreeUtil.selectNode(myTreePanel.getTree(), node);
}
updateSessionData();
}
public List<String> getWatchExpressions() {
private void updateSessionData() {
List<String> watchExpressions = new ArrayList<String>();
final List<? extends WatchNode> children = myRootNode.getAllChildren();
if (children != null) {
@@ -157,7 +162,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
watchExpressions.add(child.getExpression());
}
}
return watchExpressions;
mySessionData.setWatchExpressions(ArrayUtil.toStringArray(watchExpressions));
}
public boolean update(final DnDEvent aEvent) {
@@ -18,8 +18,8 @@ package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import java.util.List;
@@ -34,10 +34,6 @@ public class XEditWatchAction extends XWatchesTreeActionBase {
super.update(e);
}
protected boolean isEnabled(final AnActionEvent e) {
return true;
}
public void actionPerformed(final AnActionEvent e) {
XDebuggerTree tree = XDebuggerTree.getTree(e);
if (tree == null) return;
@@ -34,8 +34,4 @@ public class XNewWatchAction extends XWatchesTreeActionBase {
watchesRoot.addNewWatch();
}
}
protected boolean isEnabled(final AnActionEvent e) {
return XDebuggerTree.getTree(e) != null;
}
}
@@ -20,6 +20,7 @@ import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -27,10 +28,8 @@ import java.util.List;
* @author nik
*/
public class XRemoveWatchAction extends XWatchesTreeActionBase {
protected boolean isEnabled(final AnActionEvent e) {
XDebuggerTree tree = XDebuggerTree.getTree(e);
return tree != null && !getSelectedNodes(tree, XDebuggerTreeNode.class).isEmpty();
protected boolean isEnabled(final AnActionEvent e, @NotNull XDebuggerTree tree) {
return !getSelectedNodes(tree, XDebuggerTreeNode.class).isEmpty();
}
@@ -45,15 +45,11 @@ public abstract class XWatchesTreeActionBase extends AnAction {
public void update(final AnActionEvent e) {
final XDebuggerTree tree = XDebuggerTree.getTree(e);
boolean enabled;
if (tree == null || tree.getSession().isStopped()) {
enabled = false;
}
else {
enabled = isEnabled(e);
}
boolean enabled = tree != null && isEnabled(e, tree);
e.getPresentation().setEnabled(enabled);
}
protected abstract boolean isEnabled(AnActionEvent e);
protected boolean isEnabled(AnActionEvent e, @NotNull XDebuggerTree tree) {
return true;
}
}
@@ -31,6 +31,10 @@ public class XDebugSessionData {
this(ArrayUtil.EMPTY_STRING_ARRAY);
}
public void setWatchExpressions(String[] watchExpressions) {
myWatchExpressions = watchExpressions;
}
public String[] getWatchExpressions() {
return myWatchExpressions;
}
@@ -40,7 +40,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
import com.intellij.util.ArrayUtil;
import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
@@ -115,19 +114,10 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
return framesContent;
}
public XDebugSessionData saveData() {
final List<String> watchExpressions = myWatchesView.getWatchExpressions();
return new XDebugSessionData(ArrayUtil.toStringArray(watchExpressions));
}
public ExecutionConsole getConsole() {
return myConsole;
}
public String getSessionName() {
return mySessionName;
}
public void rebuildViews() {
for (XDebugViewBase view : myViews) {
view.rebuildView();
@@ -144,7 +134,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
final XDebugProcess debugProcess = session.getDebugProcess();
ProcessHandler processHandler = debugProcess.getProcessHandler();
myConsole = consoleView;
myRunContentDescriptor = new RunContentDescriptor(myConsole, processHandler, myUi.getComponent(), getSessionName());
myRunContentDescriptor = new RunContentDescriptor(myConsole, processHandler, myUi.getComponent(), mySessionName);
myUi.addContent(createFramesContent(session), 0, PlaceInGrid.left, false);
myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);
@@ -153,7 +143,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
myUi.addContent(consoleContent, 1, PlaceInGrid.bottom, false);
attachNotificationTo(consoleContent);
session.getDebugProcess().registerAdditionalContent(myUi);
debugProcess.registerAdditionalContent(myUi);
RunContentBuilder.addAdditionalConsoleEditorActions(myConsole, consoleContent);
myUi.addContent(consoleContent, 0, PlaceInGrid.bottom, false);
@@ -209,7 +199,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
final XDebugProcess debugProcess = session.getDebugProcess();
ProcessHandler processHandler = debugProcess.getProcessHandler();
myConsole = consoleView;
myRunContentDescriptor = new RunContentDescriptor(myConsole, processHandler, myUi.getComponent(), getSessionName());
myRunContentDescriptor = new RunContentDescriptor(myConsole, processHandler, myUi.getComponent(), mySessionName);
myUi.addContent(createFramesContent(session), 0, PlaceInGrid.left, false);
myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);