mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RIDER-70060 bagfixes
GitOrigin-RevId: b4399cab0897fd48fffc3f67cbdc28e8fed97012
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f70b02b76d
commit
236350c86a
+2
-2
@@ -83,7 +83,7 @@ private class RunToolbarMainSlotActive(presentation: Presentation) : SegmentedCu
|
||||
init {
|
||||
layout = MigLayout("ins 0 0 0 3, fill, ay center")
|
||||
val pane = JPanel().apply {
|
||||
layout = MigLayout("ins 0, fill, novisualpadding, ay center, gap 0", "[pref!][min!]3[shp 1]3[]")
|
||||
layout = MigLayout("ins 0, fill, novisualpadding, ay center, gap 0", "[pref!][min!]3[shp 1, push]3[]push")
|
||||
add(JPanel().apply {
|
||||
isOpaque = false
|
||||
add(arrow)
|
||||
@@ -102,7 +102,7 @@ private class RunToolbarMainSlotActive(presentation: Presentation) : SegmentedCu
|
||||
isOpaque = false
|
||||
}
|
||||
|
||||
add(pane)
|
||||
add(pane, "growx")
|
||||
MouseListenerHelper.addListener(this, { doClick() }, { doShiftClick() }, { doRightClick() })
|
||||
}
|
||||
|
||||
|
||||
+51
-32
@@ -3,7 +3,6 @@ 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
|
||||
@@ -25,8 +24,8 @@ class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(RunToolbarMainSlotInfoAction::class.java)
|
||||
private val PROP_ACTIVE_PROCESS_COLOR = Key<Color>("ACTIVE_PROCESS_COLOR")
|
||||
private val PROP_ACTIVE_PROCESSES_UPDATED = Key<Boolean>("PROP_ACTIVE_PROCESSES_UPDATED")
|
||||
private val PROP_ACTIVE_PROCESSES = Key<MutableMap<RunToolbarProcess, MutableList<ExecutionEnvironment>>>("PROP_ACTIVE_PROCESSES")
|
||||
private val PROP_ACTIVE_PROCESSES_COUNT = Key<Int>("PROP_ACTIVE_PROCESSES_COUNT")
|
||||
private val PROP_ACTIVE_PROCESSES = Key<ActiveProcesses>("PROP_ACTIVE_PROCESSES")
|
||||
}
|
||||
|
||||
override fun getRightSideType(): RTBarAction.Type = RTBarAction.Type.FLEXIBLE
|
||||
@@ -42,18 +41,17 @@ 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.processes
|
||||
val activeProcesses = manager.activeProcesses
|
||||
|
||||
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_COUNT, activeProcesses.getActiveCount())
|
||||
e.presentation.putClientProperty(PROP_ACTIVE_PROCESSES, activeProcesses)
|
||||
|
||||
activeProcesses.isNotEmpty()
|
||||
activeProcesses.processes.isNotEmpty()
|
||||
} ?: false
|
||||
|
||||
if (!RunToolbarProcess.isExperimentalUpdatingEnabled) {
|
||||
@@ -71,10 +69,11 @@ 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 processComponents = mutableListOf<ProcessesByType>()
|
||||
private val migLayout = MigLayout("fill, hidemode 3, ins 0, novisualpadding, ay center, flowx, gapx 0")
|
||||
private val info = JPanel(migLayout)
|
||||
private val processesComponents = mutableListOf<ProcessesByType>()
|
||||
private val one = ProcessesByType()
|
||||
|
||||
init {
|
||||
layout = MigLayout("ins 0, fill, ay center")
|
||||
@@ -93,7 +92,11 @@ class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration
|
||||
background = UIManager.getColor("Separator.separatorColor")
|
||||
})
|
||||
|
||||
add(info, "pushx, ay center, wmin 0")
|
||||
add(JPanel(MigLayout("ins 0, fill, novisualpadding, ay center, gap 0, hidemode 3")).apply {
|
||||
add(info, "growx")
|
||||
add(one, "growx")
|
||||
isOpaque = false
|
||||
}, "pushx, ay center, wmin 0")
|
||||
isOpaque = false
|
||||
|
||||
}, "growx, wmin 10")
|
||||
@@ -147,33 +150,49 @@ class RunToolbarMainSlotInfoAction : SegmentedCustomAction(), RTRunConfiguration
|
||||
}
|
||||
|
||||
private fun updateActiveProcesses() {
|
||||
presentation.getClientProperty(PROP_ACTIVE_PROCESSES)?.let {
|
||||
if (it.isEmpty()) return
|
||||
presentation.getClientProperty(PROP_ACTIVE_PROCESSES)?.let { activeProcesses ->
|
||||
val processes = activeProcesses.processes
|
||||
val keys = processes.keys.toList()
|
||||
if (activeProcesses.getActiveCount() == 1) {
|
||||
info.isVisible = false
|
||||
one.isVisible = processes.keys.firstOrNull()?.let { process ->
|
||||
processes[process]?.let {
|
||||
one.update(process, it, false)
|
||||
true
|
||||
}
|
||||
} ?: false
|
||||
|
||||
info.removeAll()
|
||||
|
||||
var colConstr = ""
|
||||
|
||||
while (processesComponents.size < it.size) {
|
||||
processesComponents.add(ProcessesByType())
|
||||
return
|
||||
}
|
||||
else {
|
||||
info.isVisible = true
|
||||
one.isVisible = false
|
||||
|
||||
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++
|
||||
for (i in processComponents.size..processes.size) {
|
||||
val component = ProcessesByType()
|
||||
processComponents.add(component)
|
||||
info.add(component, "w pref!")
|
||||
}
|
||||
|
||||
var constraint = ""
|
||||
for (i in 0 until processComponents.size) {
|
||||
constraint += "[]"
|
||||
val component = processComponents[i]
|
||||
if (i < keys.size) {
|
||||
val key = keys[i]
|
||||
processes[key]?.let {
|
||||
component.isVisible = true
|
||||
component.update(key, it, true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
component.isVisible = false
|
||||
}
|
||||
}
|
||||
constraint += "push"
|
||||
migLayout.columnConstraints = constraint
|
||||
}
|
||||
if (showCount) colConstr += "push"
|
||||
migLayout.columnConstraints = colConstr
|
||||
}
|
||||
|
||||
info.revalidate()
|
||||
info.repaint()
|
||||
}
|
||||
|
||||
private fun updateArrow() {
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ class RunToolbarProcessStartedAction : ComboBoxAction(), RTRunConfiguration {
|
||||
}
|
||||
|
||||
private fun fill() {
|
||||
layout = MigLayout("ins 0, novisualpadding, gap 0, fill", "4[shp 1]3[grow]4")
|
||||
layout = MigLayout("ins 0 0 0 3, novisualpadding, gap 0, fill", "4[shp 1]3[grow]push")
|
||||
|
||||
add(setting, "ay center, pushx, wmin 10")
|
||||
add(process, "ay center, pushx, wmin 0")
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ open class RunToolbarRunConfigurationsAction : RunConfigurationsComboBoxAction()
|
||||
}
|
||||
|
||||
private fun fill() {
|
||||
layout = MigLayout("ins 0, novisualpadding, gap 0, fill, hidemode 3", "4[][min!]2")
|
||||
layout = MigLayout("ins 0 0 0 3, novisualpadding, gap 0, fill, hidemode 3", "4[][min!]")
|
||||
|
||||
add(setting, "ay center, growx, wmin 10")
|
||||
add(arrow)
|
||||
|
||||
+2
-2
@@ -229,7 +229,7 @@ class RunToolbarSlotManager(val project: Project) {
|
||||
}
|
||||
|
||||
private fun updateState() {
|
||||
state = when (activeProcesses.getEnvironmentCount()) {
|
||||
state = when (activeProcesses.getActiveCount()) {
|
||||
0 -> State.INACTIVE
|
||||
1 -> {
|
||||
mainSlotData.environment?.let {
|
||||
@@ -481,7 +481,7 @@ class ActiveProcesses {
|
||||
val processes = mutableMapOf<RunToolbarProcess, MutableList<ExecutionEnvironment>>()
|
||||
private var activeCount = 0
|
||||
|
||||
fun getEnvironmentCount(): Int = activeCount
|
||||
fun getActiveCount(): Int = activeCount
|
||||
|
||||
fun getText(): String? {
|
||||
return when {
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ class ProcessesByType : JPanel() {
|
||||
}
|
||||
|
||||
init {
|
||||
layout = MigLayout("novisualpadding, ins 0, gap 0", "[min!][push]")
|
||||
layout = MigLayout("fill, novisualpadding, ins 0, gap 0", "[min!][fill]")
|
||||
|
||||
add(processLabel)
|
||||
add(settingLabel, "wmin 10")
|
||||
@@ -39,7 +39,7 @@ class ProcessesByType : JPanel() {
|
||||
isOpaque = false
|
||||
}
|
||||
|
||||
fun update(process: RunToolbarProcess, environment: List<ExecutionEnvironment>, onlyCount: Boolean = false) {
|
||||
fun update(process: RunToolbarProcess, environment: MutableList<ExecutionEnvironment>, onlyCount: Boolean = false) {
|
||||
this.process = process
|
||||
this.environment = environment
|
||||
this.onlyCount = onlyCount
|
||||
|
||||
+7
-5
@@ -8,8 +8,10 @@ import java.awt.Graphics2D
|
||||
import javax.swing.JLabel
|
||||
|
||||
open class TrimmedMiddleLabel : JLabel() {
|
||||
private val magicConst = 5
|
||||
|
||||
override fun paintComponent(g: Graphics) {
|
||||
val fm = g.getFontMetrics(g.font)
|
||||
val fm = getFontMetrics(font)
|
||||
g as Graphics2D
|
||||
UISettings.setupAntialiasing(g)
|
||||
val textW = fm.stringWidth(text)
|
||||
@@ -17,10 +19,11 @@ open class TrimmedMiddleLabel : JLabel() {
|
||||
var x = insets.left
|
||||
icon?.let {
|
||||
x += iconTextGap + it.iconWidth
|
||||
availableWidth -= x
|
||||
}
|
||||
|
||||
val ellipsisWidth = fm.stringWidth(StringUtil.ELLIPSIS)
|
||||
if (textW < availableWidth || width < 3 * ellipsisWidth) {
|
||||
if (textW <= availableWidth + (icon?.let { 0 } ?: magicConst) || width < ellipsisWidth) {
|
||||
super.paintComponent(g)
|
||||
}
|
||||
else {
|
||||
@@ -28,14 +31,13 @@ open class TrimmedMiddleLabel : JLabel() {
|
||||
icon.paintIcon(this, g, insets.left, 0)
|
||||
}
|
||||
|
||||
availableWidth -= (x + ellipsisWidth)
|
||||
|
||||
val charArray = text.toCharArray()
|
||||
val stringLength = charArray.size
|
||||
var w = 0
|
||||
val avW = availableWidth - ellipsisWidth
|
||||
for (nChars in 0 until stringLength) {
|
||||
w += fm.charWidth(charArray[nChars])
|
||||
if (w > availableWidth) {
|
||||
if (w > avW) {
|
||||
g.drawString(StringUtil.trimMiddle(text, nChars - 1), x, fm.ascent)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user