From c23dca86ce8ef0c800e37feb88d20dbbd118fa87 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Tue, 14 Jun 2016 18:40:47 +0300 Subject: [PATCH] Change thread icon when stopped at breakpoint (PY-2431) --- .../python/debugger/PyExecutionStack.java | 8 ++++++++ .../python/debugger/PySuspendContext.java | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/python/debugger/PyExecutionStack.java b/python/src/com/jetbrains/python/debugger/PyExecutionStack.java index 573ae7a2c5b5..b9e1942cff15 100644 --- a/python/src/com/jetbrains/python/debugger/PyExecutionStack.java +++ b/python/src/com/jetbrains/python/debugger/PyExecutionStack.java @@ -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) { diff --git a/python/src/com/jetbrains/python/debugger/PySuspendContext.java b/python/src/com/jetbrains/python/debugger/PySuspendContext.java index a3bcfa77b870..3167927388c7 100644 --- a/python/src/com/jetbrains/python/debugger/PySuspendContext.java +++ b/python/src/com/jetbrains/python/debugger/PySuspendContext.java @@ -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; }