From f70b02b76db7b82a82eb3f2ec683b2dbc1891ff6 Mon Sep 17 00:00:00 2001 From: "anna.gromova" Date: Thu, 2 Dec 2021 16:57:09 +0300 Subject: [PATCH] RIDER-70060 info state GitOrigin-RevId: 9d5e74e91894b4e41819fb4575a703b09455b7e7 --- .../runToolbar/RunToolbarMainSlotActive.kt | 29 ++--- .../RunToolbarMainSlotInfoAction.kt | 117 +++++++++++------- .../runToolbar/RunToolbarPopupController.kt | 1 - .../RunToolbarProcessStartedAction.kt | 21 +--- .../RunToolbarRunConfigurationsAction.kt | 25 +--- .../components/MouseListenerHelper.kt | 33 +++++ .../runToolbar/components/ProcessesByType.kt | 59 +++++++++ .../components/TrimmedMiddleLabel.kt | 6 +- .../messages/ExecutionBundle.properties | 9 +- .../execution/runToolbar/RunToolbarProcess.kt | 1 + .../runToolbar/RunToolbarRunProcess.kt | 5 +- .../segmentedActionBar/SegmentedBarPainter.kt | 45 ++++--- .../impl/runToolbar/RunToolbarDebugProcess.kt | 10 +- 13 files changed, 216 insertions(+), 145 deletions(-) create mode 100644 platform/execution-impl/src/com/intellij/execution/runToolbar/components/MouseListenerHelper.kt create mode 100644 platform/execution-impl/src/com/intellij/execution/runToolbar/components/ProcessesByType.kt diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotActive.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotActive.kt index 28111f00a55d..7bfc0c1fb51d 100644 --- a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotActive.kt +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotActive.kt @@ -2,6 +2,7 @@ package com.intellij.execution.runToolbar import com.intellij.execution.runToolbar.RunToolbarProcessStartedAction.Companion.PROP_ACTIVE_ENVIRONMENT +import com.intellij.execution.runToolbar.components.MouseListenerHelper import com.intellij.execution.runToolbar.components.TrimmedMiddleLabel import com.intellij.icons.AllIcons import com.intellij.idea.ActionsBundle @@ -12,16 +13,16 @@ import com.intellij.openapi.actionSystem.impl.segmentedActionBar.SegmentedCustom import com.intellij.openapi.actionSystem.impl.segmentedActionBar.SegmentedCustomPanel import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.Key -import com.intellij.ui.JBColor import com.intellij.util.ui.JBDimension import com.intellij.util.ui.UIUtil import net.miginfocom.swing.MigLayout import java.awt.Dimension import java.awt.Font -import java.awt.event.MouseAdapter -import java.awt.event.MouseEvent import java.beans.PropertyChangeEvent -import javax.swing.* +import javax.swing.Icon +import javax.swing.JLabel +import javax.swing.JPanel +import javax.swing.UIManager class RunToolbarMainSlotActive : SegmentedCustomAction(), RTBarAction { companion object { @@ -76,7 +77,7 @@ private class RunToolbarMainSlotActive(presentation: Presentation) : SegmentedCu return UIUtil.getToolbarFont() } }.apply { - foreground = JBColor.namedColor("infoPanelForeground", JBColor(0x808080, 0x8C8C8C)) + foreground = UIUtil.getLabelInfoForeground() } init { @@ -102,23 +103,7 @@ private class RunToolbarMainSlotActive(presentation: Presentation) : SegmentedCu } add(pane) - - addMouseListener(object : MouseAdapter() { - override fun mousePressed(e: MouseEvent) { - if (SwingUtilities.isLeftMouseButton(e)) { - e.consume() - if (e.isShiftDown) { - doShiftClick() - } - else { - doClick() - } - } - else if (SwingUtilities.isRightMouseButton(e)) { - doRightClick() - } - } - }) + MouseListenerHelper.addListener(this, { doClick() }, { doShiftClick() }, { doRightClick() }) } fun doRightClick() { diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotInfoAction.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotInfoAction.kt index 3b5647494b15..40ceca39f668 100644 --- a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotInfoAction.kt +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarMainSlotInfoAction.kt @@ -1,6 +1,9 @@ // Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.runToolbar +import com.intellij.execution.runToolbar.components.MouseListenerHelper +import com.intellij.execution.runToolbar.components.ProcessesByType +import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.icons.AllIcons import com.intellij.idea.ActionsBundle import com.intellij.openapi.actionSystem.ActionToolbar @@ -11,22 +14,19 @@ import com.intellij.openapi.actionSystem.impl.segmentedActionBar.SegmentedCustom import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.Key import com.intellij.util.ui.JBDimension -import com.intellij.util.ui.UIUtil import net.miginfocom.swing.MigLayout import java.awt.Color -import java.awt.Font -import java.awt.event.MouseAdapter -import java.awt.event.MouseEvent import java.beans.PropertyChangeEvent import javax.swing.JLabel import javax.swing.JPanel -import javax.swing.SwingUtilities import javax.swing.UIManager class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration { companion object { private val LOG = Logger.getInstance(RunToolbarMainSlotInfoAction::class.java) private val PROP_ACTIVE_PROCESS_COLOR = Key("ACTIVE_PROCESS_COLOR") + private val PROP_ACTIVE_PROCESSES_UPDATED = Key("PROP_ACTIVE_PROCESSES_UPDATED") + private val PROP_ACTIVE_PROCESSES = Key>>("PROP_ACTIVE_PROCESSES") } override fun getRightSideType(): RTBarAction.Type = RTBarAction.Type.FLEXIBLE @@ -42,20 +42,18 @@ class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration override fun update(e: AnActionEvent) { e.presentation.isVisible = e.project?.let { project -> val manager = RunToolbarSlotManager.getInstance(project) - - - val activeProcesses = manager.activeProcesses + val activeProcesses = manager.activeProcesses.processes manager.getMainOrFirstActiveProcess()?.let { e.presentation.putClientProperty(PROP_ACTIVE_PROCESS_COLOR, it.pillColor) } e.presentation.putClientProperty(RunToolbarMainSlotActive.ARROW_DATA, e.arrowIcon()) + val value = e.presentation.getClientProperty(PROP_ACTIVE_PROCESSES_UPDATED) ?: false + e.presentation.putClientProperty(PROP_ACTIVE_PROCESSES_UPDATED, !value) + e.presentation.putClientProperty(PROP_ACTIVE_PROCESSES, activeProcesses) - activeProcesses.getText()?.let { - e.presentation.setText(it, false) - true - } ?: false + activeProcesses.isNotEmpty() } ?: false if (!RunToolbarProcess.isExperimentalUpdatingEnabled) { @@ -73,46 +71,35 @@ class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration private class RunToolbarMainSlotInfo(presentation: Presentation) : SegmentedCustomPanel(presentation), PopupControllerComponent { private val arrow = JLabel() + private val migLayout = MigLayout("fill, hidemode 3, ins 0, novisualpadding, ay center, flowx, gapx 0") - private val setting = object : JLabel() { - override fun getFont(): Font { - return UIUtil.getToolbarFont() - } - } + private val info = JPanel(migLayout) + private val processesComponents = mutableListOf() init { - layout = MigLayout("ins 0, fill, novisualpadding, ay center, gap 0", "[pref!][min!]5[]") - add(JPanel().apply { + layout = MigLayout("ins 0, fill, ay center") + add(JPanel(MigLayout("ins 0, fill, novisualpadding, ay center, gap 0", "[pref!][min!]5[fill]5")).apply { + add(JPanel().apply { + isOpaque = false + add(arrow) + val d = preferredSize + d.width = FixWidthSegmentedActionToolbarComponent.ARROW_WIDTH + preferredSize = d + }) + add(JPanel().apply { + preferredSize = JBDimension(1, 12) + minimumSize = JBDimension(1, 12) + + background = UIManager.getColor("Separator.separatorColor") + }) + + add(info, "pushx, ay center, wmin 0") isOpaque = false - add(arrow) - val d = preferredSize - d.width = FixWidthSegmentedActionToolbarComponent.ARROW_WIDTH - preferredSize = d - }) - add(JPanel().apply { - preferredSize = JBDimension(1, 12) - minimumSize = JBDimension(1, 12) - background = UIManager.getColor("Separator.separatorColor") - }) - add(setting) + }, "growx, wmin 10") - addMouseListener(object : MouseAdapter() { - override fun mousePressed(e: MouseEvent) { - if (SwingUtilities.isLeftMouseButton(e)) { - e.consume() - if (e.isShiftDown) { - doShiftClick() - } - else { - doClick() - } - } - else if (SwingUtilities.isRightMouseButton(e)) { - doRightClick() - } - } - }) + info.isOpaque = false + MouseListenerHelper.addListener(this, { doClick() }, { doShiftClick() }, { doRightClick() }) } fun doRightClick() { @@ -144,15 +131,49 @@ class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration } override fun presentationChanged(event: PropertyChangeEvent) { + updateState() + } + + private fun updateState() { updateArrow() - setting.icon = presentation.icon - setting.text = presentation.text presentation.getClientProperty(PROP_ACTIVE_PROCESS_COLOR)?.let { background = it } ?: kotlin.run { isOpaque = false } + + updateActiveProcesses() + } + + private fun updateActiveProcesses() { + presentation.getClientProperty(PROP_ACTIVE_PROCESSES)?.let { + if (it.isEmpty()) return + + info.removeAll() + + var colConstr = "" + + while (processesComponents.size < it.size) { + processesComponents.add(ProcessesByType()) + } + + var i = 0 + var showCount = false + for (entry in it) { + showCount = showCount || entry.value.size > 1 || it.size > 1 + val processesByType = processesComponents[i] + processesByType.update(entry.key, entry.value, showCount) + info.add(processesByType, "wmin 0") + colConstr += if (showCount) "[pref!]" else "[fill]" + i++ + } + if (showCount) colConstr += "push" + migLayout.columnConstraints = colConstr + } + + info.revalidate() + info.repaint() } private fun updateArrow() { diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarPopupController.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarPopupController.kt index 3756fa283878..d3c086221755 100644 --- a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarPopupController.kt +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarPopupController.kt @@ -19,7 +19,6 @@ import javax.swing.event.AncestorListener class RunToolbarPopupController(val project: Project, val mainWidgetComponent: RunToolbarMainWidgetComponent) : PopupControllerComponentListener, Disposable { - private val manager = RunToolbarSlotManager.getInstance(project) private var popup: JBPopup? = null private var pane: RunToolbarExtraSlotPane = RunToolbarExtraSlotPane(project, {mainWidgetComponent.width}) diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarProcessStartedAction.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarProcessStartedAction.kt index 94302d6b6dc8..21dfaf381443 100644 --- a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarProcessStartedAction.kt +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarProcessStartedAction.kt @@ -1,6 +1,7 @@ // Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.runToolbar +import com.intellij.execution.runToolbar.components.MouseListenerHelper import com.intellij.execution.runToolbar.components.TrimmedMiddleLabel import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.idea.ActionsBundle @@ -16,12 +17,9 @@ import com.intellij.util.ui.UIUtil import net.miginfocom.swing.MigLayout import java.awt.Dimension import java.awt.Font -import java.awt.event.MouseAdapter -import java.awt.event.MouseEvent import java.beans.PropertyChangeEvent import javax.swing.JComponent import javax.swing.JLabel -import javax.swing.SwingUtilities class RunToolbarProcessStartedAction : ComboBoxAction(), RTRunConfiguration { companion object { @@ -89,22 +87,7 @@ class RunToolbarProcessStartedAction : ComboBoxAction(), RTRunConfiguration { } init { - addMouseListener(object : MouseAdapter() { - override fun mousePressed(e: MouseEvent) { - if (SwingUtilities.isLeftMouseButton(e)) { - e.consume() - if (e.isShiftDown) { - doShiftClick() - } - else { - showPopup() - } - } - else if (SwingUtilities.isRightMouseButton(e)) { - doRightClick() - } - } - }) + MouseListenerHelper.addListener(this, { showPopup() }, { doShiftClick() }, { doRightClick() }) fill() } diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarRunConfigurationsAction.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarRunConfigurationsAction.kt index 56f945bd4e63..2b4d84c9d15d 100644 --- a/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarRunConfigurationsAction.kt +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/RunToolbarRunConfigurationsAction.kt @@ -5,6 +5,7 @@ import com.intellij.execution.* import com.intellij.execution.actions.RunConfigurationsComboBoxAction import com.intellij.execution.impl.EditConfigurationsDialog import com.intellij.execution.runToolbar.components.ComboBoxArrowComponent +import com.intellij.execution.runToolbar.components.MouseListenerHelper import com.intellij.execution.runToolbar.components.TrimmedMiddleLabel import com.intellij.ide.DataManager import com.intellij.ide.HelpTooltip @@ -25,8 +26,6 @@ import com.intellij.util.ui.UIUtil import net.miginfocom.swing.MigLayout import java.awt.Dimension import java.awt.Font -import java.awt.event.MouseAdapter -import java.awt.event.MouseEvent import java.beans.PropertyChangeEvent import javax.swing.JComponent import javax.swing.SwingUtilities @@ -98,23 +97,7 @@ open class RunToolbarRunConfigurationsAction : RunConfigurationsComboBoxAction() private val arrow = ComboBoxArrowComponent().getView() init { - addMouseListener(object : MouseAdapter() { - override fun mousePressed(e: MouseEvent) { - if (SwingUtilities.isLeftMouseButton(e)) { - e.consume() - if (e.isShiftDown) { - doShiftClick() - } - else { - doClick() - } - } - else if (SwingUtilities.isRightMouseButton(e)) { - doRightClick() - } - } - }) - + MouseListenerHelper.addListener(this, { doClick() }, { doShiftClick() }, { doRightClick() }) fill() background = JBColor.namedColor("ComboBoxButton.background", Gray.xDF) @@ -124,7 +107,9 @@ open class RunToolbarRunConfigurationsAction : RunConfigurationsComboBoxAction() setting.icon = presentation.icon setting.text = presentation.text - isEnabled = true + isEnabled = presentation.isEnabled + setting.isEnabled = isEnabled + arrow.isVisible = isEnabled toolTipText = presentation.description } diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/components/MouseListenerHelper.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/components/MouseListenerHelper.kt new file mode 100644 index 000000000000..cb6601119763 --- /dev/null +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/components/MouseListenerHelper.kt @@ -0,0 +1,33 @@ +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.execution.runToolbar.components + +import java.awt.Component +import java.awt.event.MouseAdapter +import java.awt.event.MouseEvent +import javax.swing.SwingUtilities + +class MouseListenerHelper { + companion object { + fun addListener(component: Component, doClick: () -> Unit, doShiftClick: () -> Unit, doRightClick: () -> Unit) { + + component.addMouseListener(object : MouseAdapter() { + override fun mousePressed(e: MouseEvent) { + if (!component.isEnabled) return + + if (SwingUtilities.isLeftMouseButton(e)) { + e.consume() + if (e.isShiftDown) { + doShiftClick() + } + else { + doClick() + } + } + else if (SwingUtilities.isRightMouseButton(e)) { + doRightClick() + } + } + }) + } + } +} diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/components/ProcessesByType.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/components/ProcessesByType.kt new file mode 100644 index 000000000000..05d519ea82a3 --- /dev/null +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/components/ProcessesByType.kt @@ -0,0 +1,59 @@ +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.execution.runToolbar.components + +import com.intellij.execution.runToolbar.RunToolbarProcess +import com.intellij.execution.runners.ExecutionEnvironment +import com.intellij.util.ui.UIUtil +import net.miginfocom.swing.MigLayout +import java.awt.Font +import javax.swing.JLabel +import javax.swing.JPanel + +class ProcessesByType : JPanel() { + + private var onlyCount = true + private var environment = emptyList() + private var process = RunToolbarProcess.getProcesses()[0] + + + private val settingLabel = object : TrimmedMiddleLabel() { + override fun getFont(): Font { + return UIUtil.getToolbarFont() + } + } + + private val processLabel = object : JLabel() { + override fun getFont(): Font { + return UIUtil.getToolbarFont() + } + }.apply { + foreground = UIUtil.getLabelInfoForeground() + } + + init { + layout = MigLayout("novisualpadding, ins 0, gap 0", "[min!][push]") + + add(processLabel) + add(settingLabel, "wmin 10") + + isOpaque = false + } + + fun update(process: RunToolbarProcess, environment: List, onlyCount: Boolean = false) { + this.process = process + this.environment = environment + this.onlyCount = onlyCount + + update() + } + + private fun update() { + processLabel.text = "${process.shortName}: " + settingLabel.text = if (environment.size > 1 || onlyCount) { + environment.size.toString() + } + else { + environment[0].contentToReuse?.displayName ?: "" + } + } +} \ No newline at end of file diff --git a/platform/execution-impl/src/com/intellij/execution/runToolbar/components/TrimmedMiddleLabel.kt b/platform/execution-impl/src/com/intellij/execution/runToolbar/components/TrimmedMiddleLabel.kt index c96458cb9f34..736b784b9b20 100644 --- a/platform/execution-impl/src/com/intellij/execution/runToolbar/components/TrimmedMiddleLabel.kt +++ b/platform/execution-impl/src/com/intellij/execution/runToolbar/components/TrimmedMiddleLabel.kt @@ -19,14 +19,16 @@ open class TrimmedMiddleLabel : JLabel() { x += iconTextGap + it.iconWidth } - if (textW < availableWidth) { + val ellipsisWidth = fm.stringWidth(StringUtil.ELLIPSIS) + if (textW < availableWidth || width < 3 * ellipsisWidth) { super.paintComponent(g) } else { icon?.let { icon.paintIcon(this, g, insets.left, 0) } - availableWidth -= (x + fm.stringWidth(StringUtil.ELLIPSIS)) + + availableWidth -= (x + ellipsisWidth) val charArray = text.toCharArray() val stringLength = charArray.size diff --git a/platform/execution/resources/messages/ExecutionBundle.properties b/platform/execution/resources/messages/ExecutionBundle.properties index 7e82089c63f3..2460b951a773 100644 --- a/platform/execution/resources/messages/ExecutionBundle.properties +++ b/platform/execution/resources/messages/ExecutionBundle.properties @@ -588,11 +588,14 @@ project.startup.task.table.name.column=Run Configuration project.startup.task.table.is.shared.column=Shared label.project.path.on.target=Project path on target: -run.toolbar.debug=Debugging +run.toolbar.debugging=Debugging +run.toolbar.running=Running +run.toolbar.debug=Debug +run.toolbar.attached=Attached run.toolbar.attach=Attach -run.toolbar.run=Running +run.toolbar.run=Run -run.toolbar.started = {0}: {1} +run.toolbar.started={0}: {1} module.not.specified=module not specified sdk.of.0.module=SDK of ''{0}'' module diff --git a/platform/execution/src/com/intellij/execution/runToolbar/RunToolbarProcess.kt b/platform/execution/src/com/intellij/execution/runToolbar/RunToolbarProcess.kt index 154f0621407d..29f1c3a391e7 100644 --- a/platform/execution/src/com/intellij/execution/runToolbar/RunToolbarProcess.kt +++ b/platform/execution/src/com/intellij/execution/runToolbar/RunToolbarProcess.kt @@ -44,6 +44,7 @@ interface RunToolbarProcess { val ID: String val executorId: String val name: @Nls String + val shortName: @Nls String val actionId: String fun getMainActionId(): String = "main$actionId" diff --git a/platform/lang-api/src/com/intellij/execution/runToolbar/RunToolbarRunProcess.kt b/platform/lang-api/src/com/intellij/execution/runToolbar/RunToolbarRunProcess.kt index 33595dd55713..11cf6b92be65 100644 --- a/platform/lang-api/src/com/intellij/execution/runToolbar/RunToolbarRunProcess.kt +++ b/platform/lang-api/src/com/intellij/execution/runToolbar/RunToolbarRunProcess.kt @@ -8,12 +8,13 @@ import com.intellij.ui.JBColor class RunToolbarRunProcess : RunToolbarProcess { override val ID: String = ToolWindowId.RUN override val executorId: String = ToolWindowId.RUN - override val name: String = ExecutionBundle.message("run.toolbar.run") + override val name: String = ExecutionBundle.message("run.toolbar.running") + override val shortName: String = ExecutionBundle.message("run.toolbar.run") override val actionId: String = "RunToolbarRunProcess" override val moreActionSubGroupName: String = "RunToolbarRunMoreActionSubGroupName" override val showInBar: Boolean = true - override val pillColor: JBColor = JBColor.namedColor("RunToolbar.Run.activeBackground", JBColor(0xBAEEBA, 0x375E37)) + override val pillColor: JBColor = JBColor.namedColor("RunToolbar.Run.activeBackground", JBColor(0xBAEEBA, 0x375E37)) } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/segmentedActionBar/SegmentedBarPainter.kt b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/segmentedActionBar/SegmentedBarPainter.kt index f9b69c9f90a2..e3e587ac88ca 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/segmentedActionBar/SegmentedBarPainter.kt +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/segmentedActionBar/SegmentedBarPainter.kt @@ -2,7 +2,6 @@ package com.intellij.openapi.actionSystem.impl.segmentedActionBar import com.intellij.ide.ui.laf.darcula.DarculaUIUtil -import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI import com.intellij.openapi.actionSystem.ActionButtonComponent import com.intellij.openapi.rd.paint2DLine import com.intellij.ui.Gray @@ -22,6 +21,24 @@ import kotlin.math.roundToInt internal class SegmentedBarPainter { companion object { + private val strokeWidth = 1.0 + + private val bw = 0f + private val lw = DarculaUIUtil.LW.float + + fun getGradientPaint(component: Component): Paint { + return GradientPaint(bw, bw, + JBColor.namedColor( + "Button.startBorderColor", + JBColor.namedColor("Button.darcula.outlineStartColor", 0xbfbfbf)), + bw, component.height - (bw * 2), + JBColor + .namedColor("Button.endBorderColor", + JBColor.namedColor( + "Button.darcula.outlineEndColor", + 0xb8b8b8))) + } + fun paintButtonDecorations(g: Graphics2D, c: JComponent, paint: Paint): Boolean { if (!(c as AbstractButton).isContentAreaFilled) { return true @@ -41,10 +58,11 @@ internal class SegmentedBarPainter { if (MacUIUtil.USE_QUARTZ) RenderingHints.VALUE_STROKE_PURE else RenderingHints.VALUE_STROKE_NORMALIZE) g2.translate(r.x, r.y) val arc = DarculaUIUtil.BUTTON_ARC.float - val bw: Float = if (DarculaButtonUI.isSmallVariant(c)) 0f else DarculaUIUtil.BW.float + val bw: Float = 0f //if (DarculaButtonUI.isSmallVariant(c)) 0f else DarculaUIUtil.BW.float if (c.isEnabled()) { g2.paint = paint + c.getClientProperty(SegmentedActionToolbarComponent.CONTROL_BAR_PROPERTY)?.let { paintComponent(g2, Rectangle(c.getSize()), it.toString()) } ?: g2.fill(RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc)) @@ -65,7 +83,6 @@ internal class SegmentedBarPainter { val wdth = r.width.toFloat() val offs = arc * 2 - val bw = 0f val area = when (position) { SegmentedActionToolbarComponent.CONTROL_BAR_FIRST -> { @@ -107,9 +124,6 @@ internal class SegmentedBarPainter { } fun paintActionBarBorder(component: JComponent, g: Graphics) { - val lw = DarculaUIUtil.LW.float - val bw = 0f - val g2 = g.create() as Graphics2D try { @@ -118,23 +132,12 @@ internal class SegmentedBarPainter { if (MacUIUtil.USE_QUARTZ) RenderingHints.VALUE_STROKE_PURE else RenderingHints.VALUE_STROKE_NORMALIZE) - val paint = GradientPaint(bw, bw, - JBColor.namedColor( - "Button.startBorderColor", - JBColor.namedColor("Button.darcula.outlineStartColor", 0xbfbfbf)), - bw, component.height - (bw * 2), - JBColor - .namedColor("Button.endBorderColor", - JBColor.namedColor( - "Button.darcula.outlineEndColor", - 0xb8b8b8))) - + val paint = getGradientPaint(component) for(i in 0 until component.componentCount - 1) { val comp = component.getComponent(i) val bounds = comp.bounds - val strokeWidth = 1.0 g2.paint2DLine(bounds.maxX - strokeWidth, bw.toDouble(), bounds.maxX - strokeWidth, (component.height - (bw * 2)).toDouble(), LinePainter2D.StrokeType.INSIDE, strokeWidth, @@ -152,8 +155,6 @@ internal class SegmentedBarPainter { g2.paint = paint g2.fill(border) - - } finally { g2.dispose() @@ -161,8 +162,6 @@ internal class SegmentedBarPainter { } private fun componentBorder(g: Graphics, h: Int, shape: Shape) { - val bw = 0f - val g2 = g.create() as Graphics2D g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, @@ -187,8 +186,6 @@ internal class SegmentedBarPainter { } fun paintActionBarBackground(component: JComponent, g: Graphics) { - val bw = 0f - val g2 = g.create() as Graphics2D try { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/runToolbar/RunToolbarDebugProcess.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/runToolbar/RunToolbarDebugProcess.kt index 845badea2b91..3c69f9a93192 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/runToolbar/RunToolbarDebugProcess.kt +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/runToolbar/RunToolbarDebugProcess.kt @@ -9,20 +9,22 @@ import com.intellij.ui.JBColor class RunToolbarDebugProcess : RunToolbarProcess { override val ID: String = ToolWindowId.DEBUG override val executorId: String = ID - override val name: String = ExecutionBundle.message("run.toolbar.debug") + override val name: String = ExecutionBundle.message("run.toolbar.debugging") + override val shortName: String = ExecutionBundle.message("run.toolbar.debug") override val actionId: String = "RunToolbarDebugProcess" override val moreActionSubGroupName: String = "RunToolbarDebugMoreActionSubGroupName" override val showInBar: Boolean = true - override val pillColor: JBColor = JBColor.namedColor("RunToolbar.Debug.activeBackground", JBColor(0xFAD576, 0x69541C)) + override val pillColor: JBColor = JBColor.namedColor("RunToolbar.Debug.activeBackground", JBColor(0xFAD576, 0x69541C)) } class RunToolbarAttachDebugProcess : RunToolbarProcess { override val ID: String = "ProcessAttachDebug" override val executorId: String = ID - override val name: String = ExecutionBundle.message("run.toolbar.attach") + override val name: String = ExecutionBundle.message("run.toolbar.attached") + override val shortName: String = name override val actionId: String = "RunToolbarAttachDebugProcess" override val moreActionSubGroupName: String = "RunToolbarAttachDebugMoreActionSubGroupName" @@ -31,5 +33,5 @@ class RunToolbarAttachDebugProcess : RunToolbarProcess { override fun isTemporaryProcess(): Boolean = true - override val pillColor: JBColor = JBColor.namedColor("RunToolbar.Debug.activeBackground", JBColor(0xFAD576, 0x69541C)) + override val pillColor: JBColor = JBColor.namedColor("RunToolbar.Debug.activeBackground", JBColor(0xFAD576, 0x69541C)) } \ No newline at end of file