mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
vcs: cleanup
GitOrigin-RevId: 7c1cc5307a4712666f5c171443b8044f76b655d9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3e59df3163
commit
84a4df2dee
@@ -30,7 +30,8 @@ import javax.swing.event.ChangeEvent
|
||||
import javax.swing.event.ChangeListener
|
||||
import kotlin.properties.Delegates.observable
|
||||
|
||||
class CurrentBranchComponent(private val tree: ChangesTree) : JBLabel(), Disposable {
|
||||
class CurrentBranchComponent(private val tree: ChangesTree,
|
||||
private val pathsProvider: () -> Iterable<FilePath>) : JBLabel(), Disposable {
|
||||
private val changeEventDispatcher = EventDispatcher.create(ChangeListener::class.java)
|
||||
|
||||
private var branches: Set<BranchData> by observable(setOf()) { _, oldValue, newValue ->
|
||||
@@ -51,10 +52,6 @@ class CurrentBranchComponent(private val tree: ChangesTree) : JBLabel(), Disposa
|
||||
|
||||
val project: Project get() = tree.project
|
||||
|
||||
var pathsProvider: () -> Iterable<FilePath> by observable({ emptyList() }) { _, _, _ ->
|
||||
refresh()
|
||||
}
|
||||
|
||||
init {
|
||||
isVisible = false
|
||||
icon = AllIcons.Vcs.Branch
|
||||
@@ -67,6 +64,8 @@ class CurrentBranchComponent(private val tree: ChangesTree) : JBLabel(), Disposa
|
||||
}
|
||||
tree.addPropertyChangeListener(treeChangeListener)
|
||||
Disposer.register(this, Disposable { tree.removePropertyChangeListener(treeChangeListener) })
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun addChangeListener(block: () -> Unit, parent: Disposable) =
|
||||
@@ -89,6 +88,7 @@ class CurrentBranchComponent(private val tree: ChangesTree) : JBLabel(), Disposa
|
||||
get() = namedDouble("VersionControl.RefLabel.backgroundBrightness", 0.08)
|
||||
|
||||
private val BACKGROUND_BASE_COLOR = namedColor("VersionControl.RefLabel.backgroundBase", JBColor(Color.BLACK, Color.WHITE))
|
||||
|
||||
@JvmField
|
||||
val TEXT_COLOR: JBColor = namedColor("VersionControl.RefLabel.foreground", JBColor(Color(0x7a7a7a), Color(0x909090)))
|
||||
|
||||
|
||||
@@ -12,8 +12,9 @@ import com.intellij.util.ui.JBUI.Borders.emptyRight
|
||||
import com.intellij.util.ui.JBUI.Panels.simplePanel
|
||||
import com.intellij.util.ui.UIUtil.addBorder
|
||||
import com.intellij.util.ui.UIUtil.getRegularPanelInsets
|
||||
import com.intellij.vcs.commit.*
|
||||
import com.intellij.vcs.commit.NonModalCommitPromoter
|
||||
import com.intellij.vcs.commit.SingleChangeListCommitWorkflow
|
||||
import com.intellij.vcs.commit.SingleChangeListCommitWorkflowUi
|
||||
import com.intellij.vcs.commit.getDisplayedPaths
|
||||
import java.awt.Dimension
|
||||
import javax.swing.JComponent
|
||||
@@ -30,10 +31,9 @@ class DefaultCommitChangeListDialog(workflow: SingleChangeListCommitWorkflow) :
|
||||
init {
|
||||
LineStatusTrackerManager.getInstanceImpl(project).resetExcludedFromCommitMarkers()
|
||||
|
||||
val branchComponent = CurrentBranchComponent(browser.viewer).apply {
|
||||
Disposer.register(this@DefaultCommitChangeListDialog, this)
|
||||
pathsProvider = { getDisplayedPaths() }
|
||||
}
|
||||
val branchComponent = CurrentBranchComponent(browser.viewer, pathsProvider = { getDisplayedPaths() })
|
||||
Disposer.register(this, branchComponent)
|
||||
|
||||
addBorder(branchComponent, emptyRight(16))
|
||||
browserBottomPanel.add(branchComponent)
|
||||
|
||||
|
||||
@@ -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.vcs.commit
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.ui.popup.JBPopup
|
||||
import com.intellij.openapi.util.Disposer
|
||||
@@ -66,10 +67,8 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel) :
|
||||
support.installSearch(commitMessage.editorField, commitMessage.editorField)
|
||||
}
|
||||
|
||||
with(changesView) {
|
||||
setInclusionListener { fireInclusionChanged() }
|
||||
isShowCheckboxes = true
|
||||
}
|
||||
changesView.setInclusionListener { fireInclusionChanged() }
|
||||
changesView.isShowCheckboxes = true
|
||||
changesViewHost.statusComponent =
|
||||
CommitStatusPanel(this).apply {
|
||||
border = emptyRight(6)
|
||||
@@ -77,7 +76,7 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel) :
|
||||
|
||||
addToLeft(toolbarPanel)
|
||||
}
|
||||
ChangesViewCommitTabTitleUpdater(this).start()
|
||||
ChangesViewCommitTabTitleUpdater(changesView, this, this).start()
|
||||
|
||||
commitActionsPanel.isCommitButtonDefault = {
|
||||
!progressPanel.isDumbMode &&
|
||||
@@ -210,10 +209,8 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel) :
|
||||
|
||||
override fun dispose() {
|
||||
changesViewHost.statusComponent = null
|
||||
with(changesView) {
|
||||
isShowCheckboxes = false
|
||||
setInclusionListener(null)
|
||||
}
|
||||
changesView.isShowCheckboxes = false
|
||||
changesView.setInclusionListener(null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,17 +233,15 @@ private class ChangesViewCommitProgressPanel(
|
||||
}
|
||||
}
|
||||
|
||||
private class ChangesViewCommitTabTitleUpdater(private val commitPanel: ChangesViewCommitPanel) :
|
||||
CommitTabTitleUpdater(commitPanel.changesView, LOCAL_CHANGES, { message("local.changes.tab") }),
|
||||
ChangesViewContentManagerListener {
|
||||
|
||||
private class ChangesViewCommitTabTitleUpdater(tree: ChangesTree, workflowUi: CommitWorkflowUi, disposable: Disposable)
|
||||
: CommitTabTitleUpdater(tree, LOCAL_CHANGES, { message("local.changes.tab") },
|
||||
pathsProvider = {
|
||||
val singleRoot = ProjectLevelVcsManager.getInstance(tree.project).allVersionedRoots.singleOrNull()
|
||||
if (singleRoot != null) listOf(getFilePath(singleRoot)) else workflowUi.getDisplayedPaths()
|
||||
}),
|
||||
ChangesViewContentManagerListener {
|
||||
init {
|
||||
Disposer.register(commitPanel, this)
|
||||
|
||||
pathsProvider = {
|
||||
val singleRoot = ProjectLevelVcsManager.getInstance(project).allVersionedRoots.singleOrNull()
|
||||
if (singleRoot != null) listOf(getFilePath(singleRoot)) else commitPanel.getDisplayedPaths()
|
||||
}
|
||||
Disposer.register(disposable, this)
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
|
||||
@@ -12,13 +12,16 @@ import com.intellij.openapi.vcs.changes.ui.CurrentBranchComponent
|
||||
import com.intellij.ui.content.Content
|
||||
import com.intellij.util.ui.update.UiNotifyConnector.doWhenFirstShown
|
||||
|
||||
open class CommitTabTitleUpdater(val tree: ChangesTree, val tabName: String, val defaultTitle: () -> String?) : Disposable {
|
||||
private val branchComponent = CurrentBranchComponent(tree).also { Disposer.register(this, it) }
|
||||
open class CommitTabTitleUpdater(val tree: ChangesTree,
|
||||
val tabName: String,
|
||||
val defaultTitle: () -> String?,
|
||||
pathsProvider: () -> Iterable<FilePath>) : Disposable {
|
||||
private val branchComponent = CurrentBranchComponent(tree, pathsProvider).also {
|
||||
Disposer.register(this, it)
|
||||
}
|
||||
|
||||
val project: Project get() = tree.project
|
||||
|
||||
var pathsProvider: () -> Iterable<FilePath> by branchComponent::pathsProvider
|
||||
|
||||
open fun start() {
|
||||
doWhenFirstShown(tree) { updateTab() } // as UI components could be created before tool window `Content`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user