mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[PyCharm] PY-73685 Fixed - execution state does not disappear with cell moving
GitOrigin-RevId: 4b107a70b458751cd749cb38d42fc16277a6f96b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6ae81f5908
commit
09c2ab97bc
@@ -26,6 +26,10 @@ class NotebookBelowCellDelimiterPanel(
|
||||
private val cellTags: List<String>,
|
||||
val cellNum: Int,
|
||||
isRenderedMarkdown: Boolean,
|
||||
executionCount: Int?,
|
||||
initStatusIcon: Icon?,
|
||||
initTooltipText: String?,
|
||||
initExecutionDurationText: String?
|
||||
) : JPanel(BorderLayout()) {
|
||||
private val notebookAppearance = editor.notebookAppearance
|
||||
private val plusTagButtonSize = JBUI.scale(18)
|
||||
@@ -43,10 +47,11 @@ class NotebookBelowCellDelimiterPanel(
|
||||
init {
|
||||
updateBackgroundColor()
|
||||
border = BorderFactory.createEmptyBorder(delimiterHeight, 0, delimiterHeight, 0)
|
||||
cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)
|
||||
|
||||
val addingTagsRow = (cellTags.isNotEmpty() && !isRenderedMarkdown && Registry.`is`("jupyter.cell.metadata.tags", false))
|
||||
|
||||
if (addingTagsRow) add(createTagsRow(), BorderLayout.EAST) // PY-72712
|
||||
updateExecutionStatus(initTooltipText, executionCount, initStatusIcon, initExecutionDurationText) // PY-73685
|
||||
}
|
||||
|
||||
private fun createExecutionLabel(): JLabel {
|
||||
@@ -64,7 +69,6 @@ class NotebookBelowCellDelimiterPanel(
|
||||
return labelText
|
||||
}
|
||||
|
||||
@Suppress("HardCodedStringLiteral")
|
||||
private fun createTagsRow(): Box {
|
||||
val tagsRow = Box.createHorizontalBox()
|
||||
val plusActionToolbar = createAddTagButton()
|
||||
@@ -82,7 +86,7 @@ class NotebookBelowCellDelimiterPanel(
|
||||
private fun createAddTagButton(): JButton? {
|
||||
// todo: refactor
|
||||
// ideally, a toolbar with a single action and targetComponent this should've done that
|
||||
// however, the toolbar max height must be not greater than 18, which seemed to be untrivial
|
||||
// however, the toolbar max height must be not greater than 18, which seemed to be non-trivial
|
||||
val action = ActionManager.getInstance().getAction("JupyterCellAddTagInlayAction") ?: return null
|
||||
val originalIcon = AllIcons.Expui.General.Add
|
||||
val transparentIcon = IconLoader.getTransparentIcon(originalIcon)
|
||||
@@ -100,16 +104,9 @@ class NotebookBelowCellDelimiterPanel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createAddTagButtonHoverListener(originalIcon: Icon, transparentIcon: Icon): MouseAdapter {
|
||||
return object : MouseAdapter() {
|
||||
override fun mouseEntered(e: MouseEvent) {
|
||||
(e.source as JButton).icon = originalIcon
|
||||
}
|
||||
|
||||
override fun mouseExited(e: MouseEvent) {
|
||||
(e.source as JButton).icon = transparentIcon
|
||||
}
|
||||
}
|
||||
private fun createAddTagButtonHoverListener(originalIcon: Icon, transparentIcon: Icon) = object : MouseAdapter() {
|
||||
override fun mouseEntered(e: MouseEvent) { (e.source as JButton).icon = originalIcon }
|
||||
override fun mouseExited(e: MouseEvent) { (e.source as JButton).icon = transparentIcon }
|
||||
}
|
||||
|
||||
private fun createAddTagButtonActionListener(action: AnAction): ActionListener {
|
||||
@@ -144,13 +141,15 @@ class NotebookBelowCellDelimiterPanel(
|
||||
super.updateUI()
|
||||
}
|
||||
|
||||
fun updateExecutionStatus(@Nls tooltipText: String?, executionCount: Int?, statusIcon: Icon?, @Nls executionDurationText: String?) {
|
||||
fun updateExecutionStatus(
|
||||
@NlsSafe tooltipText: String?, executionCount: Int?, statusIcon: Icon?, @NlsSafe executionDurationText: String?
|
||||
) {
|
||||
val showStatus = isExecutionCountDefined(executionCount) || (tooltipText != null && statusIcon != AllIcons.Expui.General.GreenCheckmark)
|
||||
if (showStatus) {
|
||||
getOrCreateExecutionLabel().apply {
|
||||
text = getExecutionLabelText(executionCount, executionDurationText)
|
||||
icon = statusIcon
|
||||
this.toolTipText = tooltipText
|
||||
toolTipText = tooltipText
|
||||
}
|
||||
} else {
|
||||
executionLabel?.let { remove(it) }
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.intellij.openapi.actionSystem.ActionGroup
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.ui.Gray
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.ui.PopupHandler
|
||||
import com.intellij.util.ui.JBFont
|
||||
import com.intellij.util.ui.JBUI
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.awt.Component
|
||||
import java.awt.Graphics
|
||||
import java.awt.Graphics2D
|
||||
@@ -17,7 +17,7 @@ import java.awt.RenderingHints
|
||||
import javax.swing.BorderFactory
|
||||
import javax.swing.JLabel
|
||||
|
||||
class NotebookCellTagLabel(@Nls val tag: String, val cellNum: Int) : JLabel(tag) { // PY-72712
|
||||
class NotebookCellTagLabel(@NlsSafe val tag: String, val cellNum: Int) : JLabel(tag) { // PY-72712
|
||||
private var backgroundColor = JBColor.namedColor("Tag.background", Gray.xDF)
|
||||
private var foregroundColor = JBColor.BLACK
|
||||
|
||||
|
||||
Reference in New Issue
Block a user