mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[lvcs] implement a toggle for showing system labels in the activity view (IJPL-163462)
Follow-up: 3208fc6842cebf31203a999fb414a1c77e323999 GitOrigin-RevId: 8db1882e0072b53c19963005736980e330f71f34
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1f44159b75
commit
a862a8d09b
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.history
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
@@ -74,8 +74,7 @@ abstract class LocalHistory {
|
||||
|
||||
/**
|
||||
* Puts a system label to mark a certain point in local history.
|
||||
* Note that system labels added inside the [LocalHistoryAction] are not visible,
|
||||
* also they are not visible in the experimental "Activity" tool window.
|
||||
* Note that system labels can be visible or not depending on the UI settings.
|
||||
*
|
||||
* @param project the project where the event occurred
|
||||
* @param name the name of the label
|
||||
@@ -86,8 +85,7 @@ abstract class LocalHistory {
|
||||
|
||||
/**
|
||||
* Puts a system label to mark a certain point in local history.
|
||||
* Note that system labels added inside the [LocalHistoryAction] are not visible,
|
||||
* also they are not visible in the experimental "Activity" tool window.
|
||||
* Note that system labels can be visible or not depending on the UI settings.
|
||||
*
|
||||
* @param project the project where the event occurred
|
||||
* @param name the name of the label
|
||||
|
||||
@@ -52,10 +52,15 @@
|
||||
<action id="ActivityView.RevertDifferences" class="com.intellij.platform.lvcs.impl.actions.RevertDifferencesAction"
|
||||
icon="AllIcons.Actions.Rollback"/>
|
||||
<action id="ActivityView.CreatePatch" class="com.intellij.platform.lvcs.impl.actions.CreatePatchAction" icon="AllIcons.Vcs.Patch"/>
|
||||
<group id="ActivityView.Options" icon="AllIcons.General.Show" popup="true">
|
||||
<action id="ActivityView.ShowSystemLabelsAction"
|
||||
class="com.intellij.platform.lvcs.impl.actions.ShowSystemLabelsAction"/>
|
||||
</group>
|
||||
|
||||
<group id="ActivityView.Toolbar">
|
||||
<reference ref="ActivityView.Revert"/>
|
||||
<reference ref="ActivityView.CreatePatch"/>
|
||||
<reference ref="ActivityView.Options"/>
|
||||
</group>
|
||||
<group id="ActivityView.Popup">
|
||||
<reference ref="ActivityView.Revert"/>
|
||||
|
||||
@@ -93,6 +93,8 @@ activity.action.patch.collecting.diff=Collecting Differences
|
||||
action.ActivityView.Revert.text=Revert Selected and Later Changes
|
||||
action.ActivityView.RevertDifferences.text=Revert Selection
|
||||
action.ActivityView.CreatePatch.text=Create Patch\u2026
|
||||
group.ActivityView.Options.text=View Options
|
||||
action.ActivityView.ShowSystemLabelsAction.text=Show System Events
|
||||
|
||||
# notifications
|
||||
notification.group.general=Local history messages
|
||||
@@ -104,4 +106,4 @@ notification.content.label.creation.failed=Could not create label {0}
|
||||
|
||||
# used externally
|
||||
dialog.title.revert=Revert
|
||||
message.do.you.want.to.proceed={0}\n\nDo you want to proceed?
|
||||
message.do.you.want.to.proceed={0}\n\nDo you want to proceed?
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl
|
||||
|
||||
import com.intellij.diff.chains.DiffRequestProducer
|
||||
@@ -9,8 +9,8 @@ import org.jetbrains.annotations.ApiStatus
|
||||
interface ActivityProvider {
|
||||
fun getActivityItemsChanged(scope: ActivityScope): Flow<Unit>
|
||||
|
||||
fun loadActivityList(scope: ActivityScope, fileFilter: String?): ActivityData
|
||||
fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?): Set<ActivityItem>?
|
||||
fun loadActivityList(scope: ActivityScope, fileFilter: String?, showSystemLabels: Boolean): ActivityData
|
||||
fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?, showSystemLabels: Boolean): Set<ActivityItem>?
|
||||
|
||||
fun loadDiffData(scope: ActivityScope, selection: ActivitySelection, diffMode: DirectoryDiffMode): ActivityDiffData?
|
||||
fun loadSingleDiff(scope: ActivityScope, selection: ActivitySelection): DiffRequestProducer?
|
||||
@@ -28,4 +28,4 @@ enum class FilterKind {
|
||||
@ApiStatus.Experimental
|
||||
enum class DirectoryDiffMode {
|
||||
WithLocal, WithNext
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:ApiStatus.Internal
|
||||
|
||||
package com.intellij.platform.lvcs.impl
|
||||
@@ -14,13 +14,15 @@ import com.intellij.util.text.DateFormatUtil
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
abstract class ChangeSetActivityItem(changeSet: ChangeSet) : ActivityItem {
|
||||
abstract class ChangeSetActivityItem(private val changeSet: ChangeSet) : ActivityItem {
|
||||
override val timestamp: Long = changeSet.timestamp
|
||||
val id = changeSet.id
|
||||
val activityId: ActivityId? = changeSet.activityId
|
||||
open val fullName: @NlsSafe String? get() = name
|
||||
abstract val name: @NlsSafe String?
|
||||
|
||||
fun isSystemLabelOnly(): Boolean = changeSet.isSystemLabelOnly
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is ChangeSetActivityItem) return false
|
||||
@@ -91,4 +93,4 @@ internal class LabelActivityItem(changeSet: ChangeSet) : ChangeSetActivityItem(c
|
||||
fun ChangeSet.toActivityItem(scope: ActivityScope): ActivityItem {
|
||||
if (isLabelOnly) return LabelActivityItem(this)
|
||||
return ChangeActivityItem(this, scope)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.project.BaseProjectDirectories.Companion.getBaseDirectories
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.platform.lvcs.impl.diff.createDiffData
|
||||
import com.intellij.platform.lvcs.impl.diff.createSingleFileDiffRequestProducer
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
@@ -30,46 +29,45 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga
|
||||
return facade.onChangeSetFinished(project, gateway, scope)
|
||||
}
|
||||
|
||||
override fun loadActivityList(scope: ActivityScope, fileFilter: String?): ActivityData {
|
||||
override fun loadActivityList(scope: ActivityScope, fileFilter: String?, showSystemLabels: Boolean): ActivityData {
|
||||
gateway.registerUnsavedDocuments(facade)
|
||||
|
||||
val filter = HistoryPathFilter.create(fileFilter, project)
|
||||
val projectId = project.locationHash
|
||||
if (scope is ActivityScope.File) {
|
||||
return loadFileActivityList(projectId, scope, filter)
|
||||
return loadFileActivityList(projectId, scope, filter, showSystemLabels)
|
||||
} else if (scope is ActivityScope.Files) {
|
||||
return loadFilesActivityList(projectId, scope, filter)
|
||||
return loadFilesActivityList(projectId, scope, filter, showSystemLabels)
|
||||
}
|
||||
return loadRecentActivityList(projectId, scope, filter)
|
||||
return loadRecentActivityList(projectId, scope, filter, showSystemLabels)
|
||||
}
|
||||
|
||||
private fun loadFileActivityList(projectId: String, scope: ActivityScope.File, scopeFilter: HistoryPathFilter?): ActivityData {
|
||||
private fun loadFileActivityList(projectId: String, scope: ActivityScope.File, scopeFilter: HistoryPathFilter?, showSystemLabels: Boolean): ActivityData {
|
||||
val path = gateway.getPathOrUrl(scope.file)
|
||||
val activityItems = mutableListOf<ActivityItem>()
|
||||
val affectedPaths = mutableSetOf(path)
|
||||
|
||||
doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems)
|
||||
doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems, showSystemLabels)
|
||||
|
||||
return ActivityData(activityItems).also { it.putUserData(AFFECTED_PATHS, affectedPaths) }
|
||||
}
|
||||
|
||||
private fun loadFilesActivityList(projectId: String, scope: ActivityScope.Files, scopeFilter: HistoryPathFilter?): ActivityData {
|
||||
private fun loadFilesActivityList(projectId: String, scope: ActivityScope.Files, scopeFilter: HistoryPathFilter?, showSystemLabels: Boolean): ActivityData {
|
||||
val paths = scope.files.map { gateway.getPathOrUrl(it) }
|
||||
val activityItems = mutableListOf<ActivityItem>()
|
||||
val affectedPaths = paths.toMutableSet()
|
||||
|
||||
for (path in paths) {
|
||||
doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems)
|
||||
doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems, showSystemLabels)
|
||||
}
|
||||
|
||||
return ActivityData(activityItems.toSet().sortedByDescending { it.timestamp }).also { it.putUserData(AFFECTED_PATHS, affectedPaths) }
|
||||
}
|
||||
|
||||
private fun doLoadPathActivityList(projectId: String, scope: ActivityScope, path: String, scopeFilter: HistoryPathFilter?,
|
||||
affectedPaths: MutableSet<String>, activityItems: MutableList<ActivityItem>) {
|
||||
affectedPaths: MutableSet<String>, activityItems: MutableList<ActivityItem>, showSystemLabels: Boolean) {
|
||||
var lastEventLabel: ChangeSet? = null
|
||||
val userLabels = mutableListOf<ChangeSet>()
|
||||
val showSystemLabels = Registry.`is`("lvcs.show.system.labels.in.activity.view")
|
||||
|
||||
facade.collectChanges(path, ChangeAndPathProcessor(projectId, scopeFilter, affectedPaths::add) { changeSet ->
|
||||
if (!showSystemLabels && changeSet.isSystemLabelOnly) return@ChangeAndPathProcessor
|
||||
@@ -95,10 +93,9 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadRecentActivityList(projectId: String, scope: ActivityScope, fileFilter: HistoryPathFilter?): ActivityData {
|
||||
private fun loadRecentActivityList(projectId: String, scope: ActivityScope, fileFilter: HistoryPathFilter?, showSystemLabels: Boolean): ActivityData {
|
||||
val result = mutableListOf<ActivityItem>()
|
||||
val paths = project.getBaseDirectories().map { gateway.getPathOrUrl(it) }
|
||||
val showSystemLabels = Registry.`is`("lvcs.show.system.labels.in.activity.view")
|
||||
|
||||
for (changeSet in facade.changes) {
|
||||
if (!showSystemLabels && changeSet.isSystemLabelOnly) continue
|
||||
@@ -115,14 +112,14 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga
|
||||
return ActivityData(result).also { it.putUserData(AFFECTED_PATHS, paths) }
|
||||
}
|
||||
|
||||
override fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?): Set<ActivityItem>? {
|
||||
override fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?, showSystemLabels: Boolean): Set<ActivityItem>? {
|
||||
val changeSets = data.getChangeSets()
|
||||
if (contentFilter.isNullOrEmpty() || changeSets.isEmpty()) return null
|
||||
if (changeSets.isEmpty()) return null
|
||||
val fileScope = scope as? ActivityScope.File ?: return null
|
||||
|
||||
val filteredIds = mutableSetOf<Long>()
|
||||
val processor: (Long, String?) -> Boolean = { changeSetId, content ->
|
||||
if (content?.contains(contentFilter, true) == true) filteredIds.add(changeSetId)
|
||||
if (contentFilter == null || content?.contains(contentFilter, true) == true) filteredIds.add(changeSetId)
|
||||
true
|
||||
}
|
||||
|
||||
@@ -135,7 +132,14 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga
|
||||
facade.processContents(gateway, rootEntry, path, changeSets, before = USE_OLD_CONTENT, processor = processor)
|
||||
}
|
||||
|
||||
return data.items.filterTo(mutableSetOf()) { (it is ChangeSetActivityItem) && filteredIds.contains(it.id) }
|
||||
val result = mutableSetOf<ActivityItem>()
|
||||
for (item in data.items) {
|
||||
when {
|
||||
!showSystemLabels && item is ChangeSetActivityItem && item.isSystemLabelOnly() -> continue
|
||||
item is ChangeSetActivityItem && filteredIds.contains(item.id) -> result.add(item)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun loadDiffData(scope: ActivityScope, selection: ActivitySelection, diffMode: DirectoryDiffMode): ActivityDiffData? {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl.actions
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.ToggleAction
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.platform.lvcs.impl.settings.ActivityViewApplicationSettings
|
||||
import com.intellij.platform.lvcs.impl.ui.ActivityViewDataKeys
|
||||
|
||||
internal class ShowSystemLabelsAction: ToggleAction(), DumbAware {
|
||||
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
|
||||
|
||||
override fun isSelected(e: AnActionEvent): Boolean {
|
||||
return isShowSystemLabelsEnabled()
|
||||
}
|
||||
|
||||
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||
service<ActivityViewApplicationSettings>().showSystemLabels = state
|
||||
e.getData(ActivityViewDataKeys.ACTIVITY_VIEW_MODEL)?.setSystemLabelsFiltered(state)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun isShowSystemLabelsEnabled(): Boolean =
|
||||
service<ActivityViewApplicationSettings>().showSystemLabels
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl.settings
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -13,6 +13,7 @@ internal class ActivityViewApplicationSettings : SimplePersistentStateComponent<
|
||||
|
||||
class State : BaseState() {
|
||||
var diffMode by enum(DirectoryDiffMode.WithLocal)
|
||||
var showSystemLabels by property(true)
|
||||
}
|
||||
|
||||
var diffMode: DirectoryDiffMode
|
||||
@@ -22,6 +23,13 @@ internal class ActivityViewApplicationSettings : SimplePersistentStateComponent<
|
||||
eventDispatcher.multicaster.settingsChanged()
|
||||
}
|
||||
|
||||
var showSystemLabels: Boolean
|
||||
get() = state.showSystemLabels
|
||||
set(value) {
|
||||
state.showSystemLabels = value
|
||||
eventDispatcher.multicaster.settingsChanged()
|
||||
}
|
||||
|
||||
fun addListener(listener: Listener, disposable: Disposable) {
|
||||
eventDispatcher.addListener(listener, disposable)
|
||||
}
|
||||
@@ -29,4 +37,4 @@ internal class ActivityViewApplicationSettings : SimplePersistentStateComponent<
|
||||
interface Listener : EventListener {
|
||||
fun settingsChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl.ui
|
||||
|
||||
import com.intellij.diff.editor.DiffEditorTabFilesManager
|
||||
@@ -173,6 +173,7 @@ class ActivityView(private val project: Project, gateway: IdeaGateway, val activ
|
||||
sink[ActivityViewDataKeys.SCOPE] = activityScope
|
||||
sink[DiffDataKeys.EDITOR_TAB_DIFF_PREVIEW] = editorDiffPreview
|
||||
sink[ActivityViewDataKeys.DIRECTORY_DIFF_MODE] = model.diffMode
|
||||
sink[ActivityViewDataKeys.ACTIVITY_VIEW_MODEL] = model
|
||||
}
|
||||
|
||||
val preferredFocusedComponent: JComponent get() = activityList
|
||||
@@ -399,4 +400,4 @@ private sealed interface SearchFieldComponent {
|
||||
override val containerComponent = SearchTextArea(textArea, true)
|
||||
override val textComponent = textArea
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl.ui
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataKey
|
||||
@@ -14,4 +14,5 @@ object ActivityViewDataKeys {
|
||||
val SCOPE: DataKey<ActivityScope> = DataKey.create("ActivityView.Scope")
|
||||
val SELECTED_DIFFERENCES: DataKey<Iterable<PresentableChange>> = DataKey.create("ActivityView.SelectedDifferences")
|
||||
val DIRECTORY_DIFF_MODE: DataKey<DirectoryDiffMode> = DataKey.create("ActivityView.DirectoryDiffMode")
|
||||
}
|
||||
internal val ACTIVITY_VIEW_MODEL: DataKey<ActivityViewModel> = DataKey.create("ActivityView.ActivityViewModel")
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl.ui
|
||||
|
||||
import com.intellij.history.integration.IdeaGateway
|
||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.lvcs.impl.*
|
||||
import com.intellij.platform.lvcs.impl.actions.isShowSystemLabelsEnabled
|
||||
import com.intellij.platform.lvcs.impl.statistics.LocalHistoryCounter
|
||||
import com.intellij.util.EventDispatcher
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
@@ -27,21 +28,24 @@ internal class ActivityViewModel(private val project: Project, gateway: IdeaGate
|
||||
|
||||
private val filterFlow = MutableStateFlow<String?>(null)
|
||||
|
||||
private val filterSystemLabelsFlow = MutableStateFlow(isShowSystemLabelsEnabled())
|
||||
|
||||
private val isVisibleFlow = MutableStateFlow(true)
|
||||
|
||||
init {
|
||||
coroutineScope.launch {
|
||||
combine(activityProvider.getActivityItemsChanged(activityScope).debounce(500),
|
||||
if (filterKind == FilterKind.FILE) filterFlow else flowOf(null),
|
||||
isVisibleFlow) { _, filter, isVisible -> filter to isVisible }
|
||||
.filter { (_, isVisible) -> isVisible }
|
||||
.map { it.first }
|
||||
.collect { filter ->
|
||||
isVisibleFlow,
|
||||
filterSystemLabelsFlow.debounce(100)) { _, filter, isVisible, showSystemLabels -> Triple(filter, isVisible, showSystemLabels) }
|
||||
.filter { (_, isVisible, _) -> isVisible }
|
||||
.map { it.first to it.third }
|
||||
.collect { (filter, showSystemLabels) ->
|
||||
thisLogger<ActivityViewModel>().debug("Loading activity items for $activityScope and filter $filter")
|
||||
withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onItemsLoadingStarted() }
|
||||
val activityData = withContext(Dispatchers.Default) {
|
||||
LocalHistoryCounter.logLoadItems(project, activityScope) {
|
||||
activityProvider.loadActivityList(activityScope, filter)
|
||||
activityProvider.loadActivityList(activityScope, filter, showSystemLabels)
|
||||
}
|
||||
}
|
||||
withContext(Dispatchers.EDT) {
|
||||
@@ -73,19 +77,17 @@ internal class ActivityViewModel(private val project: Project, gateway: IdeaGate
|
||||
|
||||
if (filterKind == FilterKind.CONTENT) {
|
||||
coroutineScope.launch {
|
||||
combine(filterFlow.debounce(100), activityItemsFlow) { f, r -> f to r }.collect { (filter, data) ->
|
||||
if (filter.isNullOrEmpty()) {
|
||||
withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStopped(null) }
|
||||
return@collect
|
||||
combine(filterFlow.debounce(100),
|
||||
filterSystemLabelsFlow.debounce(100),
|
||||
activityItemsFlow) { ff, fs, r -> Triple(ff, fs, r) }
|
||||
.collect { (filter, showSystemLabels, data) ->
|
||||
thisLogger<ActivityViewModel>().debug("Filtering activity items for $activityScope by $filter")
|
||||
withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStarted() }
|
||||
val result = LocalHistoryCounter.logFilter(project, activityScope) {
|
||||
activityProvider.filterActivityList(activityScope, data, filter, showSystemLabels)
|
||||
}
|
||||
withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStopped(result) }
|
||||
}
|
||||
|
||||
thisLogger<ActivityViewModel>().debug("Filtering activity items for $activityScope by $filter")
|
||||
withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStarted() }
|
||||
val result = LocalHistoryCounter.logFilter(project, activityScope) {
|
||||
activityProvider.filterActivityList(activityScope, data, filter)
|
||||
}
|
||||
withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStopped(result) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,6 +107,10 @@ internal class ActivityViewModel(private val project: Project, gateway: IdeaGate
|
||||
filterFlow.value = pattern
|
||||
}
|
||||
|
||||
fun setSystemLabelsFiltered(filtered: Boolean) {
|
||||
filterSystemLabelsFlow.value = filtered
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
fun setSelection(selection: ActivitySelection?) {
|
||||
selectionFlow.value = selection
|
||||
@@ -128,4 +134,4 @@ internal interface ActivityModelListener : EventListener {
|
||||
fun onDiffDataLoadingStopped(diffData: ActivityDiffData?) = Unit
|
||||
fun onFilteringStarted() = Unit
|
||||
fun onFilteringStopped(result: Set<ActivityItem>?) = Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,24 @@ package com.intellij.platform.lvcs.impl
|
||||
import com.intellij.history.ActivityId
|
||||
import com.intellij.history.LocalHistory
|
||||
import com.intellij.history.integration.IntegrationTestCase
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.lvcs.impl.settings.ActivityViewApplicationSettings
|
||||
import com.intellij.testFramework.HeavyPlatformTestCase
|
||||
import com.intellij.util.application
|
||||
import junit.framework.TestCase
|
||||
|
||||
class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
|
||||
private val showSystemLabels get() = application.service<ActivityViewApplicationSettings>().showSystemLabels
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
Registry.get("lvcs.show.system.labels.in.activity.view").setValue(false, testRootDisposable)
|
||||
val applicationSettings = application.service<ActivityViewApplicationSettings>()
|
||||
val prev = applicationSettings.showSystemLabels
|
||||
applicationSettings.showSystemLabels = false
|
||||
Disposer.register(testRootDisposable) { applicationSettings.showSystemLabels = prev }
|
||||
}
|
||||
|
||||
fun `test single file`() {
|
||||
@@ -30,13 +39,13 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFile(file)
|
||||
|
||||
val fileActivity = provider.loadActivityList(scope, null)
|
||||
val fileActivity = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
TestCase.assertEquals(/* file created + content changes */contents.size + 1, fileActivity.items.size)
|
||||
|
||||
val activityContents = getContentFor(file, fileActivity.getChangeSets())
|
||||
TestCase.assertEquals(/* content before change happened */listOf("") + contents.dropLast(1), activityContents.reversed())
|
||||
|
||||
val filteredActivity = provider.filterActivityList(scope, fileActivity, keyword)
|
||||
val filteredActivity = provider.filterActivityList(scope, fileActivity, keyword, showSystemLabels)
|
||||
TestCase.assertEquals(fileActivity.items[2], filteredActivity?.single())
|
||||
}
|
||||
|
||||
@@ -62,7 +71,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFile(file)
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val activityList = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
val labelNames = activityList.getLabelNameSet()
|
||||
|
||||
TestCase.assertTrue(labelNames.containsAll(listOf(userLabel, visibleUserLabel)))
|
||||
@@ -98,7 +107,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFile(file)
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val activityList = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
val labelNames = activityList.getLabelNameSet()
|
||||
|
||||
TestCase.assertEquals(listOf(userLabel1, userLabel2, userLabel3, visibleEventLabel1, visibleEventLabel2), labelNames.toList().sorted())
|
||||
@@ -119,7 +128,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFile(directory)
|
||||
|
||||
val directoryActivity = provider.loadActivityList(scope, null)
|
||||
val directoryActivity = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
TestCase.assertEquals(4, directoryActivity.items.size)
|
||||
TestCase.assertEquals(listOf("label",
|
||||
"Modify ${file.name}",
|
||||
@@ -149,14 +158,14 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.Recent
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val activityList = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
val labelNames = activityList.getLabelNameSet()
|
||||
|
||||
TestCase.assertTrue(labelNames.containsAll(listOf(label1, label2)))
|
||||
TestCase.assertTrue(labelNames.intersect(listOf(systemLabel, otherProjectLabel)).isEmpty())
|
||||
|
||||
for (f in listOf(file, otherFile)) {
|
||||
val fileActivity = provider.loadActivityList(scope, file.name)
|
||||
val fileActivity = provider.loadActivityList(scope, file.name, showSystemLabels)
|
||||
TestCase.assertEquals(3, fileActivity.items.size)
|
||||
|
||||
val activityContents = getContentFor(file, fileActivity.getChangeSets())
|
||||
@@ -183,7 +192,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFiles(listOf(file, otherFile))
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val activityList = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
|
||||
TestCase.assertEquals(listOf(visibleLabel,
|
||||
"Modify ${otherFile.name}",
|
||||
@@ -212,7 +221,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFiles(listOf(file, directory))
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val activityList = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
|
||||
TestCase.assertEquals(listOf("Modify ${file.name}",
|
||||
moveActionName,
|
||||
@@ -233,7 +242,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFiles(listOf(myRoot))
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val activityList = provider.loadActivityList(scope, null, showSystemLabels)
|
||||
|
||||
TestCase.assertEquals(listOf("MODIFIED:${file.name}"), getDiffDataForSelection(provider, scope, activityList, 0, 1))
|
||||
TestCase.assertEquals(listOf("ADDED:${innerDirectory.name}"), getDiffDataForSelection(provider, scope, activityList, 1, 2))
|
||||
|
||||
@@ -809,8 +809,6 @@ lvcs.show.activity.view=true
|
||||
lvcs.show.activity.view.description=Show new ui for the "Local History"
|
||||
lvcs.open.diff.automatically=true
|
||||
lvcs.open.diff.automatically.description=Open diff tab (if it is configured to be opened in the editor) when "Local History" tab is shown.
|
||||
lvcs.show.system.labels.in.activity.view=true
|
||||
lvcs.show.system.labels.in.activity.view.description=If true, show system labels in activity view such as "Tests Passed/Failed", "Shelve changes", etc.
|
||||
|
||||
vcs.showConsole=true
|
||||
vcs.showConsole.description=Show 'Console' tab in VCS toolwindow that logs all write-commands performed by IDE.
|
||||
|
||||
Reference in New Issue
Block a user