mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: non-modal: Show current change list author after "Commit" button
GitOrigin-RevId: 10562addaf302d3cbea81debca7f5fb03c27a868
This commit is contained in:
committed by
intellij-monorepo-bot
parent
23f4c7e663
commit
4989493636
@@ -36,6 +36,7 @@ import com.intellij.ui.components.JBOptionButton
|
||||
import com.intellij.ui.components.JBOptionButton.Companion.getDefaultShowPopupShortcut
|
||||
import com.intellij.ui.components.JBPanel
|
||||
import com.intellij.ui.components.panels.HorizontalLayout
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel
|
||||
import com.intellij.util.EventDispatcher
|
||||
import com.intellij.util.IJSwingUtilities.updateComponentTreeUI
|
||||
import com.intellij.util.ui.JBUI.Borders.empty
|
||||
@@ -45,6 +46,7 @@ import com.intellij.util.ui.JBUI.scale
|
||||
import com.intellij.util.ui.UIUtil.getTreeBackground
|
||||
import com.intellij.util.ui.components.BorderLayoutPanel
|
||||
import com.intellij.util.ui.tree.TreeUtil.*
|
||||
import com.intellij.vcs.log.VcsUser
|
||||
import java.awt.Point
|
||||
import java.awt.event.ActionEvent
|
||||
import java.awt.event.InputEvent
|
||||
@@ -122,6 +124,7 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v
|
||||
|
||||
override fun isDefaultButton(): Boolean = IdeFocusManager.getInstance(project).getFocusedDescendantFor(rootComponent) != null
|
||||
}
|
||||
private val commitAuthorComponent = CommitAuthorComponent()
|
||||
private val commitLegendCalculator = ChangeInfoCalculator()
|
||||
private val commitLegend = CommitLegendPanel(commitLegendCalculator)
|
||||
|
||||
@@ -169,7 +172,10 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v
|
||||
createHorizontalPanel().apply {
|
||||
background = BACKGROUND_COLOR
|
||||
|
||||
add(commitButton)
|
||||
add(NonOpaquePanel(HorizontalLayout(scale(4))).apply {
|
||||
add(commitButton)
|
||||
add(commitAuthorComponent)
|
||||
})
|
||||
add(CurrentBranchComponent(project, changesView, this@ChangesViewCommitPanel))
|
||||
add(commitLegend.component)
|
||||
add(toolbarPanel)
|
||||
@@ -242,6 +248,12 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v
|
||||
|
||||
override fun setCustomCommitActions(actions: List<AnAction>) = commitButton.setOptions(actions)
|
||||
|
||||
override var commitAuthor: VcsUser?
|
||||
get() = commitAuthorComponent.commitAuthor
|
||||
set(value) {
|
||||
commitAuthorComponent.commitAuthor = value
|
||||
}
|
||||
|
||||
override val isActive: Boolean get() = isVisible
|
||||
|
||||
override fun activate(): Boolean {
|
||||
|
||||
@@ -185,6 +185,7 @@ class ChangesViewCommitWorkflowHandler(
|
||||
setCommitMessage(newCommitMessage)
|
||||
|
||||
newChangeList?.let { commitOptions.changeListChanged(it) }
|
||||
ui.commitAuthor = (newChangeList?.data as? ChangeListData)?.author
|
||||
}
|
||||
|
||||
override fun inclusionChanged() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.vcs.changes.InclusionModel
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList
|
||||
import com.intellij.vcs.log.VcsUser
|
||||
|
||||
interface ChangesViewCommitWorkflowUi : CommitWorkflowUi {
|
||||
val isActive: Boolean
|
||||
@@ -13,6 +14,8 @@ interface ChangesViewCommitWorkflowUi : CommitWorkflowUi {
|
||||
var isDefaultCommitActionEnabled: Boolean
|
||||
fun setCustomCommitActions(actions: List<AnAction>)
|
||||
|
||||
var commitAuthor: VcsUser?
|
||||
|
||||
var inclusionModel: InclusionModel?
|
||||
|
||||
fun select(item: Any)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.vcs.commit
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil.escapeXmlEntities
|
||||
import com.intellij.openapi.util.text.StringUtil.unescapeXmlEntities
|
||||
import com.intellij.ui.components.JBLabel
|
||||
import com.intellij.ui.components.labels.LinkLabel
|
||||
import com.intellij.ui.components.panels.HorizontalLayout
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel
|
||||
import com.intellij.util.ui.JBUI.Borders.emptyRight
|
||||
import com.intellij.util.ui.UIUtil.getInactiveTextColor
|
||||
import com.intellij.vcs.log.VcsUser
|
||||
import com.intellij.vcs.log.util.VcsUserUtil.getShortPresentation
|
||||
import kotlin.properties.Delegates.observable
|
||||
|
||||
class CommitAuthorComponent : NonOpaquePanel(HorizontalLayout(0)) {
|
||||
private val viewer: VcsUserViewer = VcsUserViewer()
|
||||
|
||||
var commitAuthor by observable<VcsUser?>(null) { _, oldValue, newValue ->
|
||||
if (oldValue == newValue) return@observable
|
||||
|
||||
isVisible = newValue != null
|
||||
viewer.user = newValue
|
||||
}
|
||||
|
||||
init {
|
||||
isVisible = false
|
||||
|
||||
add(JBLabel("by").apply {
|
||||
foreground = getInactiveTextColor()
|
||||
border = emptyRight(4)
|
||||
})
|
||||
add(viewer)
|
||||
}
|
||||
}
|
||||
|
||||
private class VcsUserViewer : LinkLabel<Any>(null, null) {
|
||||
var user by observable<VcsUser?>(null) { _, oldValue, newValue ->
|
||||
if (oldValue == newValue) return@observable
|
||||
|
||||
text = newValue?.let { getShortPresentation(it) }
|
||||
toolTipText = newValue?.let { escapeXmlEntities(it.toString()) }
|
||||
}
|
||||
|
||||
override fun getStatusBarText(): String = unescapeXmlEntities(super.getStatusBarText())
|
||||
}
|
||||
Reference in New Issue
Block a user