From 03cd549b47c9ae68547cbee5d2a184823990057f Mon Sep 17 00:00:00 2001 From: "Olga.Lavrichenko" Date: Tue, 10 Jan 2023 21:51:59 +0000 Subject: [PATCH] DS-365 Show cell execution start time and duration GitOrigin-RevId: 9930321a64459060cc61e9508e49ca25ccf0f3e7 --- .../visualization/NotebookEditorAppearance.kt | 22 ++++++++++--------- .../NotebookLineMarkerRenderer.kt | 9 +++++--- .../components/InlayOutputProgressStatus.kt | 11 +++++++++- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookEditorAppearance.kt b/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookEditorAppearance.kt index 390fccf76769..491b9e7027dd 100644 --- a/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookEditorAppearance.kt +++ b/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookEditorAppearance.kt @@ -22,16 +22,17 @@ interface NotebookEditorAppearanceSizes { val LINE_NUMBERS_MARGIN: Int // TODO Do the pixel constants need JBUI.scale? - val COMMAND_MODE_CELL_LEFT_LINE_WIDTH : Int - val EDIT_MODE_CELL_LEFT_LINE_WIDTH : Int - val CODE_AND_CODE_TOP_GRAY_HEIGHT : Int - val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT : Int - val INNER_CELL_TOOLBAR_HEIGHT : Int - val CELL_BORDER_HEIGHT : Int - val SPACER_HEIGHT : Int - val SPACE_BELOW_CELL_TOOLBAR : Int - val CELL_TOOLBAR_TOTAL_HEIGHT : Int - val PROGRESS_STATUS_HEIGHT : Int + val COMMAND_MODE_CELL_LEFT_LINE_WIDTH: Int + val EDIT_MODE_CELL_LEFT_LINE_WIDTH: Int + val CODE_AND_CODE_TOP_GRAY_HEIGHT: Int + val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT: Int + val INNER_CELL_TOOLBAR_HEIGHT: Int + val CELL_BORDER_HEIGHT: Int + val SPACER_HEIGHT: Int + val EXECUTION_TIME_HEIGHT: Int + val SPACE_BELOW_CELL_TOOLBAR: Int + val CELL_TOOLBAR_TOTAL_HEIGHT: Int + val PROGRESS_STATUS_HEIGHT: Int val JUPYTER_CELL_SPACERS_INLAY_PRIORITY: Int val JUPYTER_BELOW_OUTPUT_CELL_SPACERS_INLAY_PRIORITY: Int @@ -88,6 +89,7 @@ object DefaultNotebookEditorAppearanceSizes: NotebookEditorAppearanceSizes { override val INNER_CELL_TOOLBAR_HEIGHT = 25 override val CELL_BORDER_HEIGHT = 20 override val SPACER_HEIGHT = CELL_BORDER_HEIGHT / 2 + override val EXECUTION_TIME_HEIGHT = SPACER_HEIGHT * 3 override val SPACE_BELOW_CELL_TOOLBAR = 12 override val CELL_TOOLBAR_TOTAL_HEIGHT = INNER_CELL_TOOLBAR_HEIGHT + SPACE_BELOW_CELL_TOOLBAR override val PROGRESS_STATUS_HEIGHT = 2 diff --git a/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookLineMarkerRenderer.kt b/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookLineMarkerRenderer.kt index 8551bef82107..d185713cf60a 100644 --- a/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookLineMarkerRenderer.kt +++ b/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/visualization/NotebookLineMarkerRenderer.kt @@ -44,12 +44,14 @@ class NotebookAboveCodeCellGutterLineMarkerRenderer(private val highlighter: Ran } } -class NotebookBelowCellCellGutterLineMarkerRenderer(private val highlighter: RangeHighlighter, inlayId: Long) : NotebookLineMarkerRenderer(inlayId) { +class NotebookBelowCellCellGutterLineMarkerRenderer(private val highlighter: RangeHighlighter, + inlayId: Long, + private val customHeight: Int) : NotebookLineMarkerRenderer(inlayId) { override fun paint(editor: Editor, g: Graphics, r: Rectangle) { editor as EditorImpl val lines = IntRange(editor.document.getLineNumber(highlighter.startOffset), editor.document.getLineNumber(highlighter.endOffset)) val inlayBounds = getInlayBounds(editor, lines) ?: return - paintNotebookCellBackgroundGutter(editor, g, r, lines, inlayBounds.y, editor.notebookAppearance.SPACER_HEIGHT) + paintNotebookCellBackgroundGutter(editor, g, r, lines, inlayBounds.y, customHeight) } } @@ -131,7 +133,8 @@ class NotebookTextCellBackgroundLineMarkerRenderer(private val highlighter: Rang } } -class NotebookCellToolbarGutterLineMarkerRenderer(private val highlighter: RangeHighlighter, inlayId: Long) : NotebookLineMarkerRenderer(inlayId) { +class NotebookCellToolbarGutterLineMarkerRenderer(private val highlighter: RangeHighlighter, inlayId: Long) : NotebookLineMarkerRenderer( + inlayId) { override fun paint(editor: Editor, g: Graphics, r: Rectangle) { editor as EditorImpl val lines = IntRange(editor.document.getLineNumber(highlighter.startOffset), editor.document.getLineNumber(highlighter.endOffset)) diff --git a/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/r/inlays/components/InlayOutputProgressStatus.kt b/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/r/inlays/components/InlayOutputProgressStatus.kt index c6347002c77e..e55e3b3ef1a2 100644 --- a/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/r/inlays/components/InlayOutputProgressStatus.kt +++ b/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/r/inlays/components/InlayOutputProgressStatus.kt @@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nls import org.jetbrains.plugins.notebooks.visualization.r.ui.UiCustomizer import java.awt.BorderLayout import java.awt.Color +import java.time.LocalDateTime import javax.swing.* private val TEXT_BORDER = JBUIScale.scale(5) @@ -18,7 +19,15 @@ enum class ProgressStatus { RUNNING, STOPPED_OK, STOPPED_ERROR } -data class InlayProgressStatus(val progress: ProgressStatus, @Nls val statusText: String = "") +/** + * @param previousStatusDateTime - date time, when previous status was set + * @param statusStartDateTime - date time, when status was set + */ +data class StatusDateTimeStamp(val previousStatusDateTime: LocalDateTime? = null, val statusStartDateTime: LocalDateTime) + +data class InlayProgressStatus(val progress: ProgressStatus, + @Nls val statusText: String = "", + val statusDateTimeStamp: StatusDateTimeStamp? = null) fun buildProgressStatusComponent(progressStatus: InlayProgressStatus, editor: Editor): JComponent? { if (progressStatus.progress == ProgressStatus.STOPPED_OK && progressStatus.statusText.isEmpty()) return null