mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[lvcs] extract local history isEnabled API (IJPL-161713)
GitOrigin-RevId: 18a6bbdf87ff7b1919fdd745870820c5fa4c1826
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d90f879649
commit
8b44f407ee
@@ -27,6 +27,7 @@ a:com.intellij.history.LocalHistory
|
||||
- <init>():V
|
||||
- a:getByteContent(com.intellij.openapi.vfs.VirtualFile,com.intellij.history.FileRevisionTimestampComparator):B[]
|
||||
- sf:getInstance():com.intellij.history.LocalHistory
|
||||
- a:isEnabled():Z
|
||||
- a:isUnderControl(com.intellij.openapi.vfs.VirtualFile):Z
|
||||
- a:putEventLabel(com.intellij.openapi.project.Project,java.lang.String,com.intellij.history.ActivityId):com.intellij.history.Label
|
||||
- f:putSystemLabel(com.intellij.openapi.project.Project,java.lang.String):com.intellij.history.Label
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2024 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
|
||||
@@ -37,6 +37,12 @@ import org.jetbrains.annotations.ApiStatus
|
||||
* @see [ActivityId]
|
||||
*/
|
||||
abstract class LocalHistory {
|
||||
|
||||
/**
|
||||
* Is Local History enabled for all projects.
|
||||
*/
|
||||
abstract val isEnabled: Boolean
|
||||
|
||||
/**
|
||||
* Starts an action in the local history with the given name and [ActivityId] to indicate the start of file changes.
|
||||
* Call [LocalHistoryAction.finish] after the changes were performed.
|
||||
@@ -120,6 +126,8 @@ abstract class LocalHistory {
|
||||
abstract fun isUnderControl(file: VirtualFile): Boolean
|
||||
|
||||
private class Dummy : LocalHistory() {
|
||||
override val isEnabled: Boolean = true
|
||||
|
||||
override fun startAction(name: @NlsContexts.Label String?, activityId: ActivityId?): LocalHistoryAction = LocalHistoryAction.NULL
|
||||
override fun putEventLabel(project: Project, name: String, activityId: ActivityId): Label = Label.NULL_INSTANCE
|
||||
override fun putSystemLabel(project: Project, name: @NlsContexts.Label String, color: Int): Label = Label.NULL_INSTANCE
|
||||
|
||||
@@ -49,8 +49,10 @@ class LocalHistoryImpl(private val coroutineScope: CoroutineScope) : LocalHistor
|
||||
|
||||
private var daysToKeep = getInt(DAYS_TO_KEEP)
|
||||
|
||||
var isDisabled: Boolean = false
|
||||
private set
|
||||
override val isEnabled: Boolean
|
||||
get() = !isDisabled
|
||||
|
||||
private var isDisabled: Boolean = false
|
||||
|
||||
var facade: LocalHistoryFacade? = null
|
||||
private set
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
package com.intellij.history.integration.ui.actions;
|
||||
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.core.LocalHistoryFacade;
|
||||
import com.intellij.history.integration.IdeaGateway;
|
||||
import com.intellij.history.integration.LocalHistoryImpl;
|
||||
@@ -19,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class LocalHistoryAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
if (LocalHistoryImpl.getInstanceImpl().isDisabled()) {
|
||||
if (!LocalHistory.getInstance().isEnabled()) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xdebugger.impl.hotswap
|
||||
|
||||
import com.intellij.history.ActivityId
|
||||
import com.intellij.history.FileRevisionTimestampComparator
|
||||
import com.intellij.history.Label
|
||||
import com.intellij.history.LocalHistory
|
||||
import com.intellij.history.LocalHistoryAction
|
||||
import com.intellij.history.*
|
||||
import com.intellij.openapi.command.writeCommandAction
|
||||
import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -142,6 +138,8 @@ private class MockListener(private val scope: CoroutineScope, private val channe
|
||||
}
|
||||
|
||||
private class MockLocalHistory(val bytes: ByteArray) : LocalHistory() {
|
||||
override val isEnabled: Boolean = true
|
||||
|
||||
override fun getByteContent(file: VirtualFile, condition: FileRevisionTimestampComparator): ByteArray? = bytes
|
||||
override fun startAction(name: @NlsContexts.Label String?, activityId: ActivityId?): LocalHistoryAction = LocalHistoryAction.NULL
|
||||
override fun putEventLabel(project: Project, name: String, activityId: ActivityId): Label = Label.NULL_INSTANCE
|
||||
|
||||
Reference in New Issue
Block a user