mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
diff: remove dependency on VcsEditorTabFilesManager
GitOrigin-RevId: 147d7554e49006d11866943ddaaa9f65350a0f27
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a2b26d2f64
commit
b2bc5e1223
@@ -9,5 +9,7 @@
|
||||
<applicationListeners>
|
||||
<listener class="com.intellij.diff.editor.EditorTabDiffPreviewAdvancedSettingsListener"
|
||||
topic="com.intellij.openapi.options.advanced.AdvancedSettingsChangeListener"/>
|
||||
<listener class="com.intellij.diff.editor.DiffInWindowDndListener"
|
||||
topic="com.intellij.openapi.fileEditor.FileOpenedSyncListener"/>
|
||||
</applicationListeners>
|
||||
</idea-plugin>
|
||||
@@ -5,8 +5,12 @@ import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.diff.editor.DiffEditorTabFilesManager.Companion.isDiffInEditor
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.application.invokeLater
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.FileOpenedSyncListener
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorWithProvider
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWindow
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorOpenOptions
|
||||
@@ -114,6 +118,29 @@ internal class EditorTabDiffPreviewAdvancedSettingsListener : AdvancedSettingsCh
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle option on drag-n-drop
|
||||
*/
|
||||
internal class DiffInWindowDndListener : FileOpenedSyncListener {
|
||||
override fun fileOpenedSync(editorManager: FileEditorManager, file: VirtualFile, editorsWithProviders: List<FileEditorWithProvider>) {
|
||||
if (file !is DiffContentVirtualFile) return
|
||||
if (editorManager !is FileEditorManagerImpl) return
|
||||
|
||||
// flag is not properly set for async editor opening
|
||||
//if (file.getUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN) != true) return
|
||||
|
||||
val openedFileEditors = editorsWithProviders.map { it.fileEditor }
|
||||
val window = editorManager.windows.find { it.allComposites.any { it.allEditors.any { openedFileEditors.contains(it) } } } ?: return
|
||||
|
||||
val isFileInEditor = !isSingletonEditorInWindow(window)
|
||||
if (DiffEditorTabFilesManager.isDiffInEditor != isFileInEditor) {
|
||||
invokeLater(ModalityState.nonModal()) {
|
||||
DiffEditorTabFilesManager.isDiffInEditor = isFileInEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun isSingletonEditorInWindow(window: EditorWindow): Boolean {
|
||||
return window.owner.isFloating && window.tabCount == 1
|
||||
}
|
||||
|
||||
@@ -1419,11 +1419,6 @@ c:com.intellij.openapi.vcs.changes.DefaultChangeListOwner
|
||||
- addUnversionedFiles(com.intellij.openapi.vcs.changes.LocalChangeList,java.util.List):V
|
||||
- getProject():com.intellij.openapi.project.Project
|
||||
- moveChangesTo(com.intellij.openapi.vcs.changes.LocalChangeList,java.util.List):V
|
||||
a:com.intellij.openapi.vcs.changes.DefaultDiffEditorTabFilesListener
|
||||
- com.intellij.openapi.vcs.changes.VcsEditorTabFilesListener
|
||||
- <init>():V
|
||||
- a:shouldOpenInNewWindowChanged(com.intellij.diff.editor.DiffContentVirtualFile,Z):V
|
||||
- f:shouldOpenInNewWindowChanged(com.intellij.openapi.vfs.VirtualFile,Z):V
|
||||
c:com.intellij.openapi.vcs.changes.DeletedFilesHolder
|
||||
- com.intellij.openapi.vcs.changes.FileHolder
|
||||
- <init>():V
|
||||
@@ -1436,10 +1431,6 @@ c:com.intellij.openapi.vcs.changes.DeletedFilesHolder
|
||||
- hashCode():I
|
||||
- isContainedInLocallyDeleted(com.intellij.openapi.vcs.FilePath):Z
|
||||
- takeFrom(com.intellij.openapi.vcs.changes.DeletedFilesHolder):V
|
||||
f:com.intellij.openapi.vcs.changes.DiffEditorTabStateListener
|
||||
- com.intellij.openapi.vcs.changes.DefaultDiffEditorTabFilesListener
|
||||
- <init>():V
|
||||
- shouldOpenInNewWindowChanged(com.intellij.diff.editor.DiffContentVirtualFile,Z):V
|
||||
com.intellij.openapi.vcs.changes.DiffPreview
|
||||
- sf:Companion:com.intellij.openapi.vcs.changes.DiffPreview$Companion
|
||||
- a:closePreview():V
|
||||
|
||||
@@ -58,8 +58,4 @@
|
||||
<listener class="com.intellij.platform.ide.impl.statistic.ToolWindowStateListener"
|
||||
topic="com.intellij.openapi.wm.ex.ToolWindowManagerListener"/>
|
||||
</projectListeners>
|
||||
<applicationListeners>
|
||||
<listener class="com.intellij.openapi.vcs.changes.DiffEditorTabStateListener"
|
||||
topic="com.intellij.openapi.vcs.changes.VcsEditorTabFilesListener"/>
|
||||
</applicationListeners>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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.openapi.vcs.changes
|
||||
|
||||
import com.intellij.diff.editor.DiffContentVirtualFile
|
||||
import com.intellij.diff.editor.DiffEditorTabFilesManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
abstract class DefaultDiffEditorTabFilesListener : VcsEditorTabFilesListener {
|
||||
final override fun shouldOpenInNewWindowChanged(file: VirtualFile, shouldOpenInNewWindow: Boolean) {
|
||||
if (file is DiffContentVirtualFile) {
|
||||
shouldOpenInNewWindowChanged(file as DiffContentVirtualFile, shouldOpenInNewWindow)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun shouldOpenInNewWindowChanged(diffFile: DiffContentVirtualFile, shouldOpenInNewWindow: Boolean)
|
||||
}
|
||||
|
||||
|
||||
class DiffEditorTabStateListener : DefaultDiffEditorTabFilesListener() {
|
||||
|
||||
override fun shouldOpenInNewWindowChanged(diffFile: DiffContentVirtualFile, shouldOpenInNewWindow: Boolean) {
|
||||
DiffEditorTabFilesManager.isDiffInEditor = !shouldOpenInNewWindow
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ package com.intellij.openapi.vcs.changes
|
||||
import com.intellij.diff.DiffContext
|
||||
import com.intellij.diff.actions.impl.SetEditorSettingsAction
|
||||
import com.intellij.diff.actions.impl.SetEditorSettingsActionGroup
|
||||
import com.intellij.diff.editor.DiffContentVirtualFile
|
||||
import com.intellij.diff.editor.DiffEditorTabFilesManager
|
||||
import com.intellij.diff.editor.DiffRequestProcessorEditorCustomizer
|
||||
import com.intellij.diff.util.DiffUserDataKeysEx
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.actionSystem.ActionToolbar
|
||||
import com.intellij.openapi.actionSystem.impl.ActionButtonUtil
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
import com.intellij.openapi.options.advanced.AdvancedSettingsChangeListener
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vcs.VcsBundle
|
||||
import com.intellij.openapi.vcs.changes.ui.ActionToolbarGotItTooltip
|
||||
@@ -27,9 +28,11 @@ internal class ShowDiffInEditorTooltipInstaller : DiffRequestProcessorEditorCust
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowDiffInEditorTabTooltipHolder(disposable: Disposable,
|
||||
private val toolbarToShowTooltip: ActionToolbar) :
|
||||
DefaultDiffEditorTabFilesListener(), Disposable {
|
||||
private class ShowDiffInEditorTabTooltipHolder(
|
||||
disposable: Disposable,
|
||||
private val toolbarToShowTooltip: ActionToolbar,
|
||||
)
|
||||
: AdvancedSettingsChangeListener, Disposable {
|
||||
|
||||
companion object {
|
||||
const val TOOLTIP_ID = "show.diff.in.editor"
|
||||
@@ -42,11 +45,11 @@ private class ShowDiffInEditorTabTooltipHolder(disposable: Disposable,
|
||||
|
||||
init {
|
||||
Disposer.register(disposable, this)
|
||||
ApplicationManager.getApplication().messageBus.connect(this).subscribe(VcsEditorTabFilesListener.TOPIC, this)
|
||||
ApplicationManager.getApplication().messageBus.connect(this).subscribe(AdvancedSettingsChangeListener.TOPIC, this)
|
||||
}
|
||||
|
||||
override fun shouldOpenInNewWindowChanged(diffFile: DiffContentVirtualFile, shouldOpenInNewWindow: Boolean) {
|
||||
if (shouldOpenInNewWindow) {
|
||||
override fun advancedSettingChanged(id: String, oldValue: Any, newValue: Any) {
|
||||
if (id == DiffEditorTabFilesManager.SHOW_DIFF_IN_EDITOR_SETTING && !DiffEditorTabFilesManager.isDiffInEditor) {
|
||||
showGotItTooltip()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
package com.intellij.openapi.vcs.changes
|
||||
|
||||
import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.diff.editor.DiffContentVirtualFile
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWindow
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorOpenOptions
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -28,22 +23,6 @@ class VcsEditorTabFilesManager :
|
||||
var openInNewWindow by property(false)
|
||||
}
|
||||
|
||||
init {
|
||||
val messageBus = ApplicationManager.getApplication().messageBus
|
||||
messageBus.connect(this).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, object : FileEditorManagerListener {
|
||||
override fun fileOpened(source: FileEditorManager, file: VirtualFile) {
|
||||
//currently shouldOpenInNewWindow is bound only to diff files
|
||||
if (file is DiffContentVirtualFile && source is FileEditorManagerEx) {
|
||||
val isOpenInNewWindow = source.findFloatingWindowForFile(file)?.let {
|
||||
it.tabCount == 1
|
||||
} ?: false
|
||||
shouldOpenInNewWindow = isOpenInNewWindow
|
||||
messageBus.syncPublisher(VcsEditorTabFilesListener.TOPIC).shouldOpenInNewWindowChanged(file, isOpenInNewWindow)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var shouldOpenInNewWindow: Boolean
|
||||
get() = state.openInNewWindow
|
||||
private set(value) {
|
||||
@@ -89,11 +68,6 @@ class VcsEditorTabFilesManager :
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getInstance(): VcsEditorTabFilesManager = service()
|
||||
|
||||
@JvmStatic
|
||||
fun FileEditorManagerEx.findFloatingWindowForFile(file: VirtualFile): EditorWindow? {
|
||||
return windows.find { it.owner.isFloating && it.isFileOpen(file) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user