Change thread icon when stopped at breakpoint (PY-2431)

This commit is contained in:
Elizaveta Shashkova
2016-06-14 18:42:04 +03:00
parent 14e6fde73d
commit c23dca86ce
2 changed files with 23 additions and 2 deletions
@@ -18,7 +18,9 @@ package com.jetbrains.python.debugger;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XStackFrame;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -36,6 +38,12 @@ public class PyExecutionStack extends XExecutionStack {
myThreadInfo = threadInfo;
}
public PyExecutionStack(@NotNull final PyDebugProcess debugProcess, @NotNull final PyThreadInfo threadInfo, final @Nullable Icon icon) {
super(threadInfo.getName(), icon);
myDebugProcess = debugProcess;
myThreadInfo = threadInfo;
}
@Override
public PyStackFrame getTopFrame() {
if (myTopFrame == null) {
@@ -15,10 +15,13 @@
*/
package com.jetbrains.python.debugger;
import com.intellij.icons.AllIcons;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XSuspendContext;
import com.jetbrains.python.debugger.pydev.AbstractCommand;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Collection;
@@ -29,7 +32,7 @@ public class PySuspendContext extends XSuspendContext {
public PySuspendContext(@NotNull final PyDebugProcess debugProcess, @NotNull final PyThreadInfo threadInfo) {
myDebugProcess = debugProcess;
myActiveStack = new PyExecutionStack(debugProcess, threadInfo);
myActiveStack = new PyExecutionStack(debugProcess, threadInfo, getThreadIcon(threadInfo));
}
@Override
@@ -38,6 +41,16 @@ public class PySuspendContext extends XSuspendContext {
return myActiveStack;
}
@NotNull
public static Icon getThreadIcon(@NotNull PyThreadInfo threadInfo) {
if ((threadInfo.getState() == PyThreadInfo.State.SUSPENDED) && (threadInfo.getStopReason() == AbstractCommand.SET_BREAKPOINT)) {
return AllIcons.Debugger.ThreadAtBreakpoint;
}
else {
return AllIcons.Debugger.ThreadSuspended;
}
}
@NotNull
@Override
public XExecutionStack[] getExecutionStacks() {
@@ -49,7 +62,7 @@ public class PySuspendContext extends XSuspendContext {
XExecutionStack[] stacks = new XExecutionStack[threads.size()];
int i = 0;
for (PyThreadInfo thread : threads) {
stacks[i++] = new PyExecutionStack(myDebugProcess, thread);
stacks[i++] = new PyExecutionStack(myDebugProcess, thread, getThreadIcon(thread));
}
return stacks;
}